org.apache.ojb.broker.util.configuration.impl
Class ConfigurationAbstractImpl

java.lang.Object
  extended by org.apache.ojb.broker.util.configuration.impl.ConfigurationAbstractImpl
All Implemented Interfaces:
Configuration
Direct Known Subclasses:
LoggingConfiguration, OjbConfiguration

public abstract class ConfigurationAbstractImpl
extends Object
implements Configuration

Configuration Base Class that keeps a Properties based configuration persistent in a file. This class provides only basic infrastructure for loading etc.

Version:
$Id: ConfigurationAbstractImpl.java,v 1.1 2007-08-24 22:17:42 ewestfal Exp $
Author:
Thomas Mahler

Field Summary
protected  String filename
          the name of the properties file
protected  Properties properties
          the properties object holding the configuration data
 
Constructor Summary
ConfigurationAbstractImpl()
          The constructor loads the configuration from file
 
Method Summary
 boolean getBoolean(String key, boolean defaultValue)
          Returns the boolean value for the specified key.
 byte getByte(String key, byte defaultValue)
           
 Class getClass(String key, Class defaultValue)
          Returns the class specified by the value for the specified key.
 Class getClass(String key, Class defaultValue, Class assignable)
          Returns the class specified by the value for the specified key.
 Class getClass(String key, Class defaultValue, Class[] assignables)
          Returns the class specified by the value for the specified key.
 int getInteger(String key, int defaultValue)
          Returns the integer value for the specified key.
 long getLong(String key, long defaultValue)
           
 String getString(String key, String defaultValue)
          Returns the string value for the specified key.
 String[] getStrings(String key, String defaultValue)
          Gets an array of Strings from the value of the specified key, seperated by ";".
 String[] getStrings(String key, String defaultValue, String seperators)
          Gets an array of Strings from the value of the specified key, seperated by any key from seperators.
protected  void load()
          Loads the Configuration from the properties file.
protected  void setFilename(String name)
           
 void setLogger(Logger loggerInstance)
          this method allows to set a logger that tracks configuration events.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filename

protected String filename
the name of the properties file


properties

protected Properties properties
the properties object holding the configuration data

Constructor Detail

ConfigurationAbstractImpl

public ConfigurationAbstractImpl()
The constructor loads the configuration from file

Method Detail

getString

public String getString(String key,
                        String defaultValue)
Returns the string value for the specified key. If no value for this key is found in the configuration defaultValue is returned.

Specified by:
getString in interface Configuration
Parameters:
key - the key
defaultValue - the default value
Returns:
the value for the key, or defaultValue

getStrings

public String[] getStrings(String key,
                           String defaultValue,
                           String seperators)
Gets an array of Strings from the value of the specified key, seperated by any key from seperators. If no value for this key is found the array contained in defaultValue is returned.

Specified by:
getStrings in interface Configuration
Parameters:
key - the key
defaultValue - the default Value
seperators - the seprators to be used
Returns:
the strings for the key, or the strings contained in defaultValue
See Also:
StringTokenizer

getStrings

public String[] getStrings(String key,
                           String defaultValue)
Gets an array of Strings from the value of the specified key, seperated by ";". If no value for this key is found the array contained in defaultValue is returned.

Specified by:
getStrings in interface Configuration
Parameters:
key - the key
defaultValue - the default Value
Returns:
the strings for the key, or the strings contained in defaultValue

getInteger

public int getInteger(String key,
                      int defaultValue)
Returns the integer value for the specified key. If no value for this key is found in the configuration or the value is not an legal integer defaultValue is returned.

Specified by:
getInteger in interface Configuration
Parameters:
key - the key
defaultValue - the default Value
Returns:
the value for the key, or defaultValue

getLong

public long getLong(String key,
                    long defaultValue)

getByte

public byte getByte(String key,
                    byte defaultValue)

getBoolean

public boolean getBoolean(String key,
                          boolean defaultValue)
Returns the boolean value for the specified key. If no value for this key is found in the configuration or the value is not an legal boolean defaultValue is returned.

Specified by:
getBoolean in interface Configuration
Parameters:
key - the key
defaultValue - the default Value
Returns:
the value for the key, or defaultValue
See Also:
trueValues, falseValues

getClass

public Class getClass(String key,
                      Class defaultValue,
                      Class[] assignables)
Returns the class specified by the value for the specified key. If no value for this key is found in the configuration, no class of this name can be found or the specified class is not assignable to each class/interface in assignables defaultValue is returned.

Specified by:
getClass in interface Configuration
Parameters:
key - the key
defaultValue - the default Value
assignables - classes and/or interfaces the specified class must extend/implement.
Returns:
the value for the key, or defaultValue

getClass

public Class getClass(String key,
                      Class defaultValue,
                      Class assignable)
Returns the class specified by the value for the specified key. If no value for this key is found in the configuration, no class of this name can be found or the specified class is not assignable assignable defaultValue is returned.

Specified by:
getClass in interface Configuration
Parameters:
key - the key
defaultValue - the default Value
assignable - a classe and/or interface the specified class must extend/implement.
Returns:
the value for the key, or defaultValue

getClass

public Class getClass(String key,
                      Class defaultValue)
Returns the class specified by the value for the specified key. If no value for this key is found in the configuration or no class of this name can be found defaultValue is returned.

Specified by:
getClass in interface Configuration
Parameters:
key - the key
defaultValue - the default Value
Returns:
the value for the key, or defaultValue

load

protected void load()
Loads the Configuration from the properties file. Loads the properties file, or uses defaults on failure.

See Also:
setFilename(java.lang.String)

setFilename

protected void setFilename(String name)

setLogger

public void setLogger(Logger loggerInstance)
Description copied from interface: Configuration
this method allows to set a logger that tracks configuration events.

Specified by:
setLogger in interface Configuration
Parameters:
loggerInstance - the logger to set
See Also:
Configuration.setLogger(Logger)


Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.