Package org.jvnet.hk2.config
Class VariableResolver
java.lang.Object
org.jvnet.hk2.config.VariableResolver
- All Implemented Interfaces:
Translator
Translator that does variable resolution in the Ant style.
This implementation looks for variables in the string like
"${xyz}" or "${abc.DEF.ghi}". The getVariableValue(String) method
is then used to obtain the actual value for the variable.
"$$" works as the escape of "$", so for example "$${abc}" expands to "${abc}" where "${abc}" would have expanded to "value-of-abc". A lone "$" is left as-is, so "$abc" expands to "$abc".
- Author:
- Kohsuke Kawaguchi
-
Field Summary
Fields inherited from interface org.jvnet.hk2.config.Translator
NOOP, SYS_PROP_TR -
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
VariableResolver
public VariableResolver()
-
-
Method Details
-
translate
- Specified by:
translatein interfaceTranslator- Throws:
TranslationException
-
getVariableValue
Returns the value of the variable. This class will not try to further expand variables in the returned value. If the implementation wants to do so, that is the implementation's responsibility.- Returns:
- null if the variable is not found. The caller will report an error.
When the variable is not found, it's also legal to throw
TranslationException, which is an useful technique if the implementation would like to report additional errors. - Throws:
TranslationException
-