public class StringResolver extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DELIM_START |
static String |
DELIM_STOP |
Constructor and Description |
---|
StringResolver() |
Modifier and Type | Method and Description |
---|---|
static boolean |
needsResolution(String string)
Check if the input string needs property substitution applied.
|
static String |
substVars(String val,
Map<?,?> props)
Do variable substitution on a string to resolve ${x2} to the value of the
property x2.
|
static String |
substVars(String val,
Map<?,?> props,
boolean resolveWithPropertyName)
Do variable substitution on a string to resolve ${x2} to the value of the
property x2.
|
static String |
substVars(String val,
Map<?,?> props1,
Map<?,?> props2)
Do variable substitution on a string to resolve ${x2} to the value of the
property x2.
|
static String |
substVars(String val,
Map<?,?> props1,
Map<?,?> props2,
boolean resolveWithPropertyName)
Do variable substitution on a string to resolve ${x2} to the value of the
property x2.
|
static String |
substVars(String val,
Map<?,?> props1,
Map<?,?> props2,
Set<String> propsToHide)
Do variable substitution on a string to resolve ${x2} to the value of the
property x2.
|
static String |
substVars(String val,
Map<?,?> props1,
Map<?,?> props2,
Set<String> propsToHide,
boolean resolveWithPropertyName)
Do variable substitution on a string to resolve ${x2} to the value of the
property x2.
|
static String |
substVars(String val,
Map<?,?> props1,
Map<?,?> props2,
Set<String> propsToHide,
String delimStart,
String delimStop)
Do variable substitution on a string to resolve ${x2} to the value of the
property x2.
|
static String |
substVars(String val,
Map<?,?> props1,
Map<?,?> props2,
Set<String> propsToHide,
String delimStart,
String delimStop,
boolean resolveWithPropertyName)
Do variable substitution on a string to resolve ${x2} to the value of the
property x2.
|
public static final String DELIM_START
public static final String DELIM_STOP
public static String substVars(String val, Map<?,?> props1, Map<?,?> props2, Set<String> propsToHide) throws IllegalArgumentException
Properties prop = new Properties();
prop.put("test.name", "this is a name with ${test.xx}");
prop.put("test.xx", "again");
System.out.println(prop.get("test.name"));
will print this is a name with again
First it looks in the System environment and System properties, if none is found
then all installed AdditionalStringResolver
s are scanned for providing a replacement.
If no replacement is found still and a Map
(or Properties
) object is specified, it looks in the specified
object. If two Map
or Properties
objects are supplied, it looks first in the first and if none found
then in the second object.
val
- Value in which to provide string substitutionsprops1
- First property object in which to find substitutionsprops2
- Second property object in which to find substitutionspropsToHide
- Optional collection of property names to hide from the output. If not null, then
all credentials will also be hidden, in addition to properties named in the collection.IllegalArgumentException
- if there were invalid input arguments.public static String substVars(String val, Map<?,?> props1, Map<?,?> props2, Set<String> propsToHide, String delimStart, String delimStop) throws IllegalArgumentException
Properties prop = new Properties();
prop.put("test.name", "this is a name with ${test.xx}");
prop.put("test.xx", "again");
System.out.println(prop.get("test.name"));
will print this is a name with again
First it looks in the System environment and System properties, if none is found
then all installed AdditionalStringResolver
s are scanned for providing a replacement.
If no replacement is found still and a Map
(or Properties
) object is specified, it looks in the specified
object. If two Map
or Properties
objects are supplied, it looks first in the first and if none found
then in the second object.
val
- Value in which to provide string substitutionsprops1
- First property object in which to find substitutionsprops2
- Second property object in which to find substitutionspropsToHide
- Optional collection of property names to hide from the output. If not null, then
all credentials will also be hidden, in addition to properties named in the collection.delimStart
- Start of substitution pattern delimiterdelimStop
- End of substitution pattern delimiterIllegalArgumentException
- if there were invalid input arguments.public static String substVars(String val, Map<?,?> props1, Map<?,?> props2, Set<String> propsToHide, String delimStart, String delimStop, boolean resolveWithPropertyName) throws IllegalArgumentException
Properties prop = new Properties();
prop.put("test.name", "this is a name with ${test.xx}");
prop.put("test.xx", "again");
System.out.println(prop.get("test.name"));
will print this is a name with again
First it looks in the System environment and System properties, if none is found
then all installed AdditionalStringResolver
s are scanned for providing a replacement.
If no replacement is found still and a Map
(or Properties
) object is specified, it looks in the specified
object. If two Map
or Properties
objects are supplied, it looks first in the first and if none found
then in the second object.
val
- Value in which to provide string substitutionsprops1
- First property object in which to find substitutionsprops2
- Second property object in which to find substitutionspropsToHide
- Optional collection of property names to hide from the output. If not null, then
all credentials will also be hidden, in addition to properties named in the collection.delimStart
- Start of substitution pattern delimiterdelimStop
- End of substitution pattern delimiterresolveWithPropertyName
- Flag indicating if property names should also be part of the output, for debugging of
configurations.IllegalArgumentException
- if there were invalid input arguments.public static String substVars(String val, Map<?,?> props1, Map<?,?> props2) throws IllegalArgumentException
Properties prop = new Properties();
prop.put("test.name", "this is a name with ${test.xx}");
prop.put("test.xx", "again");
System.out.println(prop.get("test.name"));
will print this is a name with again
First it looks in the System environment and System properties, if none is found
then all installed AdditionalStringResolver
s are scanned for providing a replacement.
If no replacement is found still and a Map
(or Properties
) object is specified, it looks in the specified
object. If two Map
or Properties
objects are supplied, it looks first in the first and if none found
then in the second object.
val
- Value in which to provide string substitutionsprops1
- First property object in which to find substitutionsprops2
- Second property object in which to find substitutionsIllegalArgumentException
- if there were invalid input arguments.public static String substVars(String val, Map<?,?> props) throws IllegalArgumentException
Properties prop = new Properties();
prop.put("test.name", "this is a name with ${test.xx}");
prop.put("test.xx", "again");
System.out.println(prop.get("test.name"));
will print this is a name with again
First it looks in the System environment and System properties, if none is found
then all installed AdditionalStringResolver
s are scanned for providing a replacement.
If no replacement is found still and a Map
(or Properties
) object is specified, it looks in the specified
object.
val
- Value in which to provide string substitutionsprops
- Property object in which to find substitutionsIllegalArgumentException
- if there were invalid input arguments.public static String substVars(String val, Map<?,?> props, boolean resolveWithPropertyName)
Properties prop = new Properties();
prop.put("test.name", "this is a name with ${test.xx}");
prop.put("test.xx", "again");
System.out.println(prop.get("test.name"));
will print this is a name with again
First it looks in the System environment and System properties, if none is found
then all installed AdditionalStringResolver
s are scanned for providing a replacement.
If no replacement is found still and a Map
(or Properties
) object is specified, it looks in the specified
object.
val
- Value in which to provide string substitutionsprops
- Property object in which to find substitutionsresolveWithPropertyName
- Flag indicating if property names should also be part of the output, for debugging of
configurations.IllegalArgumentException
- if there were invalid input arguments.public static String substVars(String val, Map<?,?> props1, Map<?,?> props2, boolean resolveWithPropertyName) throws IllegalArgumentException
Properties prop = new Properties();
prop.put("test.name", "this is a name with ${test.xx}");
prop.put("test.xx", "again");
System.out.println(prop.get("test.name"));
will print this is a name with again
First it looks in the System environment and System properties, if none is found
then all installed AdditionalStringResolver
s are scanned for providing a replacement.
If no replacement is found still and a Map
(or Properties
) object is specified, it looks in the specified
object. If two Map
or Properties
objects are supplied, it looks first in the first and if none found
then in the second object.
val
- Value in which to provide string substitutionsprops1
- First property object in which to find substitutionsprops2
- Second property object in which to find substitutionsresolveWithPropertyName
- Flag indicating if property names should also be part of the output, for debugging of
configurations.IllegalArgumentException
- if there were invalid input arguments.public static String substVars(String val, Map<?,?> props1, Map<?,?> props2, Set<String> propsToHide, boolean resolveWithPropertyName) throws IllegalArgumentException
Properties prop = new Properties();
prop.put("test.name", "this is a name with ${test.xx}");
prop.put("test.xx", "again");
System.out.println(prop.get("test.name"));
will print this is a name with again
First it looks in the System environment and System properties, if none is found
then all installed AdditionalStringResolver
s are scanned for providing a replacement.
If no replacement is found still and a Map
(or Properties
) object is specified, it looks in the specified
object. If two Map
or Properties
objects are supplied, it looks first in the first and if none found
then in the second object.
val
- Value in which to provide string substitutionsprops1
- First property object in which to find substitutionsprops2
- Second property object in which to find substitutionspropsToHide
- Optional collection of property names to hide from the output. If not null, then
all credentials will also be hidden, in addition to properties named in the collection.resolveWithPropertyName
- Flag indicating if property names should also be part of the output, for debugging of
configurations.IllegalArgumentException
- if there were invalid input arguments.public static boolean needsResolution(String string)
string
- String to checktrue
if the input string contains the default start and end delimiters in consecutive
order, otherwise false
.
The default delimiters are "${"and
"}"respectively.
Copyright © 2023 Frank!Framework. All rights reserved.