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 property key, recursively.
Author:
Johan Verrips
  • Field Summary

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

    Constructors
    Constructor
    Description
     
  • 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 ${x2} to the value of the property x2.
    static String
    substVars(String val, Map<?,?> props, boolean resolveWithPropertyName)
    Do variable substitution on a string to resolve ${x2} to the value of the property x2.
    static String
    substVars(String val, Map<?,?> props1, Map<?,?> props2)
    Do variable substitution on a string to resolve ${x2} to the value of the property x2.
    static String
    substVars(String val, Map<?,?> props1, Map<?,?> props2, boolean resolveWithPropertyName)
    Do variable substitution on a string to resolve ${x2} to the value of the property x2.
    static String
    substVars(String val, Map<?,?> props1, Map<?,?> props2, Set<String> propsToHide)
    Do variable substitution on a string to resolve ${x2} to the value of the property x2.
    static String
    substVars(String val, Map<?,?> props1, Map<?,?> props2, Set<String> propsToHide, boolean resolveWithPropertyName)
    Do variable substitution on a string to resolve ${x2} to the value of the property x2.
    static String
    substVars(String val, Map<?,?> props1, Map<?,?> props2, Set<String> propsToHide, String delimStart, String delimStop)
    Do variable substitution on a string to resolve ${x2} to the value of the property x2.
    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 ${x2} to the value of the property x2.

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • StringResolver

      public StringResolver()
  • 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 ${x2} to the value of the property x2. This is done recursive, so that
      
       Properties prop = new Properties();
       prop.put("test.name", "this is a name with ${test.xx}");
       prop.put("test.xx", "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 ${x2} to the value of the property x2. This is done recursive, so that
      
       Properties prop = new Properties();
       prop.put("test.name", "this is a name with ${test.xx}");
       prop.put("test.xx", "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 ${x2} to the value of the property x2. This is done recursive, so that
      
       Properties prop = new Properties();
       prop.put("test.name", "this is a name with ${test.xx}");
       prop.put("test.xx", "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 ${x2} to the value of the property x2. This is done recursive, so that
      
       Properties prop = new Properties();
       prop.put("test.name", "this is a name with ${test.xx}");
       prop.put("test.xx", "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 ${x2} to the value of the property x2. This is done recursive, so that
      
       Properties prop = new Properties();
       prop.put("test.name", "this is a name with ${test.xx}");
       prop.put("test.xx", "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 ${x2} to the value of the property x2. This is done recursive, so that
      
       Properties prop = new Properties();
       prop.put("test.name", "this is a name with ${test.xx}");
       prop.put("test.xx", "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 ${x2} to the value of the property x2. This is done recursive, so that
      
       Properties prop = new Properties();
       prop.put("test.name", "this is a name with ${test.xx}");
       prop.put("test.xx", "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 ${x2} to the value of the property x2. This is done recursive, so that
      
       Properties prop = new Properties();
       prop.put("test.name", "this is a name with ${test.xx}");
       prop.put("test.xx", "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.