Class Template

    • Method Detail

      • compile

        public static Template compile​(String source)
        Build a new Template from the given source value.

        It enables escaping (protection with '\' of special characters as described in TemplateTokenizer).

        Parameters:
        source - templated string
        Returns:
        a new Template instance
      • compile

        public static Template compile​(String source,
                                       boolean escaping)
        Build a new Template from the given source value, instructing the parser to either escape or not special characters with the help of the escaping parameter.

        It supports escaping (protection with '\' of special characters as described in TemplateTokenizer).

        Parameters:
        source - templated string
        escaping - control escaping mode
        Returns:
        a new Template instance
      • accept

        public <T,​C> T accept​(TemplateVisitor<T,​C> visitor,
                                    C context)
        Apply an operation (the visitor) to this template.
        Type Parameters:
        T - the result type
        C - the context type
        Parameters:
        visitor - the operation to apply (never null)
        context - operation's context (may be null)
        Returns:
        the result of the visitor applied to this template (can be null)
      • empty

        public static Template empty()
        Constructs a new empty template. Can be used for property's default value when not set.
        Returns:
        a new empty template
      • textual

        public static Template textual​(String text)
        Constructs a new textual template with the given text.
        Parameters:
        text - textual value (never null, but can be empty)
        Returns:
        a new textual template
      • property

        public static Template property​(Template name)
        Constructs a new property template with the given name Template.

        It's equivalent to use property(Template, Template) with an empty() template for the default value.

        Parameters:
        name - template for property name (never null)
        Returns:
        a new property template with no default value
      • property

        public static Template property​(Template name,
                                        Template defaultValue)
        Constructs a new property template with the given name and defaultValue templates.
        Parameters:
        name - template for property name (never null)
        defaultValue - template for property default value (never null)
        Returns:
        a new property template
      • sequence

        public static Template sequence​(Template... templates)
        Constructs a new sequence template from the given templates list.
        Parameters:
        templates - list of templates
        Returns:
        a new sequence template
      • sequence

        public static Template sequence​(List<Template> templates)
        Constructs a new sequence template from the given templates list.
        Parameters:
        templates - list of templates (never null)
        Returns:
        a new sequence template