Class VarResolver
Variables are of the form
The variable key can contain anything, even nested variables that get recursively resolved.
Variables are defined through the VarResolver.Builder.vars(Class[])
method.
The Var
interface defines how variables are converted to values.
Example:
See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final VarResolver
Default string variable resolver with support for system properties and environment variables:$S{key[,default]} -SystemPropertiesVar
$E{key[,default]} -EnvVariablesVar
$A{key[,default]} -ArgsVar
$MF{key[,default]} -ManifestFileVar
$SW{stringArg,pattern:thenValue[,pattern:thenValue...]} -SwitchVar
$IF{arg,then[,else]} -IfVar
$CO{arg[,arg2...]} -CoalesceVar
$PM{arg,pattern} -PatternMatchVar
$PR{stringArg,pattern,replace} -PatternReplaceVar
$PE{arg,pattern,groupIndex} -PatternExtractVar
$UC{arg} -UpperCaseVar
$LC{arg} -LowerCaseVar
$NE{arg} -NotEmptyVar
$LN{arg[,delimiter]} -LenVar
$ST{arg,start[,end]} -SubstringVar
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<T> VarResolver
Adds a bean to this session.copy()
Returns a new builder object using the settings in this resolver as a base.static VarResolver.Builder
create()
Instantiates a new clean-slateVarResolver.Builder
object.Creates a new resolver session with no session objects.createSession
(BeanStore beanStore) Same ascreateSession()
except allows you to specify a bean store for resolving beans.Returns an unmodifiable map ofVars
associated with this context.protected Var[]
getVars()
Returns an array of variables define in this variable resolver context.Resolve variables in the specified string.void
Resolve variables in the specified string and sends the results to the specified writer.
-
Field Details
-
DEFAULT
Default string variable resolver with support for system properties and environment variables:$S{key[,default]} -SystemPropertiesVar
$E{key[,default]} -EnvVariablesVar
$A{key[,default]} -ArgsVar
$MF{key[,default]} -ManifestFileVar
$SW{stringArg,pattern:thenValue[,pattern:thenValue...]} -SwitchVar
$IF{arg,then[,else]} -IfVar
$CO{arg[,arg2...]} -CoalesceVar
$PM{arg,pattern} -PatternMatchVar
$PR{stringArg,pattern,replace} -PatternReplaceVar
$PE{arg,pattern,groupIndex} -PatternExtractVar
$UC{arg} -UpperCaseVar
$LC{arg} -LowerCaseVar
$NE{arg} -NotEmptyVar
$LN{arg[,delimiter]} -LenVar
$ST{arg,start[,end]} -SubstringVar
-
-
Constructor Details
-
VarResolver
Constructor.- Parameters:
builder
- The builder for this object.
-
-
Method Details
-
create
Instantiates a new clean-slateVarResolver.Builder
object.- Returns:
- A new
VarResolver.Builder
object.
-
copy
Returns a new builder object using the settings in this resolver as a base.- Returns:
- A new var resolver builder.
-
getVarMap
Returns an unmodifiable map ofVars
associated with this context.- Returns:
- A map whose keys are var names (e.g.
"S" ) and values areVar
instances.
-
getVars
Returns an array of variables define in this variable resolver context.- Returns:
- A new array containing the variables in this context.
-
addBean
Adds a bean to this session.- Type Parameters:
T
- The bean type.- Parameters:
c
- The bean type.value
- The bean.- Returns:
- This object .
-
createSession
Creates a new resolver session with no session objects.- Returns:
- A new resolver session.
-
createSession
Same ascreateSession()
except allows you to specify a bean store for resolving beans.- Parameters:
beanStore
- The bean store to associate with this session.- Returns:
- A new resolver session.
-
resolve
Resolve variables in the specified string.This is a shortcut for calling
createSession(
.null ).resolve(s);
This method can only be used if the string doesn't contain variables that rely on the existence of session variables.- Parameters:
s
- The input string.- Returns:
- The string with variables resolved, or the same string if it doesn't contain any variables to resolve.
-
resolveTo
Resolve variables in the specified string and sends the results to the specified writer.This is a shortcut for calling
createSession(
.null ).resolveTo(s, w);
This method can only be used if the string doesn't contain variables that rely on the existence of session variables.- Parameters:
s
- The input string.w
- The writer to send the result to.- Throws:
IOException
- Thrown by underlying stream.
-