Package org.hippoecm.frontend.util
Class InterpolationUtils
java.lang.Object
org.hippoecm.frontend.util.InterpolationUtils
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
Modifier and TypeFieldDescriptionstatic final char
Default escape character to override the default escape character ofStringSubstitutor
, '$'. -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 Details
-
DEFAULT_ESCAPE
public static final char DEFAULT_ESCAPEDefault escape character to override the default escape character ofStringSubstitutor
, '$'. '\\' is more user friendly than '$' in most use cases.- See Also:
-
-
Method Details
-
interpolate
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
-