Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.configuration
Class CompositeConfiguration

    java.lang.Object
      org.apache.commons.configuration.AbstractConfiguration
          org.apache.commons.configuration.CompositeConfiguration

All Implemented Interfaces:
  Configuration

public class CompositeConfiguration
extends AbstractConfiguration

This Configuration class allows you to add multiple different types of Configuration to this CompositeConfiguration. If you add Configuration1, and then Configuration2, any properties shared will mean that Configuration1 will be returned. You can add multiple different types or the same type of properties file. If Configuration1 doesn't have the property, then Configuration2 will be checked.

Version:
  $Id: CompositeConfiguration.java,v 1.19 2004/10/05 22:56:58 ebourg Exp $
Author:
  Eric Pugh, Henning P. Schmiedehausen

Nested Class Summary

Nested classes inherited from class org.apache.commons.configuration.AbstractConfiguration
`AbstractConfiguration.PropertiesTokenizer`

Field Summary

Fields inherited from class org.apache.commons.configuration.AbstractConfiguration
`END_TOKEN, START_TOKEN`

Constructor Summary
`CompositeConfiguration()` Creates an empty CompositeConfiguration object which can then be added some other Configuration files
`CompositeConfiguration(Configuration inMemoryConfiguration)` Creates an CompositeConfiguration object with a specified InMemory configuration.

Method Summary
`void` | `addConfiguration(Configuration config)` Add a configuration.
`protected void` | `addPropertyDirect(String key, Object token)` Add this property to the inmemory Configuration.
`void` | `clear()` Remove all configuration reinitialize the in memory configuration.
`void` | `clearProperty(String key)` Remove a property from the configuration.
`boolean` | `containsKey(String key)` Check if the configuration contains the specified key.
`Configuration` | `getConfiguration(int index)` Return the configuration at the specified index.
`Configuration` | `getInMemoryConfiguration()` {@inheritDoc}
`Iterator` | `getKeys()` Get the list of the keys contained in the configuration.
`Iterator` | `getKeys(String key)` Get the list of the keys contained in the configuration that match the specified prefix.
`List` | `getList(String key, List defaultValue)` Get a List of strings associated with the given configuration key.
`int` | `getNumberOfConfigurations()` Return the number of configurations.
`Object` | `getProperty(String key)` Gets a property from the configuration.
`protected Object` | `getPropertyDirect(String key)` Read property from underlying composite
`String[]` | `getStringArray(String key)` Get an array of strings associated with the given configuration key. If the key doesn't map to an existing object an empty array is returned
`Vector` | `getVector(String key, Vector defaultValue)` Get a Vector of strings associated with the given configuration key.
`boolean` | `isEmpty()` Check if the configuration is empty.
`void` | `removeConfiguration(Configuration config)` Remove a configuration.
`void` | `setProperty(String key, Object value)` Set a property, this will replace any previously set values. Set values is implicitly a call to clearProperty(key), addProperty(key, value).

Methods inherited from class org.apache.commons.configuration.AbstractConfiguration
`addProperty, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDelimiter, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getList, getLong, getLong, getLong, getProperties, getProperties, getShort, getShort, getShort, getString, getString, getVector, interpolate, interpolateHelper, isThrowExceptionOnMissing, setDelimiter, setThrowExceptionOnMissing, split, subset`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### CompositeConfiguration

    public CompositeConfiguration()

  Creates an empty CompositeConfiguration object which can then be added some other Configuration files

### CompositeConfiguration

    public CompositeConfiguration(Configuration inMemoryConfiguration)

  Creates an CompositeConfiguration object with a specified InMemory configuration. This configuration will store any changes made to the CompositeConfiguration.

Parameters:
  `inMemoryConfiguration` - the in memory configuration to use

Method Detail

### addConfiguration

    public void addConfiguration(Configuration config)

  Add a configuration.

  Parameters:
    `config` - the configuration to add

### removeConfiguration

    public void removeConfiguration(Configuration config)

  Remove a configuration. The in memory configuration cannot be removed.

  Parameters:
    `config` - The configuration to remove

### getNumberOfConfigurations

    public int getNumberOfConfigurations()

  Return the number of configurations.

  Returns:
    the number of configuration

### clear

    public void clear()

  Remove all configuration reinitialize the in memory configuration.

### addPropertyDirect

    protected void addPropertyDirect(String key,
                                     Object token)

  Add this property to the inmemory Configuration.

  Specified by:
    `addPropertyDirect` in class `AbstractConfiguration`
  Parameters:
    `key` - The Key to add the property to.
    `token` - The Value to add.

### getPropertyDirect

    protected Object getPropertyDirect(String key)

  Read property from underlying composite

  Specified by:
    `getPropertyDirect` in class `AbstractConfiguration`
  Parameters:
    `key` - key to use for mapping
  Returns:
    object associated with the given configuration key.

### getKeys

    public Iterator getKeys()

  Get the list of the keys contained in the configuration.

  Specified by:
    `getKeys` in interface `Configuration`
  Specified by:
    `getKeys` in class `AbstractConfiguration`

### getKeys

    public Iterator getKeys(String key)

  Get the list of the keys contained in the configuration that match the specified prefix.

  Specified by:
    `getKeys` in interface `Configuration`
  Overrides:
    `getKeys` in class `AbstractConfiguration`

### isEmpty

    public boolean isEmpty()

  Check if the configuration is empty.

  Specified by:
    `isEmpty` in interface `Configuration`
  Specified by:
    `isEmpty` in class `AbstractConfiguration`

### getProperty

    public Object getProperty(String key)

  Gets a property from the configuration.

  Specified by:
    `getProperty` in interface `Configuration`
  Overrides:
    `getProperty` in class `AbstractConfiguration`

### setProperty

    public void setProperty(String key,
                            Object value)

  Set a property, this will replace any previously set values. Set values is implicitly a call to clearProperty(key), addProperty(key, value).

  Specified by:
    `setProperty` in interface `Configuration`
  Overrides:
    `setProperty` in class `AbstractConfiguration`

### clearProperty

    public void clearProperty(String key)

  Remove a property from the configuration.

  Specified by:
    `clearProperty` in interface `Configuration`
  Specified by:
    `clearProperty` in class `AbstractConfiguration`

### containsKey

    public boolean containsKey(String key)

  Check if the configuration contains the specified key.

  Specified by:
    `containsKey` in interface `Configuration`
  Specified by:
    `containsKey` in class `AbstractConfiguration`

### getList

    public List getList(String key,
                        List defaultValue)

  Get a List of strings associated with the given configuration key.

  Specified by:
    `getList` in interface `Configuration`
  Overrides:
    `getList` in class `AbstractConfiguration`

### getVector

    public Vector getVector(String key,
                            Vector defaultValue)

  Get a Vector of strings associated with the given configuration key.

  Specified by:
    `getVector` in interface `Configuration`
  Overrides:
    `getVector` in class `AbstractConfiguration`

### getStringArray

    public String[] getStringArray(String key)

  Get an array of strings associated with the given configuration key. If the key doesn't map to an existing object an empty array is returned

  Specified by:
    `getStringArray` in interface `Configuration`
  Overrides:
    `getStringArray` in class `AbstractConfiguration`

### getConfiguration

    public Configuration getConfiguration(int index)

  Return the configuration at the specified index.

  Parameters:
    `index` - The index of the configuration to retrieve

### getInMemoryConfiguration

    public Configuration getInMemoryConfiguration()

  {@inheritDoc}

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2004 The Apache Software Foundation. All Rights Reserved.