org.apache.commons.configuration
Class BaseConfiguration

java.lang.Object
  extended byorg.apache.commons.configuration.AbstractConfiguration
      extended byorg.apache.commons.configuration.BaseConfiguration
All Implemented Interfaces:
Configuration
Direct Known Subclasses:
BasePathConfiguration, JNDIConfiguration

public class BaseConfiguration
extends AbstractConfiguration

Basic configuration classe. Stores the configuration data but does not provide any load or save functions. If you want to load your Configuration from a file use PropertiesConfiguration or XmlConfiguration. This class extends normal Java properties by adding the possibility to use the same key many times concatenating the value strings instead of overwriting them.

Version:
$Id: BaseConfiguration.java,v 1.1.1.1 2003/12/23 15:09:05 epugh Exp $
Author:
Stefano Mazzocchi, Jon S. Stevens, Dave Bryson, Geir Magnusson Jr., Leon Messerschmidt, Kent Johnson, Daniel Rall, Ilkka Priha, Jason van Zyl, Martin Poeschl, Henning P. Schmiedehausen, Konstantin Shaposhnikov, Oliver Heger

Nested Class Summary
 
Nested classes inherited from class org.apache.commons.configuration.AbstractConfiguration
AbstractConfiguration.Container, AbstractConfiguration.PropertiesTokenizer
 
Field Summary
private  org.apache.commons.collections.SequencedHashMap store
          stores the configuration key-value pairs
 
Fields inherited from class org.apache.commons.configuration.AbstractConfiguration
defaults, END_TOKEN, START_TOKEN
 
Constructor Summary
BaseConfiguration()
          Empty constructor.
BaseConfiguration(Configuration defaults)
          Creates an empty BaseConfiguration object with a Super-Object which is queries for every key.
 
Method Summary
protected  void addPropertyDirect(java.lang.String key, java.lang.Object obj)
          Adds a key/value pair to the map.
 void clearProperty(java.lang.String key)
          Clear a property in the configuration.
 boolean containsKey(java.lang.String key)
          check if the configuration contains the key
 java.util.Iterator getKeys()
          Get the list of the keys contained in the configuration repository.
protected  java.lang.Object getPropertyDirect(java.lang.String key)
          Read property from underlying map.
 boolean isEmpty()
          Check if the configuration is empty
 
Methods inherited from class org.apache.commons.configuration.AbstractConfiguration
addProperty, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getKeys, getList, getList, getLong, getLong, getLong, getProperties, getProperties, getProperty, getShort, getShort, getShort, getString, getString, getStringArray, interpolate, interpolateHelper, processString, setProperty, subset, testBoolean
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

store

private org.apache.commons.collections.SequencedHashMap store
stores the configuration key-value pairs

Constructor Detail

BaseConfiguration

public BaseConfiguration()
Empty constructor. You must add all the values to this configuration.


BaseConfiguration

public BaseConfiguration(Configuration defaults)
Creates an empty BaseConfiguration object with a Super-Object which is queries for every key.

Parameters:
defaults - Configuration defaults to use if key not in file
Method Detail

addPropertyDirect

protected void addPropertyDirect(java.lang.String key,
                                 java.lang.Object obj)
Adds a key/value pair to the map. This routine does no magic morphing. It ensures the keylist is maintained

Specified by:
addPropertyDirect in class AbstractConfiguration
Parameters:
key - key to use for mapping
obj - object to store

getPropertyDirect

protected java.lang.Object getPropertyDirect(java.lang.String key)
Read property from underlying map.

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

isEmpty

public boolean isEmpty()
Check if the configuration is empty

Specified by:
isEmpty in interface Configuration
Specified by:
isEmpty in class AbstractConfiguration
Returns:
true if Configuration is empty, false otherwise.

containsKey

public boolean containsKey(java.lang.String key)
check if the configuration contains the key

Specified by:
containsKey in interface Configuration
Specified by:
containsKey in class AbstractConfiguration
Parameters:
key - the configuration key
Returns:
true if Configuration contain given key, false otherwise.

clearProperty

public void clearProperty(java.lang.String key)
Clear a property in the configuration.

Specified by:
clearProperty in interface Configuration
Specified by:
clearProperty in class AbstractConfiguration
Parameters:
key - the key to remove along with corresponding value.

getKeys

public java.util.Iterator getKeys()
Get the list of the keys contained in the configuration repository.

Specified by:
getKeys in interface Configuration
Specified by:
getKeys in class AbstractConfiguration
Returns:
An Iterator.