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
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final VarResolverDefault 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
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> VarResolverAdds a bean to this session.copy()Returns a new builder object using the settings in this resolver as a base.static VarResolver.Buildercreate()Instantiates a new clean-slateVarResolver.Builderobject.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 ofVarsassociated with this context.protected Var[]getVars()Returns an array of variables define in this variable resolver context.Resolve variables in the specified string.voidResolve 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.Builderobject.- Returns:
- A new
VarResolver.Builderobject.
-
addBean
Adds a bean to this session.- Type Parameters:
T- The bean type.- Parameters:
c- The bean type.value- The bean.- Returns:
- This object .
-
copy
Returns a new builder object using the settings in this resolver as a base.- Returns:
- A new var resolver builder.
-
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.
-
getVarMap
Returns an unmodifiable map ofVarsassociated with this context.- Returns:
- A map whose keys are var names (e.g.
"S" ) and values areVarinstances.
-
getVars
Returns an array of variables define in this variable resolver context.- Returns:
- A new array containing the variables in this context.
-