ns.apache.org/lang">Commons Lang. By extending
StrLookup
it is able to provide values for variables that appear in expressions.
The basic idea of this class is that it can maintain a set of primitive StrLookup
objects, each of which is identified by a special prefix. The variables to be processed have the form ${prefix:name}
. ConfigurationInterpolator
will extract the prefix and determine, which primitive lookup object is registered for it. Then the name of the variable is passed to this object to obtain the actual value. It is also possible to define a default lookup object, which will be used for variables that do not have a prefix or that cannot be resolved by their associated lookup object.
When a new instance of this class is created it is initialized with a default set of primitive lookup objects. This set can be customized using the static methods registerGlobalLookup()
and deregisterGlobalLookup()
. Per default it contains the following standard lookup objects:
Prefix | Lookup object |
sys | With this prefix a lookup object is associated that is able to resolve system properties. |
const | The const prefix indicates that a variable is to be interpreted as a constant member field of a class (i.e. a field with the static final modifiers). The name of the variable must be of the form <full qualified class name>.<field name> , e.g. org.apache.commons.configuration.interpol.ConfigurationInterpolator.PREFIX_CONSTANTS . |
After an instance has been created the current set of lookup objects can be modified using the registerLookup()
and deregisterLookup()
methods. The default lookup object (that is invoked for variables without a prefix) can be set with the setDefaultLookup()
method. (If a ConfigurationInterpolator
instance is created by a configuration object, this lookup points to the configuration itself, so that variables are resolved using the configuration's properties. This ensures backward compatibility to earlier version of Commons Configuration.)
Implementation node: Instances of this class are not thread-safe related to modifications of their current set of registered lookup objects. It is intended that each instance is associated with a single Configuration
object and used for its interpolation tasks.
@version $Id: ConfigurationInterpolator.java 561230 2007-07-31 04:17:09Z rahul $
@since 1.4
@author
Commons Configuration team