Class PropertyExpressionResolver

java.lang.Object
com.zfabrik.util.PropertyExpressionResolver

public class PropertyExpressionResolver extends Object
The PropertyExpressionResolver class provides the functionality to resolve expressions in properties. An expression is any character sequence enclosed with ${ and }; all characters including space, umlauts, punctuation chars but except '}' are allowed. Expressions are resolved by replacing all ${key} sequences by the result of calling getProperty(key) on the input-properties object. One can escape the an expression by $${ which will be replaced by ${. The PropertyExpressionResolver is created using either one Properties object or two. In the first case the method resolveAll() resolves all property-expressions and stores the result in the same object and replaces the original expressions. In the second case the first Properties object hosts the expressions and is unchanged while the results are stored in the second Properties object.
  • Constructor Details

    • PropertyExpressionResolver

      public PropertyExpressionResolver(Properties p_in, Properties p_out)
      Constructs a new PropertyExpressionResolver object for the given Properties p_in. Calling resolveAll() will store all resolved property expressions in p_out.
      Parameters:
      p_in - input-properties: Properties object containing the expressions
      p_out - output-properties: Properties object which will contain the resolved expressions
    • PropertyExpressionResolver

      public PropertyExpressionResolver(Properties p_in_out)
      Constructs a new PropertyExpressionResolver object for the given Properties. Calling resolveAll() will replace all properties in p_in_out by the resolved versions.
      Parameters:
      p_in_out - Properties object containing the expressions which will be replaced by the resolved versions
  • Method Details

    • resolveAll

      public Properties resolveAll()
      Resolves all property-expressions provided by the input-properties object and stores the result into the output-properties.
      Returns:
      the same Properties object as provided as output-properties to the constructor.
    • resolveExpr

      public String resolveExpr(String p_expr)
      Resolves the given expression string using the input-properties object
      Parameters:
      p_expr - string which may contain expressions
      Returns:
      string where all expressions are resolved
    • resolveKey

      public String resolveKey(String key)
      Looks up the given key in the input-properties object and resolves the value using the input-properties object
      Parameters:
      key - property key in the input-properties object
      Returns:
      string where all expressions are resolved