Class TokenResolver


  • public class TokenResolver
    extends Object
    Here is the contract: You give me a Map object. Then you can call resolve(List) and/or resolve(String) and/or resolve(Map) I will find and replace the tokens, e.g., ${foo} with the value of "foo" in the properties. If the token has no such property -- then I leave the token as is. It purposely does not handle nested tokens. E.g. if the "foo" property has another token embedded in the value -- it will not be further resolved. This is the KISS principle in action...
    Since:
    April 20, 2007
    Version:
    3
    Author:
    bnevins
    • Constructor Detail

      • TokenResolver

        public TokenResolver()
        Empty constructor means use System Properties
    • Method Detail

      • resolve

        public void resolve​(Map<String,​String> map)
        Replace $[variables} in map with a matching property from the map that this instance was constructed with. Both names and values are replaced.
        Parameters:
        map - Map of Strings to be token-replaced
      • resolve

        public void resolve​(List<String> list)
        Replace $[variables} in list with a matching property from the map
        Parameters:
        list - List of Strings to be token-replaced
      • resolve

        public String resolve​(String s)
        Replace $[variables} with a matching property in the map
        Parameters:
        s - String to be token-replaced
        Returns:
        the replaced String
      • hasToken

        public static boolean hasToken​(String s)