Class Template
java.lang.Object
org.forgerock.config.resolvers.template.Template
Represents a templated string.
It may contain resolvable properties.
A Template is obtained either programmatically using the static factory methods
defined in this class (empty(), textual(String), property(Template, Template)
and sequence(Template...)) or through the parsing of a templated string (see compile(String)
or TemplateParser.parse(String, boolean)).
- See Also:
-
Method Summary
Modifier and TypeMethodDescription<T,C> T accept(TemplateVisitor<T, C> visitor, C context) Apply an operation (the visitor) to this template.static TemplateBuild a newTemplatefrom the givensourcevalue.static TemplateBuild 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 TemplateConstructs a new property template with the givennameTemplate.static TemplateConstructs a new property template with the givennameanddefaultValuetemplates.static TemplateConstructs a new sequence template from the giventemplateslist.static TemplateConstructs a new sequence template from the giventemplateslist.static TemplateConstructs a new textual template with the giventext.toString()
-
Method Details
-
compile
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
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
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)
-
toString
-
empty
Constructs a new empty template. Can be used for property's default value when not set.- Returns:
- a new empty template
-
textual
Constructs a new textual template with the giventext.- Parameters:
text- textual value (nevernull, but can be empty)- Returns:
- a new textual template
-
property
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
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
Constructs a new sequence template from the giventemplateslist.- Parameters:
templates- list of templates- Returns:
- a new sequence template
-
sequence
Constructs a new sequence template from the giventemplateslist.- Parameters:
templates- list of templates (nevernull)- Returns:
- a new sequence template
-