org.castor.util

Class Configuration

public final class Configuration extends Object

Class to hold Castor configuration properties.

Since: 1.0

Version: $Revision: 6320 $ $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(String filename)
Create a new Configuration instance loading properties from given location.
Method Summary
static voiddisposeConfiguration()
Dispose the one and only configuration instance.
static ConfigurationgetInstance()
Get the one and only configuration instance.
PropertiesgetProperties()
Get the configured properties.
StringgetProperty(String name, String defaultValue)
Get property with given name as string or if property is not available return the given default string.
String[]getProperty(String name)
Get property with given name as string array or if property is not available return an empty string array.
intgetProperty(String name, int defaultValue)
Get property with given name as int value.
booleangetProperty(String name, boolean defaultValue)
Get property with given name as boolean value.
voidloadDefaultProperties()
Load properties from default location.
voidloadProperties(String filename)
Load properties from given filename.

Constructor Detail

Configuration

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

Configuration

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

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

Method Detail

disposeConfiguration

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

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.

getProperties

public Properties getProperties()
Get the configured properties.

Returns: The configured properties.

getProperty

public String getProperty(String name, 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 String[] getProperty(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(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(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'.

loadDefaultProperties

public void loadDefaultProperties()
Load properties from default location.

loadProperties

public void loadProperties(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.

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