Class InterpolationUtil


  • public final class InterpolationUtil
    extends java.lang.Object
    Author:
    Jeremy Long
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  InterpolationUtil.SyntaxStyle
      The syntax style for the interpolation.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String interpolate​(java.lang.String text, java.util.Properties properties)
      A utility function that will interpolate strings based on values given in the properties file.
      static java.lang.String interpolate​(java.lang.String text, java.util.Properties properties, InterpolationUtil.SyntaxStyle style)
      A utility function that will interpolate strings based on values given in the properties file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • interpolate

        public static java.lang.String interpolate​(java.lang.String text,
                                                   java.util.Properties properties)

        A utility function that will interpolate strings based on values given in the properties file. It will also interpolate the strings contained within the properties file so that properties can reference other properties.

        Note: if there is no property found the reference will be removed. In other words, if the interpolated string will be replaced with an empty string.

        Example:

        Properties p = new Properties(); p.setProperty("key", "value"); String s = interpolateString("'${key}' and '${nothing}'", p); System.out.println(s);

        Will result in:

        'value' and ''
        Parameters:
        text - the string that contains references to properties.
        properties - a collection of properties that may be referenced within the text.
        Returns:
        the interpolated text.
      • interpolate

        public static java.lang.String interpolate​(java.lang.String text,
                                                   java.util.Properties properties,
                                                   InterpolationUtil.SyntaxStyle style)

        A utility function that will interpolate strings based on values given in the properties file. It will also interpolate the strings contained within the properties file so that properties can reference other properties.

        Note: if there is no property found the reference will be removed. In other words, if the interpolated string will be replaced with an empty string.

        Example:

        Properties p = new Properties(); p.setProperty("key", "value"); String s = interpolateString("'${key}' and '${nothing}'", p); System.out.println(s);

        Will result in:

        'value' and ''
        Parameters:
        text - the string that contains references to properties.
        properties - a collection of properties that may be referenced within the text.
        style - the syntax style for the interpolation (MSBuild; "$(var)", Default "${var}")"
        Returns:
        the interpolated text.