Package org.hippoecm.frontend.util
Class InterpolationUtils
- java.lang.Object
-
- org.hippoecm.frontend.util.InterpolationUtils
-
public class InterpolationUtils extends Object
Variable interpolation utility, replacing a text with variable references by resolved values.This utility class provides features to replace texts containing variables by looking up values from the platform
ContainerConfiguration
.
-
-
Field Summary
Fields Modifier and Type Field Description static char
DEFAULT_ESCAPE
Default escape character to override the default escape character ofStringSubstitutor
, '$'.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
interpolate(String text)
Replaces the given text by looking up values from the platform configuration.static String
interpolate(String text, String variablePrefix, String variableSuffix, Character escapeChar)
Replaces the given text by looking up values from the platform configuration.static String
interpolate(org.apache.commons.text.lookup.StringLookup strLookup, String text, String variablePrefix, String variableSuffix, Character escapeChar)
Replaces the given text by looking up values from the givenStringLookup
.static String
interpolate(ContainerConfiguration containerConfiguration, String text, String variablePrefix, String variableSuffix, Character escapeChar)
Replaces the given text by looking up values from the given container configuration.
-
-
-
Field Detail
-
DEFAULT_ESCAPE
public static final char DEFAULT_ESCAPE
Default escape character to override the default escape character ofStringSubstitutor
, '$'. '\\' is more user friendly than '$' in most use cases.- See Also:
- Constant Field Values
-
-
Method Detail
-
interpolate
public static String interpolate(String text)
Replaces the given text by looking up values from the platform configuration. It uses the variable prefix"${"
. it uses the variable suffix"}"
. The escape sequence//
can be used before a variable reference to ignore the expression.- Parameters:
text
- text to replace- Returns:
- replaced string by the values found in the given resource bundle
-
interpolate
public static String interpolate(String text, String variablePrefix, String variableSuffix, Character escapeChar)
Replaces the given text by looking up values from the platform configuration.- Parameters:
text
- text to replacevariablePrefix
- variable reference prefix. "${" by default.variableSuffix
- variable reference suffix. "}" by default.escapeChar
- escape character which can be put just before a variable reference to ignore the expression.- Returns:
- replaced string by the values found in the given resource bundle
-
interpolate
public static String interpolate(ContainerConfiguration containerConfiguration, String text, String variablePrefix, String variableSuffix, Character escapeChar)
Replaces the given text by looking up values from the given container configuration.- Parameters:
containerConfiguration
- platform configurationtext
- text to replacevariablePrefix
- variable reference prefix. "${" by default.variableSuffix
- variable reference suffix. "}" by default.escapeChar
- escape character which can be put just before a variable reference to ignore the expression.- Returns:
- replaced string by the values found in the given resource bundle
-
interpolate
public static String interpolate(org.apache.commons.text.lookup.StringLookup strLookup, String text, String variablePrefix, String variableSuffix, Character escapeChar)
Replaces the given text by looking up values from the givenStringLookup
.- Parameters:
strLookup
- string lookuptext
- text to replacevariablePrefix
- variable reference prefix. "${" by default.variableSuffix
- variable reference suffix. "}" by default.escapeChar
- escape character which can be put just before a variable reference to ignore the expression.- Returns:
- replaced string by the values found in the given resource bundle
-
-