ojb.broker.util
Class BaseConfiguration

java.lang.Object
  |
  +--ojb.broker.util.BaseConfiguration
Direct Known Subclasses:
PersistenceBrokerFactoryConfiguration

public abstract class BaseConfiguration
extends java.lang.Object

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


Field Summary
protected  java.lang.String filename
          the name of the properties file
protected  java.util.Properties properties
          the properties object holding the configuration data
 
Constructor Summary
BaseConfiguration()
          The constructor loads the configuration from file
 
Method Summary
 boolean getBoolean(java.lang.String key, boolean defaultValue)
          Returns the boolean value for the specified key.
 java.lang.Class getClass(java.lang.String key, java.lang.Class defaultValue)
          Returns the class specified by the value for the specified key.
 java.lang.Class getClass(java.lang.String key, java.lang.Class defaultValue, java.lang.Class assignable)
          Returns the class specified by the value for the specified key.
 java.lang.Class getClass(java.lang.String key, java.lang.Class defaultValue, java.lang.Class[] assignables)
          Returns the class specified by the value for the specified key.
 int getInteger(java.lang.String key, int defaultValue)
          Returns the integer value for the specified key.
 java.lang.String getString(java.lang.String key, java.lang.String defaultValue)
          Returns the string value for the specified key.
 java.lang.String[] getStrings(java.lang.String key, java.lang.String defaultValue)
          Gets an array of Strings from the value of the specified key, seperated by ";".
 java.lang.String[] getStrings(java.lang.String key, java.lang.String defaultValue, java.lang.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(java.lang.String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filename

protected java.lang.String filename
the name of the properties file


properties

protected java.util.Properties properties
the properties object holding the configuration data

Constructor Detail

BaseConfiguration

public BaseConfiguration()
The constructor loads the configuration from file

Method Detail

getString

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

Parameters:
key - the key
defaultValue - the default value
Returns:
the value for the key, or defaultValue

getStrings

public java.lang.String[] getStrings(java.lang.String key,
                                     java.lang.String defaultValue,
                                     java.lang.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.

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 java.lang.String[] getStrings(java.lang.String key,
                                     java.lang.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.

Parameters:
key - the key
defaultValue - the default Value
Returns:
the strings for the key, or the strings contained in defaultValue

getInteger

public int getInteger(java.lang.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.

Parameters:
key - the key
defaultValue - the default Value
Returns:
the value for the key, or defaultValue

getBoolean

public boolean getBoolean(java.lang.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.

Parameters:
key - the key
defaultValue - the default Value
Returns:
the value for the key, or defaultValue
See Also:
#trueValues, #falseValues

getClass

public java.lang.Class getClass(java.lang.String key,
                                java.lang.Class defaultValue,
                                java.lang.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.

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 java.lang.Class getClass(java.lang.String key,
                                java.lang.Class defaultValue,
                                java.lang.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.

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 java.lang.Class getClass(java.lang.String key,
                                java.lang.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.

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.


setFilename

protected void setFilename(java.lang.String name)


Authors: Thomas Mahler and others. (C) 2000, 2001.
All rights reserved. Published under the Gnu Public License.
http://objectbridge.sourceforge.net
Version: 0.8.375, 2002-04-04