org.apache.commons.configuration
Class DatabaseConfiguration

java.lang.Object
  extended byorg.apache.commons.configuration.AbstractConfiguration
      extended byorg.apache.commons.configuration.DatabaseConfiguration
All Implemented Interfaces:
Configuration

public class DatabaseConfiguration
extends AbstractConfiguration

Configuration stored in a database.

Since:
1.0
Version:
$Revision: 1.10 $, $Date: 2004/09/20 09:37:07 $
Author:
Emmanuel Bourg

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
DatabaseConfiguration(DataSource datasource, String table, String keyColumn, String valueColumn)
          Build a configuration from a table.-
DatabaseConfiguration(DataSource datasource, String table, String nameColumn, String keyColumn, String valueColumn, String name)
          Build a configuration from a table containing multiple configurations.
 
Method Summary
protected  void addPropertyDirect(String key, Object obj)
          Adds a key/value pair to the Configuration. Override this method to provide write acces to underlying Configuration store.
 void clearProperty(String key)
          Remove a property from the configuration.
 boolean containsKey(String key)
          Check if the configuration contains the specified key.
 Iterator getKeys()
          Get the list of the keys contained in the configuration.
protected  Object getPropertyDirect(String key)
          Read property. Should return null if the key doesn't map to an existing object.
 boolean isEmpty()
          Check if the configuration is empty.
 
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, getKeys, getList, getList, getLong, getLong, getLong, getProperties, getProperties, getProperty, getShort, getShort, getShort, getString, getString, getStringArray, getVector, getVector, interpolate, interpolateHelper, isThrowExceptionOnMissing, setDelimiter, setProperty, setThrowExceptionOnMissing, split, subset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseConfiguration

public DatabaseConfiguration(DataSource datasource,
                             String table,
                             String nameColumn,
                             String keyColumn,
                             String valueColumn,
                             String name)
Build a configuration from a table containing multiple configurations.

Parameters:
datasource - the datasource to connect to the database
table - the name of the table containing the configurations
nameColumn - the column containing the name of the configuration
keyColumn - the column containing the keys of the configuration
valueColumn - the column containing the values of the configuration
name - the name of the configuration

DatabaseConfiguration

public DatabaseConfiguration(DataSource datasource,
                             String table,
                             String keyColumn,
                             String valueColumn)
Build a configuration from a table.-

Parameters:
datasource - the datasource to connect to the database
table - the name of the table containing the configurations
keyColumn - the column containing the keys of the configuration
valueColumn - the column containing the values of the configuration
Method Detail

getPropertyDirect

protected Object getPropertyDirect(String key)
Read property. Should return null if the key doesn't map to an existing object.

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

addPropertyDirect

protected void addPropertyDirect(String key,
                                 Object obj)
Adds a key/value pair to the Configuration. Override this method to provide write acces to underlying Configuration store.

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

isEmpty

public boolean isEmpty()
Check if the configuration is empty.

Specified by:
isEmpty in interface Configuration
Specified by:
isEmpty 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

clearProperty

public void clearProperty(String key)
Remove a property from the configuration.

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

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


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