Class Template
- java.lang.Object
-
- org.forgerock.config.resolvers.template.Template
-
public final class Template extends Object
Represents a templated string.It may contain resolvable properties.
A
Templateis obtained either programmatically using the static factory methods defined in this class (empty(),textual(String),property(Template, Template)andsequence(Template...)) or through the parsing of a templated string (seecompile(String)orTemplateParser.parse(String, boolean)).- See Also:
TemplateVisitor
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T,C>
Taccept(TemplateVisitor<T,C> visitor, C context)Apply an operation (the visitor) to this template.static Templatecompile(String source)Build a newTemplatefrom the givensourcevalue.static Templatecompile(String source, boolean escaping)Build a newTemplatefrom the givensourcevalue, instructing the parser to either escape or not special characters with the help of theescapingparameter.static Templateempty()Constructs a new empty template.static Templateproperty(Template name)Constructs a new property template with the givennameTemplate.static Templateproperty(Template name, Template defaultValue)Constructs a new property template with the givennameanddefaultValuetemplates.static Templatesequence(List<Template> templates)Constructs a new sequence template from the giventemplateslist.static Templatesequence(Template... templates)Constructs a new sequence template from the giventemplateslist.static Templatetextual(String text)Constructs a new textual template with the giventext.StringtoString()
-
-
-
Method Detail
-
compile
public static Template compile(String source)
Build a newTemplatefrom the givensourcevalue.It enables escaping (protection with '\' of special characters as described in
TemplateTokenizer).- Parameters:
source- templated string- Returns:
- a new
Templateinstance
-
compile
public static Template compile(String source, boolean escaping)
Build a newTemplatefrom the givensourcevalue, instructing the parser to either escape or not special characters with the help of theescapingparameter.It supports escaping (protection with '\' of special characters as described in
TemplateTokenizer).- Parameters:
source- templated stringescaping- control escaping mode- Returns:
- a new
Templateinstance
-
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 typeC- the context type- Parameters:
visitor- the operation to apply (nevernull)context- operation's context (may benull)- 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 giventext.- Parameters:
text- textual value (nevernull, but can be empty)- Returns:
- a new textual template
-
property
public static Template property(Template name)
Constructs a new property template with the givennameTemplate.It's equivalent to use property(Template, Template) with an
empty()template for the default value.- Parameters:
name- template for property name (nevernull)- 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 givennameanddefaultValuetemplates.- Parameters:
name- template for property name (nevernull)defaultValue- template for property default value (nevernull)- Returns:
- a new property template
-
sequence
public static Template sequence(Template... templates)
Constructs a new sequence template from the giventemplateslist.- Parameters:
templates- list of templates- Returns:
- a new sequence template
-
-