com.sun.enterprise.universal.glassfish
Class TokenResolver

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

public class TokenResolver
extends java.lang.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...

Author:
bnevins

Constructor Summary
TokenResolver()
          Empty constructor means use System Properties
TokenResolver(java.util.Map<java.lang.String,java.lang.String> map)
           
 
Method Summary
static boolean hasToken(java.lang.String s)
           
 void resolve(java.util.List<java.lang.String> list)
          Replace $[variables} in list with a matching property from the map
 void resolve(java.util.Map<java.lang.String,java.lang.String> map)
          Replace $[variables} in map with a matching property from the map that this instance was constructed with.
 java.lang.String resolve(java.lang.String s)
          Replace $[variables} with a matching property in the map
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TokenResolver

public TokenResolver()
Empty constructor means use System Properties


TokenResolver

public TokenResolver(java.util.Map<java.lang.String,java.lang.String> map)
Method Detail

resolve

public void resolve(java.util.Map<java.lang.String,java.lang.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(java.util.List<java.lang.String> list)
Replace $[variables} in list with a matching property from the map

Parameters:
list - List of Strings to be token-replaced

resolve

public java.lang.String resolve(java.lang.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(java.lang.String s)


Copyright © 2012 GlassFish Community. All Rights Reserved.