Class DefaultInterpolator

java.lang.Object
org.apache.maven.internal.impl.model.DefaultInterpolator
All Implemented Interfaces:
Service, Interpolator

@Named @Singleton public class DefaultInterpolator extends Object implements Interpolator
  • Constructor Details

    • DefaultInterpolator

      public DefaultInterpolator()
  • Method Details

    • interpolate

      public void interpolate(Map<String,String> map, Function<String,String> callback, BiFunction<String,String,String> postprocessor, boolean defaultsToEmpty)
      Specified by:
      interpolate in interface Interpolator
    • interpolate

      public String interpolate(String val, Function<String,String> callback, BiFunction<String,String,String> postprocessor, boolean defaultsToEmpty)
      Specified by:
      interpolate in interface Interpolator
    • interpolate

      @Nullable public String interpolate(@Nullable String val, @Nullable String currentKey, @Nullable Set<String> cycleMap, @Nullable Function<String,String> callback, @Nullable BiFunction<String,String,String> postprocessor, boolean defaultsToEmpty)
    • performSubstitution

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

      public void performSubstitution(Map<String,String> properties, Function<String,String> callback, boolean defaultsToEmptyString)
      Perform substitution on a property set
      Parameters:
      properties - the property set to perform substitution on
      callback - the callback to obtain substitution values
      defaultsToEmptyString - sets an empty string if a replacement value is not found, leaves intact otherwise
    • substVars

      public String substVars(String val, String currentKey, Set<String> cycleMap, Map<String,String> configProps)

      This method performs property variable substitution on the specified value. If the specified value contains the syntax ${&lt;prop-name&gt;}, where &lt;prop-name&gt; 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:
      InterpolatorException - If there was a syntax error in the property placeholder syntax or a recursive variable reference.
    • substVars

      public String substVars(String val, String currentKey, Set<String> cycleMap, Map<String,String> configProps, Function<String,String> callback)

      This method performs property variable substitution on the specified value. If the specified value contains the syntax ${&lt;prop-name&gt;}, where &lt;prop-name&gt; 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:
      InterpolatorException - 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, Set<String> cycleMap, Map<String,String> configProps, Function<String,String> callback, BiFunction<String,String,String> postprocessor, boolean defaultsToEmptyString)

      This method performs property variable substitution on the specified value. If the specified value contains the syntax ${&lt;prop-name&gt;}, where &lt;prop-name&gt; 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
      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.
    • escape

      @Nullable public static String escape(@Nullable String val)
      Escapes special characters in the given string to prevent unwanted interpolation.
      Parameters:
      val - The string to be escaped.
      Returns:
      The escaped string.
    • unescape

      @Nullable public static String unescape(@Nullable String val)
      Unescapes previously escaped characters in the given string.
      Parameters:
      val - The string to be unescaped.
      Returns:
      The unescaped string.