public class VarResolver extends Object
Variables are of the form
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:
SystemPropertiesVar
EnvVariablesVar
ArgsVar
ManifestFileVar
SwitchVar
IfVar
CoalesceVar
PatternMatchVar
PatternReplaceVar
PatternExtractVar
UpperCaseVar
LowerCaseVar
NotEmptyVar
LenVar
SubstringVar
|
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
SystemPropertiesVar
EnvVariablesVar
ArgsVar
ManifestFileVar
SwitchVar
IfVar
CoalesceVar
PatternMatchVar
PatternReplaceVar
PatternExtractVar
UpperCaseVar
LowerCaseVar
NotEmptyVar
LenVar
SubstringVar
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
- Thrown by underlying stream.Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.