The basic idea of this class is that it can maintain a set of primitive {@code StrLookup} objects, each of which is identified by a specialprefix. The variables to be processed have the form ${prefix:name}
. {@code ConfigurationInterpolator} willextract 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 {@code registerGlobalLookup()} and{@code 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 {@code const} prefix indicates that a variable is to beinterpreted 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 {@code |
After an instance has been created the current set of lookup objects can be modified using the {@code registerLookup()} and{@code deregisterLookup()} methods. The default lookup object (that isinvoked for variables without a prefix) can be set with the {@code setDefaultLookup()} method. (If a{@code ConfigurationInterpolator} instance is created by aconfiguration 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 {@code Configuration} object and used for its interpolation tasks.
@version $Id: ConfigurationInterpolator.java 1295276 2012-02-29 21:11:35Z oheger $ @since 1.4 @author
|
|