Class InterpolationUtil

java.lang.Object
org.owasp.dependencycheck.utils.InterpolationUtil

public final class InterpolationUtil extends Object
Author:
Jeremy Long
  • Method Details

    • interpolate

      public static String interpolate(String text, 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 String interpolate(String text, 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.