Class VariableExpander


  • public final class VariableExpander
    extends Object
    Variable expander that knows how to expand simple macro expressions of the form "${variableName}". Literal "$" can be escaped via the escape character "\". VariableExpanders are provided a map of macros to values. Values not in the map will not be expanded.
    • Constructor Detail

      • VariableExpander

        public VariableExpander()
        Creates an empty variable expander.
      • VariableExpander

        public VariableExpander​(Map<String,​String> map)
        Creates a variable expander, initialized to the given map.
        Parameters:
        map - the map of variables
      • VariableExpander

        public VariableExpander​(Properties variables)
        Creates a variable expander, initialized to the given properties object.
        Parameters:
        variables - the map of variables
    • Method Detail

      • put

        public void put​(String variable,
                        String value)
        Adds a new variable
        Parameters:
        variable - the variable to add
        value - the value of the variable
      • expand

        public String expand​(String str)
        Expands the macros in the given string.
        Parameters:
        str - the string
        Returns:
        the string with the macros expanded.