Class TokenResolver

java.lang.Object
com.sun.enterprise.universal.glassfish.TokenResolver

public class TokenResolver extends Object
Here is the contract: You give me a Map<String,String> object. Then you can call resolve(List) and/or resolve(String) and/or resolve(Map<String,String>) 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...
Author:
bnevins
  • Constructor Details

    • TokenResolver

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

      public TokenResolver(Map<String,String> map)
  • Method Details

    • 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)