org.castor.util
Class Configuration

java.lang.Object
  extended by org.castor.util.Configuration

public final class Configuration
extends java.lang.Object

Class to hold Castor configuration properties.

Since:
1.0
Version:
$Revision: 6907 $ $Date: 2006-03-21 12:26:52 -0700 (Tue, 21 Mar 2006) $
Author:
Ralf Joachim

Constructor Summary
Configuration()
          Create a new Configuration instance loading properties from default location.
Configuration(java.lang.String filename)
          Create a new Configuration instance loading properties from given location.
 
Method Summary
static void disposeConfiguration()
          Dispose the one and only configuration instance.
static Configuration getInstance()
          Get the one and only configuration instance.
 java.util.Properties getProperties()
          Get the configured properties.
 java.lang.String[] getProperty(java.lang.String name)
          Get property with given name as string array or if property is not available return an empty string array.
 boolean getProperty(java.lang.String name, boolean defaultValue)
          Get property with given name as boolean value.
 int getProperty(java.lang.String name, int defaultValue)
          Get property with given name as int value.
 java.lang.String getProperty(java.lang.String name, java.lang.String defaultValue)
          Get property with given name as string or if property is not available return the given default string.
 void loadDefaultProperties()
          Load properties from default location.
 void loadProperties(java.lang.String filename)
          Load properties from given filename.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Configuration

public Configuration()
Create a new Configuration instance loading properties from default location.


Configuration

public Configuration(java.lang.String filename)
Create a new Configuration instance loading properties from given location.

Parameters:
filename - Absolute or relative filename of the properties file.
Method Detail

getInstance

public static Configuration getInstance()
Get the one and only configuration instance. If not done yet, a new configuration will be constructed and default properties will be loaded.

Returns:
The configuration instance.

disposeConfiguration

public static void disposeConfiguration()
Dispose the one and only configuration instance.


loadDefaultProperties

public void loadDefaultProperties()
Load properties from default location.


loadProperties

public void loadProperties(java.lang.String filename)
Load properties from given filename. It first tries to interpret filename as absolute resource location. If this fails it's assumed that filename should be interpreted relative to classpath.

Parameters:
filename - Absolute or relative filename of the properties file.

getProperties

public java.util.Properties getProperties()
Get the configured properties.

Returns:
The configured properties.

getProperty

public java.lang.String getProperty(java.lang.String name,
                                    java.lang.String defaultValue)
Get property with given name as string or if property is not available return the given default string.

Parameters:
name - Name of the property.
defaultValue - Default string to return if property is not available.
Returns:
The configured string property or the default string if property is not available.

getProperty

public java.lang.String[] getProperty(java.lang.String name)
Get property with given name as string array or if property is not available return an empty string array.

Parameters:
name - Name of the property.
Returns:
The string array of configured property.

getProperty

public int getProperty(java.lang.String name,
                       int defaultValue)
Get property with given name as int value. If property is not available or can not be interpreted as integer the given default int value will be returned.

Parameters:
name - Name of the property.
defaultValue - Default int value to return if property is not available or can not be interpreted as integer.
Returns:
The configured int property or the default int value if property is not available or can not be interpreted as integer.

getProperty

public boolean getProperty(java.lang.String name,
                           boolean defaultValue)
Get property with given name as boolean value. If property is not available or does not equal 'true' or 'false' the given default boolean value will be returned.

Parameters:
name - Name of the property.
defaultValue - Default boolean value to return if property is not available or does not equal 'true' or 'false'
Returns:
The configured boolean property or the default boolean value if property is not available or does not equal 'true' or 'false'.


Intalio Inc. (C) 1999-2007. All rights reserved http://www.intalio.com