ns.apache.org/lang">Commons Lang. Thus it supports the same syntax of variable expressions.
The basic idea of this class is that it can maintain a set of primitive {@link Lookup} objects, each of which is identified by a special prefix. Thevariables to be processed have the form ${prefix:name}
. {@code 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 an arbitrary number of default lookup objects, which are used for variables that do not have a prefix or that cannot be resolved by their associated lookup object. When adding default lookup objects their order matters; they are queried in this order, and the first non-null variable value is used.
After an instance has been created it does not contain any {@code Lookup}objects. The current set of lookup objects can be modified using the {@code registerLookup()} and {@code deregisterLookup()} methods. Defaultlookup objects (that are invoked for variables without a prefix) can be added or removed with the {@code addDefaultLookup()} and{@code removeDefaultLookup()} methods respectively. (When a{@code ConfigurationInterpolator} instance is created by a configurationobject, a default lookup object is added pointing to the configuration itself, so that variables are resolved using the configuration's properties.)
The default usage scenario is that on a fully initialized instance the {@code interpolate()} method is called. It is passed an object value whichmay contain variables. All these variables are substituted if they can be resolved. The result is the passed in value with variables replaced. Alternatively, the {@code resolve()} method can be called to obtain thevalues of specific variables without performing interpolation.
Implementation node: This class is thread-safe. Lookup objects can be added or removed at any time concurrent to interpolation operations.
@version $Id: ConfigurationInterpolator.java 1624601 2014-09-12 18:04:36Z oheger $
@since 1.4
@author
Commons Configuration team