Class 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 Detail

      • DEFAULT_ESCAPE

        public static final char DEFAULT_ESCAPE
        Default escape character to override the default escape character of StringSubstitutor, '$'. '\\' 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 replace
        variablePrefix - 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 configuration
        text - text to replace
        variablePrefix - 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 given StringLookup.
        Parameters:
        strLookup - string lookup
        text - text to replace
        variablePrefix - 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