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 Template
Build a newTemplate
from the givensource
value.static Template
Build a newTemplate
from the givensource
value, instructing the parser to either escape or not special characters with the help of theescaping
parameter.static Template
empty()
Constructs a new empty template.static Template
Constructs a new property template with the givenname
Template.static Template
Constructs a new property template with the givenname
anddefaultValue
templates.static Template
Constructs a new sequence template from the giventemplates
list.static Template
Constructs a new sequence template from the giventemplates
list.static Template
Constructs a new textual template with the giventext
.toString()
-
Method Details
-
compile
Build a newTemplate
from the givensource
value.It enables escaping (protection with '\' of special characters as described in
TemplateTokenizer
).- Parameters:
source
- templated string- Returns:
- a new
Template
instance
-
compile
Build a newTemplate
from the givensource
value, instructing the parser to either escape or not special characters with the help of theescaping
parameter.It supports escaping (protection with '\' of special characters as described in
TemplateTokenizer
).- Parameters:
source
- templated stringescaping
- control escaping mode- Returns:
- a new
Template
instance
-
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 givenname
Template.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 givenname
anddefaultValue
templates.- 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 giventemplates
list.- Parameters:
templates
- list of templates- Returns:
- a new sequence template
-
sequence
Constructs a new sequence template from the giventemplates
list.- Parameters:
templates
- list of templates (nevernull
)- Returns:
- a new sequence template
-