org.castor.util
Class Configuration
java.lang.Object
org.castor.util.Configuration
public final class Configuration
extends java.lang.Object
Class to hold Castor configuration properties.
$Revision: 6320 $ $Date: 2006-03-21 12:26:52 -0700 (Tue, 21 Mar 2006) $Configuration() - Create a new Configuration instance loading properties from default location.
|
Configuration(String filename) - Create a new Configuration instance loading properties from given location.
|
static void | disposeConfiguration() - Dispose the one and only configuration instance.
|
static Configuration | getInstance() - Get the one and only configuration instance.
|
Properties | getProperties() - Get the configured properties.
|
String[] | getProperty(String name) - Get property with given name as string array or if property is not available
return an empty string array.
|
String | getProperty(String name, String defaultValue) - Get property with given name as string or if property is not available return
the given default string.
|
boolean | getProperty(String name, boolean defaultValue) - Get property with given name as boolean value.
|
int | getProperty(String name, int defaultValue) - Get property with given name as int value.
|
void | loadDefaultProperties() - Load properties from default location.
|
void | loadProperties(String filename) - Load properties from given filename.
|
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.
filename
- Absolute or relative filename of the properties file.
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.
- The configuration instance.
getProperties
public Properties getProperties()
Get the configured properties.
- The configured properties.
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.
name
- Name of the property.
- The string array of configured property.
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.
name
- Name of the property.defaultValue
- Default string to return if property is not available.
- The configured string property or the default string if property is
not available.
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.
name
- Name of the property.defaultValue
- Default boolean value to return if property is not available
or does not equal 'true' or 'false'
- The configured boolean property or the default boolean value if property
is not available or does not equal 'true' or 'false'.
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.
name
- Name of the property.defaultValue
- Default int value to return if property is not available or
can not be interpreted as integer.
- The configured int property or the default int value if property is
not available or can not be interpreted as integer.
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.
filename
- Absolute or relative filename of the properties file.
Intalio Inc. (C) 1999-2006. All rights reserved http://www.intalio.com