Class StringResolver

java.lang.Object
org.frankframework.util.StringResolver

public class StringResolver extends Object
Provide functionality to resolve ${property.key} to the value of the map/property key. If Maps passed to the various substitution methods are instances of PropertyLoader or a subclass thereof, the string value substitution will be done recursively.

Implementations of AdditionalStringResolver that are loaded via the Java ServiceLoader mechanism can provide additional sources or operations for string evaluation.

If the module credentialProvider is available on the classpath then credential properties will be resolved.

If the module script-property-substitution is available on the classpath then embedded JEXL expressions will also be evaluated. See EmbeddedScriptEvaluation for more information.

Author:
Johan Verrips
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    Check if the input string needs property substitution applied.
    static String
    substVars(String val, Map<?,?> props)
    Do variable substitution on a string to resolve ${test.xx} to the value of the property test.xx.
    static String
    substVars(String val, Map<?,?> props, boolean resolveWithPropertyName)
    Do variable substitution on a string to resolve ${test.xx} to the value of the property test.xx.
    static String
    substVars(String val, Map<?,?> props1, Map<?,?> props2)
    Do variable substitution on a string to resolve ${test.xx} to the value of the property test.xx.
    static String
    substVars(String val, Map<?,?> props1, Map<?,?> props2, boolean resolveWithPropertyName)
    Do variable substitution on a string to resolve ${test.xx} to the value of the property test.xx.
    static String
    substVars(String val, Map<?,?> props1, Map<?,?> props2, Set<String> propsToHide)
    Do variable substitution on a string to resolve ${test.xx} to the value of the property test.xx.
    static String
    substVars(String val, Map<?,?> props1, Map<?,?> props2, Set<String> propsToHide, boolean resolveWithPropertyName)
    Do variable substitution on a string to resolve ${test.xx} to the value of the property test.xx.
    static String
    substVars(String val, Map<?,?> props1, Map<?,?> props2, Set<String> propsToHide, String delimStart, String delimStop)
    Do variable substitution on a string to resolve ${test.xx} to the value of the property test.xx.
    static String
    substVars(String val, Map<?,?> props1, Map<?,?> props2, Set<String> propsToHide, String delimStart, String delimStop, boolean resolveWithPropertyName)
    Do variable substitution on a string to resolve ${test.xx} to the value of the property test.xx.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • substVars

      public static String substVars(String val, Map<?,?> props1, Map<?,?> props2, Set<String> propsToHide) throws IllegalArgumentException
      Do variable substitution on a string to resolve ${test.xx} to the value of the property test.xx. When provided Map implementations are instance of PropertyLoader or a subclass thereof, this is done recursively so that
      
       PropertyLoader prop = new PropertyLoader(propFileRef);
       prop.put("test.name", "this is a name with ${test.xx}");
       prop.put("test.xx", "${text.x}");
       prop.put("test.x", "again");
       System.out.println(prop.get("test.name"));
       
      will print this is a name with again

      First it looks in the System environment and System properties, if none is found then all installed AdditionalStringResolvers are scanned for providing a replacement. If no replacement is found still and a Map (or Properties) object is specified, it looks in the specified object. If two Map or Properties objects are supplied, it looks first in the first and if none found then in the second object.

      Parameters:
      val - Value in which to provide string substitutions
      props1 - First property object in which to find substitutions
      props2 - Second property object in which to find substitutions
      propsToHide - Optional collection of property names to hide from the output. If not null, then all credentials will also be hidden, in addition to properties named in the collection.
      Returns:
      Input string with all property reference patterns resolved to either a property value, or empty.
      Throws:
      IllegalArgumentException - if there were invalid input arguments.
    • substVars

      public static String substVars(String val, Map<?,?> props1, Map<?,?> props2, Set<String> propsToHide, String delimStart, String delimStop) throws IllegalArgumentException
      Do variable substitution on a string to resolve ${test.xx} to the value of the property test.xx. When provided Map implementations are instance of PropertyLoader or a subclass thereof, this is done recursively so that
      
       PropertyLoader prop = new PropertyLoader(propFileRef);
       prop.put("test.name", "this is a name with ${test.xx}");
       prop.put("test.xx", "${text.x}");
       prop.put("test.x", "again");
       System.out.println(prop.get("test.name"));
       
      will print this is a name with again

      First it looks in the System environment and System properties, if none is found then all installed AdditionalStringResolvers are scanned for providing a replacement. If no replacement is found still and a Map (or Properties) object is specified, it looks in the specified object. If two Map or Properties objects are supplied, it looks first in the first and if none found then in the second object.

      Parameters:
      val - Value in which to provide string substitutions
      props1 - First property object in which to find substitutions
      props2 - Second property object in which to find substitutions
      propsToHide - Optional collection of property names to hide from the output. If not null, then all credentials will also be hidden, in addition to properties named in the collection.
      delimStart - Start of substitution pattern delimiter
      delimStop - End of substitution pattern delimiter
      Returns:
      Input string with all property reference patterns resolved to either a property value, or empty.
      Throws:
      IllegalArgumentException - if there were invalid input arguments.
    • substVars

      public static String substVars(String val, Map<?,?> props1, Map<?,?> props2, Set<String> propsToHide, String delimStart, String delimStop, boolean resolveWithPropertyName) throws IllegalArgumentException
      Do variable substitution on a string to resolve ${test.xx} to the value of the property test.xx. When provided Map implementations are instance of PropertyLoader or a subclass thereof, this is done recursively so that
      
       PropertyLoader prop = new PropertyLoader(propFileRef);
       prop.put("test.name", "this is a name with ${test.xx}");
       prop.put("test.xx", "${text.x}");
       prop.put("test.x", "again");
       System.out.println(prop.get("test.name"));
       
      will print this is a name with again

      First it looks in the System environment and System properties, if none is found then all installed AdditionalStringResolvers are scanned for providing a replacement. If no replacement is found still and a Map (or Properties) object is specified, it looks in the specified object. If two Map or Properties objects are supplied, it looks first in the first and if none found then in the second object.

      Parameters:
      val - Value in which to provide string substitutions
      props1 - First property object in which to find substitutions
      props2 - Second property object in which to find substitutions
      propsToHide - Optional collection of property names to hide from the output. If not null, then all credentials will also be hidden, in addition to properties named in the collection.
      delimStart - Start of substitution pattern delimiter
      delimStop - End of substitution pattern delimiter
      resolveWithPropertyName - Flag indicating if property names should also be part of the output, for debugging of configurations.
      Returns:
      Input string with all property reference patterns resolved to either a property value, or empty.
      Throws:
      IllegalArgumentException - if there were invalid input arguments.
    • substVars

      public static String substVars(String val, Map<?,?> props1, Map<?,?> props2) throws IllegalArgumentException
      Do variable substitution on a string to resolve ${test.xx} to the value of the property test.xx. When provided Map implementations are instance of PropertyLoader or a subclass thereof, this is done recursively so that
      
       PropertyLoader prop = new PropertyLoader(propFileRef);
       prop.put("test.name", "this is a name with ${test.xx}");
       prop.put("test.xx", "${text.x}");
       prop.put("test.x", "again");
       System.out.println(prop.get("test.name"));
       
      will print this is a name with again

      First it looks in the System environment and System properties, if none is found then all installed AdditionalStringResolvers are scanned for providing a replacement. If no replacement is found still and a Map (or Properties) object is specified, it looks in the specified object. If two Map or Properties objects are supplied, it looks first in the first and if none found then in the second object.

      Parameters:
      val - Value in which to provide string substitutions
      props1 - First property object in which to find substitutions
      props2 - Second property object in which to find substitutions
      Returns:
      Input string with all property reference patterns resolved to either a property value, or empty.
      Throws:
      IllegalArgumentException - if there were invalid input arguments.
    • substVars

      public static String substVars(String val, Map<?,?> props) throws IllegalArgumentException
      Do variable substitution on a string to resolve ${test.xx} to the value of the property test.xx. When provided Map implementations are instance of PropertyLoader or a subclass thereof, this is done recursively so that
      
       PropertyLoader prop = new PropertyLoader(propFileRef);
       prop.put("test.name", "this is a name with ${test.xx}");
       prop.put("test.xx", "${text.x}");
       prop.put("test.x", "again");
       System.out.println(prop.get("test.name"));
       
      will print this is a name with again

      First it looks in the System environment and System properties, if none is found then all installed AdditionalStringResolvers are scanned for providing a replacement. If no replacement is found still and a Map (or Properties) object is specified, it looks in the specified object.

      Parameters:
      val - Value in which to provide string substitutions
      props - Property object in which to find substitutions
      Returns:
      Input string with all property reference patterns resolved to either a property value, or empty.
      Throws:
      IllegalArgumentException - if there were invalid input arguments.
    • substVars

      public static String substVars(String val, Map<?,?> props, boolean resolveWithPropertyName)
      Do variable substitution on a string to resolve ${test.xx} to the value of the property test.xx. When provided Map implementations are instance of PropertyLoader or a subclass thereof, this is done recursively so that
      
       PropertyLoader prop = new PropertyLoader(propFileRef);
       prop.put("test.name", "this is a name with ${test.xx}");
       prop.put("test.xx", "${text.x}");
       prop.put("test.x", "again");
       System.out.println(prop.get("test.name"));
       
      will print this is a name with again

      First it looks in the System environment and System properties, if none is found then all installed AdditionalStringResolvers are scanned for providing a replacement. If no replacement is found still and a Map (or Properties) object is specified, it looks in the specified object.

      Parameters:
      val - Value in which to provide string substitutions
      props - Property object in which to find substitutions
      resolveWithPropertyName - Flag indicating if property names should also be part of the output, for debugging of configurations.
      Returns:
      Input string with all property reference patterns resolved to either a property value, or empty.
      Throws:
      IllegalArgumentException - if there were invalid input arguments.
    • substVars

      public static String substVars(String val, Map<?,?> props1, Map<?,?> props2, boolean resolveWithPropertyName) throws IllegalArgumentException
      Do variable substitution on a string to resolve ${test.xx} to the value of the property test.xx. When provided Map implementations are instance of PropertyLoader or a subclass thereof, this is done recursively so that
      
       PropertyLoader prop = new PropertyLoader(propFileRef);
       prop.put("test.name", "this is a name with ${test.xx}");
       prop.put("test.xx", "${text.x}");
       prop.put("test.x", "again");
       System.out.println(prop.get("test.name"));
       
      will print this is a name with again

      First it looks in the System environment and System properties, if none is found then all installed AdditionalStringResolvers are scanned for providing a replacement. If no replacement is found still and a Map (or Properties) object is specified, it looks in the specified object. If two Map or Properties objects are supplied, it looks first in the first and if none found then in the second object.

      Parameters:
      val - Value in which to provide string substitutions
      props1 - First property object in which to find substitutions
      props2 - Second property object in which to find substitutions
      resolveWithPropertyName - Flag indicating if property names should also be part of the output, for debugging of configurations.
      Returns:
      Input string with all property reference patterns resolved to either a property value, or empty.
      Throws:
      IllegalArgumentException - if there were invalid input arguments.
    • substVars

      public static String substVars(String val, Map<?,?> props1, Map<?,?> props2, Set<String> propsToHide, boolean resolveWithPropertyName) throws IllegalArgumentException
      Do variable substitution on a string to resolve ${test.xx} to the value of the property test.xx. When provided Map implementations are instance of PropertyLoader or a subclass thereof, this is done recursively so that
      
       PropertyLoader prop = new PropertyLoader(propFileRef);
       prop.put("test.name", "this is a name with ${test.xx}");
       prop.put("test.xx", "${text.x}");
       prop.put("test.x", "again");
       System.out.println(prop.get("test.name"));
       
      will print this is a name with again

      First it looks in the System environment and System properties, if none is found then all installed AdditionalStringResolvers are scanned for providing a replacement. If no replacement is found still and a Map (or Properties) object is specified, it looks in the specified object. If two Map or Properties objects are supplied, it looks first in the first and if none found then in the second object.

      Parameters:
      val - Value in which to provide string substitutions
      props1 - First property object in which to find substitutions
      props2 - Second property object in which to find substitutions
      propsToHide - Optional collection of property names to hide from the output. If not null, then all credentials will also be hidden, in addition to properties named in the collection.
      resolveWithPropertyName - Flag indicating if property names should also be part of the output, for debugging of configurations.
      Returns:
      Input string with all property reference patterns resolved to either a property value, or empty.
      Throws:
      IllegalArgumentException - if there were invalid input arguments.
    • needsResolution

      public static boolean needsResolution(String string)
      Check if the input string needs property substitution applied.
      Parameters:
      string - String to check
      Returns:
      true if the input string contains the default start and end delimiters in consecutive order, otherwise false. The default delimiters are
      "${"
      and
      "}"
      respectively.