Class ConfigurationLookup

  • All Implemented Interfaces:
    Lookup

    public class ConfigurationLookup
    extends java.lang.Object
    implements Lookup

    A specialized implementation of the Lookup interface which uses a Configuration object to resolve variables.

    This class is passed an ImmutableConfiguration object at construction time. In its implementation of the lookup() method it simply queries this configuration for the passed in variable name. So the keys passed to lookup() are mapped directly to configuration properties.

    Since:
    2.0
    Version:
    $Id: ConfigurationLookup.java 1624601 2014-09-12 18:04:36Z oheger $
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ImmutableConfiguration getConfiguration()
      Returns the ImmutableConfiguration used by this object.
      java.lang.Object lookup​(java.lang.String variable)
      Looks up the value of the specified variable.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ConfigurationLookup

        public ConfigurationLookup​(ImmutableConfiguration config)
        Creates a new instance of ConfigurationLookup and sets the associated ImmutableConfiguration.
        Parameters:
        config - the configuration to use for lookups (must not be null)
        Throws:
        java.lang.IllegalArgumentException - if the configuration is null
    • Method Detail

      • getConfiguration

        public ImmutableConfiguration getConfiguration()
        Returns the ImmutableConfiguration used by this object.
        Returns:
        the associated ImmutableConfiguration
      • lookup

        public java.lang.Object lookup​(java.lang.String variable)
        Looks up the value of the specified variable. This method is called by ConfigurationInterpolator 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 calls getProperty() 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.
        Specified by:
        lookup in interface Lookup
        Parameters:
        variable - the name of the variable to be resolved
        Returns:
        the value of this variable or null