Class StringResolver
- Author:
- Johan Verrips
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
needsResolution
(String string) Check if the input string needs property substitution applied.static String
Do variable substitution on a string to resolve ${x2} to the value of the property x2.static String
Do variable substitution on a string to resolve ${x2} to the value of the property x2.static String
Do variable substitution on a string to resolve ${x2} to the value of the property x2.static String
Do variable substitution on a string to resolve ${x2} to the value of the property x2.static String
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.
-
Field Details
-
DELIM_START
- See Also:
-
DELIM_STOP
- See Also:
-
-
Constructor Details
-
StringResolver
public StringResolver()
-
-
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 ${x2} to the value of the property x2. This is done recursive, so that
will printProperties 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"));
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 aMap
(orProperties
) object is specified, it looks in the specified object. If twoMap
orProperties
objects 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 ${x2} to the value of the property x2. This is done recursive, so that
will printProperties 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"));
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 aMap
(orProperties
) object is specified, it looks in the specified object. If twoMap
orProperties
objects 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 ${x2} to the value of the property x2. This is done recursive, so that
will printProperties 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"));
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 aMap
(orProperties
) object is specified, it looks in the specified object. If twoMap
orProperties
objects 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 ${x2} to the value of the property x2. This is done recursive, so that
will printProperties 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"));
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 aMap
(orProperties
) object is specified, it looks in the specified object. If twoMap
orProperties
objects 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 ${x2} to the value of the property x2. This is done recursive, so that
will printProperties 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"));
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 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 ${x2} to the value of the property x2. This is done recursive, so that
will printProperties 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"));
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 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 ${x2} to the value of the property x2. This is done recursive, so that
will printProperties 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"));
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 aMap
(orProperties
) object is specified, it looks in the specified object. If twoMap
orProperties
objects 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 ${x2} to the value of the property x2. This is done recursive, so that
will printProperties 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"));
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 aMap
(orProperties
) object is specified, it looks in the specified object. If twoMap
orProperties
objects 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:
true
if the input string contains the default start and end delimiters in consecutive order, otherwisefalse
. The default delimiters are"${"
and"}"
respectively.
-