Class ConfigurationLookup
- java.lang.Object
-
- org.apache.commons.configuration2.ConfigurationLookup
-
- All Implemented Interfaces:
Lookup
public class ConfigurationLookup extends Object implements Lookup
A specialized implementation of the
Lookup
interface which uses aConfiguration
object to resolve variables.This class is passed an
ImmutableConfiguration
object at construction time. In its implementation of thelookup()
method it simply queries this configuration for the passed in variable name. So the keys passed tolookup()
are mapped directly to configuration properties.- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description ConfigurationLookup(ImmutableConfiguration config)
Creates a new instance ofConfigurationLookup
and sets the associatedImmutableConfiguration
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ImmutableConfiguration
getConfiguration()
Gets theImmutableConfiguration
used by this object.Object
lookup(String variable)
Looks up the value of the specified variable.
-
-
-
Constructor Detail
-
ConfigurationLookup
public ConfigurationLookup(ImmutableConfiguration config)
Creates a new instance ofConfigurationLookup
and sets the associatedImmutableConfiguration
.- Parameters:
config
- the configuration to use for lookups (must not be null)- Throws:
IllegalArgumentException
- if the configuration is null
-
-
Method Detail
-
getConfiguration
public ImmutableConfiguration getConfiguration()
Gets theImmutableConfiguration
used by this object.- Returns:
- the associated
ImmutableConfiguration
-
lookup
public Object lookup(String variable)
Looks up the value of the specified variable. This method is called byConfigurationInterpolator
with the variable name extracted from the expression to interpolate (i.e. the prefix name has already been removed). A concrete implementation has to return the value of this variable or null if the variable name is unknown. This implementation callsgetProperty()
on the associated configuration. The return value is directly returned. Note that this may be a complex object, e.g. a collection or an array.
-
-