Alternate constructor that uses a variable name pattern that permits variable names with alphanumerics and underscore.
Alternate constructor that uses a variable name pattern that permits variable names with alphanumerics and underscore.
A function that takes a variable name as a parameter
and returns an Option[String]
value for the
variable, or None
if there is no value
(Map[String, String].get()
, for instance).
true
for a "safe" template that just
substitutes a blank string for an unknown variable,
false
for one that throws an exception.
A function that takes a variable name as a parameter
and returns an Option[String]
value for the
variable, or None
if there is no value
(Map[String, String].get()
, for instance).
Regular expression pattern to match a variable name, as a string (not a Regex). For example: "[a-zA-Z0-9_]+"
true
for a "safe" template that just substitutes
a blank string for an unknown variable, false
for one that throws an exception.
Parse the location of the first variable in string.
Parse the location of the first variable in string.
the string
an Option[Variable]
, specifying the variable's
location; or None
if not found
A function that takes a variable name as a parameter and
returns an Option[String]
value for the variable,
or None
if there is no value
(Map[String, String].get()
, for instance).
A function that takes a variable name as a parameter and
returns an Option[String]
value for the variable,
or None
if there is no value
(Map[String, String].get()
, for instance).
true
for a "safe" template that just substitutes
a blank string for an unknown variable, false
for one that throws an exception.
true
for a "safe" template that just substitutes
a blank string for an unknown variable, false
for one that throws an exception.
Replace all variable references in the given string.
Replace all variable references in the given string. Variable references are recognized per the regular expression passed to the constructor. If a referenced variable is not found in the resolver, this method either:
- throws a VariableNotFoundException
(if safe
is false
), or
- substitutes an empty string (if safe
is true
)
Recursive references are supported (but beware of infinite recursion).
the string in which to replace variable references
Success(substitutedValue)
or Failure(error)
A string template that uses the Unix shell-like syntax
${varname}
(or$varname
) for variable references. A variable's name may consist of alphanumerics and underscores. To include a literal "$" in a string, escape it with a backslash.For this class, the general form of a variable reference is:
}
The
?default
suffix is optional and specifies a default value to be used if the variable has no value.A shorthand form of a variable reference is:
The default capability is not available in the shorthand form.