public class VarResolver extends Object
Variables are of the form $X{key}
, where X
can consist of zero or more ASCII characters.
The variable key can contain anything, even nested variables that get recursively resolved.
Variables are defined through the VarResolverBuilder.vars(Class[])
method.
The Var
interface defines how variables are converted to values.
Modifier and Type | Field and Description |
---|---|
static VarResolver |
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
$IF{arg,then[,else]} - IfVar
$SW{arg,pattern1:then1[,pattern2:then2...]} - SwitchVar
$CO{arg[,arg2...]} - CoalesceVar
$PM{arg,pattern} - PatternMatchVar
$UC{arg} - UpperCaseVar
$LC{arg} - LowerCaseVar
$NE{arg} - NotEmptyVar
|
Modifier and Type | Method and Description |
---|---|
VarResolverBuilder |
builder()
Returns a new builder object using the settings in this resolver as a base.
|
static VarResolverBuilder |
create()
Instantiates a new clean-slate
VarResolverBuilder object. |
VarResolverSession |
createSession()
Creates a new resolver session with no session objects.
|
VarResolverSession |
createSession(Map<String,Object> sessionObjects)
Same as
createSession() except allows you to specify session objects as a map. |
VarResolverContext |
getContext()
Returns the read-only properties on this variable resolver.
|
String |
resolve(String s)
Resolve variables in the specified string.
|
void |
resolveTo(String s,
Writer w)
Resolve variables in the specified string and sends the results to the specified writer.
|
public static final VarResolver DEFAULT
$S{key[,default]}
- SystemPropertiesVar
$E{key[,default]}
- EnvVariablesVar
$A{key[,default]}
- ArgsVar
$MF{key[,default]}
- ManifestFileVar
$IF{arg,then[,else]}
- IfVar
$SW{arg,pattern1:then1[,pattern2:then2...]}
- SwitchVar
$CO{arg[,arg2...]}
- CoalesceVar
$PM{arg,pattern}
- PatternMatchVar
$UC{arg}
- UpperCaseVar
$LC{arg}
- LowerCaseVar
$NE{arg}
- NotEmptyVar
SystemPropertiesVar
,
EnvVariablesVar
public static VarResolverBuilder create()
VarResolverBuilder
object.
This is equivalent to simply calling
.
VarResolverBuilder
object.public VarResolverBuilder builder()
public VarResolverContext getContext()
public VarResolverSession createSession()
Session objects can be associated with the specified session using the VarResolverSession.sessionObject(String, Object)
method.
public VarResolverSession createSession(Map<String,Object> sessionObjects)
createSession()
except allows you to specify session objects as a map.sessionObjects
- The session objects to associate with the session.public String resolve(String s)
This is a shortcut for calling createSession(
.
This method can only be used if the string doesn't contain variables that rely on the existence of session
variables.
s
- The input string.public void resolveTo(String s, Writer w) throws IOException
This is a shortcut for calling createSession(
.
This method can only be used if the string doesn't contain variables that rely on the existence of session
variables.
s
- The input string.w
- The writer to send the result to.IOException
Copyright © 2018 Apache. All rights reserved.