Class InterpolationHelper

java.lang.Object
org.apache.felix.utils.properties.InterpolationHelper

public class InterpolationHelper extends Object

Enhancement of the standard Properties managing the maintain of comments, etc.

  • Field Details

  • Constructor Details

    • InterpolationHelper

      private InterpolationHelper()
  • Method Details

    • performSubstitution

      public static void performSubstitution(Map<String,String> properties)
      Perform substitution on a property set
      Parameters:
      properties - the property set to perform substitution on
    • performSubstitution

      public static void performSubstitution(Map<String,String> properties, org.osgi.framework.BundleContext context)
      Perform substitution on a property set
      Parameters:
      properties - the property set to perform substitution on
      context - The bundle context
    • performSubstitution

      public static void performSubstitution(Map<String,String> properties, InterpolationHelper.SubstitutionCallback callback)
      Perform substitution on a property set
      Parameters:
      properties - the property set to perform substitution on
      callback - Callback for substituion
    • performSubstitution

      public static void performSubstitution(Map<String,String> properties, InterpolationHelper.SubstitutionCallback callback, boolean substituteFromConfig, boolean substituteFromSystemProperties, boolean defaultsToEmptyString)
      Perform substitution on a property set
      Parameters:
      properties - the property set to perform substitution on
      callback - the callback to obtain substitution values
      substituteFromConfig - If substitute from configuration
      substituteFromSystemProperties - If substitute from system properties
      defaultsToEmptyString - sets an empty string if a replacement value is not found, leaves intact otherwise
    • substVars

      public static String substVars(String val, String currentKey, Map<String,String> cycleMap, Map<String,String> configProps) throws IllegalArgumentException

      This method performs property variable substitution on the specified value. If the specified value contains the syntax ${<prop-name>}, where <prop-name> refers to either a configuration property or a system property, then the corresponding property value is substituted for the variable placeholder. Multiple variable placeholders may exist in the specified value as well as nested variable placeholders, which are substituted from inner most to outer most. Configuration properties override system properties.

      Parameters:
      val - The string on which to perform property substitution.
      currentKey - The key of the property being evaluated used to detect cycles.
      cycleMap - Map of variable references used to detect nested cycles.
      configProps - Set of configuration properties.
      Returns:
      The value of the specified string after system property substitution.
      Throws:
      IllegalArgumentException - If there was a syntax error in the property placeholder syntax or a recursive variable reference.
    • substVars

      public static String substVars(String val, String currentKey, Map<String,String> cycleMap, Map<String,String> configProps, org.osgi.framework.BundleContext context) throws IllegalArgumentException

      This method performs property variable substitution on the specified value. If the specified value contains the syntax ${<prop-name>}, where <prop-name> refers to either a configuration property or a system property, then the corresponding property value is substituted for the variable placeholder. Multiple variable placeholders may exist in the specified value as well as nested variable placeholders, which are substituted from inner most to outer most. Configuration properties override system properties.

      Parameters:
      val - The string on which to perform property substitution.
      currentKey - The key of the property being evaluated used to detect cycles.
      cycleMap - Map of variable references used to detect nested cycles.
      configProps - Set of configuration properties.
      context - the bundle context to retrieve properties from
      Returns:
      The value of the specified string after system property substitution.
      Throws:
      IllegalArgumentException - If there was a syntax error in the property placeholder syntax or a recursive variable reference.
    • substVars

      public static String substVars(String val, String currentKey, Map<String,String> cycleMap, Map<String,String> configProps, InterpolationHelper.SubstitutionCallback callback) throws IllegalArgumentException

      This method performs property variable substitution on the specified value. If the specified value contains the syntax ${<prop-name>}, where <prop-name> refers to either a configuration property or a system property, then the corresponding property value is substituted for the variable placeholder. Multiple variable placeholders may exist in the specified value as well as nested variable placeholders, which are substituted from inner most to outer most. Configuration properties override system properties.

      Parameters:
      val - The string on which to perform property substitution.
      currentKey - The key of the property being evaluated used to detect cycles.
      cycleMap - Map of variable references used to detect nested cycles.
      configProps - Set of configuration properties.
      callback - the callback to obtain substitution values
      Returns:
      The value of the specified string after system property substitution.
      Throws:
      IllegalArgumentException - If there was a syntax error in the property placeholder syntax or a recursive variable reference.
    • substVars

      public static String substVars(String val, String currentKey, Map<String,String> cycleMap, Map<String,String> configProps, InterpolationHelper.SubstitutionCallback callback, boolean substituteFromConfig, boolean substituteFromSystemProperties, boolean defaultsToEmptyString) throws IllegalArgumentException

      This method performs property variable substitution on the specified value. If the specified value contains the syntax ${<prop-name>}, where <prop-name> refers to either a configuration property or a system property, then the corresponding property value is substituted for the variable placeholder. Multiple variable placeholders may exist in the specified value as well as nested variable placeholders, which are substituted from inner most to outer most. Configuration properties override system properties.

      Parameters:
      val - The string on which to perform property substitution.
      currentKey - The key of the property being evaluated used to detect cycles.
      cycleMap - Map of variable references used to detect nested cycles.
      configProps - Set of configuration properties.
      callback - the callback to obtain substitution values
      substituteFromConfig - If substitute from configuration
      substituteFromSystemProperties - If substitute from system properties
      defaultsToEmptyString - sets an empty string if a replacement value is not found, leaves intact otherwise
      Returns:
      The value of the specified string after system property substitution.
      Throws:
      IllegalArgumentException - If there was a syntax error in the property placeholder syntax or a recursive variable reference.
    • doSubstVars

      private static String doSubstVars(String val, String currentKey, Map<String,String> cycleMap, Map<String,String> configProps, InterpolationHelper.SubstitutionCallback callback, boolean substituteFromConfig, boolean substituteFromSystemProperties, boolean defaultsToEmptyString) throws IllegalArgumentException
      Throws:
      IllegalArgumentException
    • unescape

      private static String unescape(String val)