Class StringResolver
PropertyLoader or a subclass thereof, the string value substitution will be done recursively.
Implementations of AdditionalStringResolver that are loaded via the Java ServiceLoader mechanism can provide additional
sources or operations for string evaluation.
If the module credentialProvider is available on the classpath then credential properties will be resolved.
If the module script-property-substitution is available on the classpath then embedded JEXL expressions will also be evaluated.
See EmbeddedScriptEvaluation for more information.
- Author:
- Johan Verrips
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanneedsResolution(String string) Check if the input string needs property substitution applied.static StringDo variable substitution on a string to resolve ${test.xx} to the value of the propertytest.xx.static StringDo variable substitution on a string to resolve ${test.xx} to the value of the propertytest.xx.static StringDo variable substitution on a string to resolve ${test.xx} to the value of the propertytest.xx.static StringDo variable substitution on a string to resolve ${test.xx} to the value of the propertytest.xx.static StringDo variable substitution on a string to resolve ${test.xx} to the value of the propertytest.xx.static StringsubstVars(String val, Map<?, ?> props1, Map<?, ?> props2, Set<String> propsToHide, boolean resolveWithPropertyName) Do variable substitution on a string to resolve ${test.xx} to the value of the propertytest.xx.static StringsubstVars(String val, Map<?, ?> props1, Map<?, ?> props2, Set<String> propsToHide, String delimStart, String delimStop) Do variable substitution on a string to resolve ${test.xx} to the value of the propertytest.xx.static StringsubstVars(String val, Map<?, ?> props1, Map<?, ?> props2, Set<String> propsToHide, String delimStart, String delimStop, boolean resolveWithPropertyName) Do variable substitution on a string to resolve ${test.xx} to the value of the propertytest.xx.
-
Field Details
-
DELIM_START
- See Also:
-
DELIM_STOP
- See Also:
-
-
Method Details
-
substVars
public static String substVars(String val, Map<?, ?> props1, Map<?, throws IllegalArgumentException?> props2, Set<String> propsToHide) Do variable substitution on a string to resolve ${test.xx} to the value of the propertytest.xx. When provided Map implementations are instance ofPropertyLoaderor a subclass thereof, this is done recursively so that
will printPropertyLoader prop = new PropertyLoader(propFileRef); prop.put("test.name", "this is a name with ${test.xx}"); prop.put("test.xx", "${text.x}"); prop.put("test.x", "again"); System.out.println(prop.get("test.name"));this is a name with againFirst it looks in the System environment and System properties, if none is found then all installed
AdditionalStringResolvers are scanned for providing a replacement. If no replacement is found still and aMap(orProperties) object is specified, it looks in the specified object. If twoMaporPropertiesobjects are supplied, it looks first in the first and if none found then in the second object.- Parameters:
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.- Returns:
- Input string with all property reference patterns resolved to either a property value, or empty.
- Throws:
IllegalArgumentException- if there were invalid input arguments.
-
substVars
public static String substVars(String val, Map<?, ?> props1, Map<?, throws IllegalArgumentException?> props2, Set<String> propsToHide, String delimStart, String delimStop) Do variable substitution on a string to resolve ${test.xx} to the value of the propertytest.xx. When provided Map implementations are instance ofPropertyLoaderor a subclass thereof, this is done recursively so that
will printPropertyLoader prop = new PropertyLoader(propFileRef); prop.put("test.name", "this is a name with ${test.xx}"); prop.put("test.xx", "${text.x}"); prop.put("test.x", "again"); System.out.println(prop.get("test.name"));this is a name with againFirst it looks in the System environment and System properties, if none is found then all installed
AdditionalStringResolvers are scanned for providing a replacement. If no replacement is found still and aMap(orProperties) object is specified, it looks in the specified object. If twoMaporPropertiesobjects are supplied, it looks first in the first and if none found then in the second object.- Parameters:
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 delimiter- Returns:
- Input string with all property reference patterns resolved to either a property value, or empty.
- Throws:
IllegalArgumentException- if there were invalid input arguments.
-
substVars
public static String substVars(String val, Map<?, ?> props1, Map<?, throws IllegalArgumentException?> props2, Set<String> propsToHide, String delimStart, String delimStop, boolean resolveWithPropertyName) Do variable substitution on a string to resolve ${test.xx} to the value of the propertytest.xx. When provided Map implementations are instance ofPropertyLoaderor a subclass thereof, this is done recursively so that
will printPropertyLoader prop = new PropertyLoader(propFileRef); prop.put("test.name", "this is a name with ${test.xx}"); prop.put("test.xx", "${text.x}"); prop.put("test.x", "again"); System.out.println(prop.get("test.name"));this is a name with againFirst it looks in the System environment and System properties, if none is found then all installed
AdditionalStringResolvers are scanned for providing a replacement. If no replacement is found still and aMap(orProperties) object is specified, it looks in the specified object. If twoMaporPropertiesobjects are supplied, it looks first in the first and if none found then in the second object.- Parameters:
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.- Returns:
- Input string with all property reference patterns resolved to either a property value, or empty.
- Throws:
IllegalArgumentException- if there were invalid input arguments.
-
substVars
public static String substVars(String val, Map<?, ?> props1, Map<?, throws IllegalArgumentException?> props2) Do variable substitution on a string to resolve ${test.xx} to the value of the propertytest.xx. When provided Map implementations are instance ofPropertyLoaderor a subclass thereof, this is done recursively so that
will printPropertyLoader prop = new PropertyLoader(propFileRef); prop.put("test.name", "this is a name with ${test.xx}"); prop.put("test.xx", "${text.x}"); prop.put("test.x", "again"); System.out.println(prop.get("test.name"));this is a name with againFirst it looks in the System environment and System properties, if none is found then all installed
AdditionalStringResolvers are scanned for providing a replacement. If no replacement is found still and aMap(orProperties) object is specified, it looks in the specified object. If twoMaporPropertiesobjects are supplied, it looks first in the first and if none found then in the second object.- Parameters:
val- Value in which to provide string substitutionsprops1- First property object in which to find substitutionsprops2- Second property object in which to find substitutions- Returns:
- Input string with all property reference patterns resolved to either a property value, or empty.
- Throws:
IllegalArgumentException- if there were invalid input arguments.
-
substVars
Do variable substitution on a string to resolve ${test.xx} to the value of the propertytest.xx. When provided Map implementations are instance ofPropertyLoaderor a subclass thereof, this is done recursively so that
will printPropertyLoader prop = new PropertyLoader(propFileRef); prop.put("test.name", "this is a name with ${test.xx}"); prop.put("test.xx", "${text.x}"); prop.put("test.x", "again"); System.out.println(prop.get("test.name"));this is a name with againFirst it looks in the System environment and System properties, if none is found then all installed
AdditionalStringResolvers are scanned for providing a replacement. If no replacement is found still and aMap(orProperties) object is specified, it looks in the specified object.- Parameters:
val- Value in which to provide string substitutionsprops- Property object in which to find substitutions- Returns:
- Input string with all property reference patterns resolved to either a property value, or empty.
- Throws:
IllegalArgumentException- if there were invalid input arguments.
-
substVars
Do variable substitution on a string to resolve ${test.xx} to the value of the propertytest.xx. When provided Map implementations are instance ofPropertyLoaderor a subclass thereof, this is done recursively so that
will printPropertyLoader prop = new PropertyLoader(propFileRef); prop.put("test.name", "this is a name with ${test.xx}"); prop.put("test.xx", "${text.x}"); prop.put("test.x", "again"); System.out.println(prop.get("test.name"));this is a name with againFirst it looks in the System environment and System properties, if none is found then all installed
AdditionalStringResolvers are scanned for providing a replacement. If no replacement is found still and aMap(orProperties) object is specified, it looks in the specified object.- Parameters:
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.- Returns:
- Input string with all property reference patterns resolved to either a property value, or empty.
- Throws:
IllegalArgumentException- if there were invalid input arguments.
-
substVars
public static String substVars(String val, Map<?, ?> props1, Map<?, throws IllegalArgumentException?> props2, boolean resolveWithPropertyName) Do variable substitution on a string to resolve ${test.xx} to the value of the propertytest.xx. When provided Map implementations are instance ofPropertyLoaderor a subclass thereof, this is done recursively so that
will printPropertyLoader prop = new PropertyLoader(propFileRef); prop.put("test.name", "this is a name with ${test.xx}"); prop.put("test.xx", "${text.x}"); prop.put("test.x", "again"); System.out.println(prop.get("test.name"));this is a name with againFirst it looks in the System environment and System properties, if none is found then all installed
AdditionalStringResolvers are scanned for providing a replacement. If no replacement is found still and aMap(orProperties) object is specified, it looks in the specified object. If twoMaporPropertiesobjects are supplied, it looks first in the first and if none found then in the second object.- Parameters:
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.- Returns:
- Input string with all property reference patterns resolved to either a property value, or empty.
- Throws:
IllegalArgumentException- if there were invalid input arguments.
-
substVars
public static String substVars(String val, Map<?, ?> props1, Map<?, throws IllegalArgumentException?> props2, Set<String> propsToHide, boolean resolveWithPropertyName) Do variable substitution on a string to resolve ${test.xx} to the value of the propertytest.xx. When provided Map implementations are instance ofPropertyLoaderor a subclass thereof, this is done recursively so that
will printPropertyLoader prop = new PropertyLoader(propFileRef); prop.put("test.name", "this is a name with ${test.xx}"); prop.put("test.xx", "${text.x}"); prop.put("test.x", "again"); System.out.println(prop.get("test.name"));this is a name with againFirst it looks in the System environment and System properties, if none is found then all installed
AdditionalStringResolvers are scanned for providing a replacement. If no replacement is found still and aMap(orProperties) object is specified, it looks in the specified object. If twoMaporPropertiesobjects are supplied, it looks first in the first and if none found then in the second object.- Parameters:
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.- Returns:
- Input string with all property reference patterns resolved to either a property value, or empty.
- Throws:
IllegalArgumentException- if there were invalid input arguments.
-
needsResolution
Check if the input string needs property substitution applied.- Parameters:
string- String to check- Returns:
trueif the input string contains the default start and end delimiters in consecutive order, otherwisefalse. The default delimiters are"${"and"}"
respectively.
-