get
protected Object get(String key)
Searches for the property with the specified key in this property map. If the key is not
found in this property map, the parent property map, and its parents, recursively, are then
checked.
If the key maps to any object value, it will be returned as is. If the property is not found,
null
will be returned.
key
- Key of the property to get from configuration.
- Object in this property map with the specified key value.
getApplicationClassLoader
public final ClassLoader getApplicationClassLoader()
Get classloader to be used for all classes of Castor and its required libraries.
- Classloader to be used for all classes of Castor and its required libraries.
getBoolean
public final Boolean getBoolean(String key)
Searches for the property with the specified key in this property map. If the key is not
found in this property map, the parent property map, and its parents, recursively, are then
checked.
If the key maps to a boolean value, it will be returned as is. For string values that are
equal, ignore case, to 'true' or 'false', the respective boolean value will be returned. If
the property is not found, null
will be returned. For all other types and
string values a ConfigurationException will be thrown. This behaviour is intended for those
usecases that need distinguish between values that are missconfigured or not specified at
all.
- Boolean value in this property map with the specified key value.
getBoolean
public final boolean getBoolean(String key,
boolean defaultValue)
Searches for the property with the specified key in this property map. If the key is not
found in this property map, the parent property map, and its parents, recursively, are then
checked.
If the key maps to a boolean value, it will be returned as is. For string values that are
equal, ignore case, to 'true' or 'false', the respective boolean value will be returned. In
all other cases the given default value will be returned.
key
- Property key.defaultValue
- Default value.
- Boolean value in this property map with the specified key value.
getClass
public final Class getClass(String key,
ClassLoader loader)
Searches for the property with the specified key in this property map. If the key is not
found in this property map, the parent property map, and its parents, recursively, are then
checked.
If the key maps to a class, it will be returned as is. A simple string will be interpreted
as class name of which the class will be loaded with the given class loader. If the property
is not found, null
will be returned. For all other types and if loading of the
class fails a ConfigurationException will be thrown.
key
- Property key.loader
- Class loader to load classes with.
- Class in this property map with the specified key value.
getClassArray
public final Class[] getClassArray(String key,
ClassLoader loader)
Searches for the property with the specified key in this property map. If the key is not
found in this property map, the parent property map, and its parents, recursively, are then
checked.
If the key maps to a class array, it will be returned as is. A simple string will be
splitted it into substrings at every occurence of ',' character. Each of these substrings
will interpreted as class name of which the class will be loaded with the given class
loader. If the property is not found, null
will be returned. For all other
types and if loading of one of the classes fails a ConfigurationException will be thrown.
key
- Property key.loader
- Class loader to load classes with.
- Class array in this property map with the specified key value.
getDomainClassLoader
public final ClassLoader getDomainClassLoader()
Get classloader to be used for all domain objects that are marshalled/unmarshalled or
loaded from the database.
- Classloader to be used for all domain objects.
getInteger
public final Integer getInteger(String key)
Searches for the property with the specified key in this property map. If the key is not
found in this property map, the parent property map, and its parents, recursively, are then
checked.
If the key maps to a integer value, it will be returned as is. For string values that can
be interpreted as signed decimal integer, the respective integer value will be returned. If
the property is not found, null
will be returned. For all other types and
string values a ConfigurationException will be thrown. This behaviour is intended for those
usecases that need distinguish between values that are missconfigured or not specified at
all.
- Integer value in this property map with the specified key value.
getInteger
public final int getInteger(String key,
int defaultValue)
Searches for the property with the specified key in this property map. If the key is not
found in this property map, the parent property map, and its parents, recursively, are then
checked.
If the key maps to a integer value, it will be returned as is. For string values that can
be interpreted as signed decimal integer, the respective integer value will be returned. In
all other cases the given default value will be returned.
key
- Property key.defaultValue
- Default value.
- Integer value in this property map with the specified key value.
getObject
public final Object getObject(String key)
Searches for the property with the specified key in this property map. If the key is not
found in this property map, the parent property map, and its parents, recursively, are then
checked.
If the key maps to any object value, it will be returned as is. If the property is not found,
null
will be returned.
- Object in this property map with the specified key value.
getObjectArray
public final Object[] getObjectArray(String key,
ClassLoader loader)
Searches for the property with the specified key in this property map. If the key is not
found in this property map, the parent property map, and its parents, recursively, are then
checked.
If the key maps to a object array, it will be returned as is. A simple string will be
splitted it into substrings at every occurence of ',' character. Each of these substrings
will interpreted as class name of which the class will be loaded with the given class
loader and instantiated using its default constructor. If the property is not found,
null
will be returned. For all other types and if loading or instantiation of
one of the classes fails a ConfigurationException will be thrown.
key
- Property key.loader
- Class loader to load classes with.
- Class array in this property map with the specified key value.
getString
public final String getString(String key)
Searches for the property with the specified key in this property map. If the key is not
found in this property map, the parent property map, and its parents, recursively, are then
checked.
If the key maps to a string value, it will be returned as is. If the property is not found,
null
will be returned. For all other types a ConfigurationException will be
thrown.
- String value in this property map with the specified key value.
getString
public final String getString(String key,
String defaultValue)
Searches for the property with the specified key in this property map. If the key is not
found in this property map, the parent property map, and its parents, recursively, are then
checked.
If the key maps to a string value that is not empty, it will be returned as is. In all other
cases the given default value will be returned.
key
- Property key.defaultValue
- Default value.
- String value in this property map with the specified key value.
getStringArray
public final String[] getStringArray(String key)
Searches for the property with the specified key in this property map. If the key is not
found in this property map, the parent property map, and its parents, recursively, are then
checked.
If the key maps to a string array, it will be returned as is. A simple string will be
converted into a string array by splitting it into substrings at every occurence of ','
character. If the property is not found, null
will be returned. For all other
types a ConfigurationException will be thrown.
- String array in this property map with the specified key value.
loadDefaultProperties
protected void loadDefaultProperties(String path,
String filename)
Load modul configuration from default locations.
First it loads default configuration contained in Castor JAR. This gets overwritten
by a configuration found on Java library directory. If no configuration could be found
until that point a ConfigurationException will be thrown.
path
- Path to the default configuration to load.filename
- Name of the configuration file.
loadUserProperties
protected void loadUserProperties(String filename)
Load common user configuration from classpath root and current working directory.
First it loads default configuration contained in Castor JAR. This gets overwritten
by a configuration found on Java library directory. If no configuration could be found
until that point a ConfigurationException will be thrown. At last an overriding
configuration is loaded from root of classpath or, if that could not be found, from
local working directory.
filename
- Name of the configuration file.
put
public final Object put(String key,
Object value)
Put given value associated with given key into the properties map of this configuration. If
the configuration previously associated the key to another value the previous value will be
returned. If a mapping for the key previously exist in the parent configuration only, the
method returns null
and not the value of the parent. This allows to distingush
if the mapping existed in this configuration or one of its parents.
Putting a value in this configuration does not change the value of its parent but the
parents value isn't visible any more as it gets overwritten by this configurations one.
While this allows to redifine the value of a property it isn't allowed to undefine it.
Therefore a NullPointerException
will be thrown if the given value is
null
.
key
- Key of the property to put into configuration.value
- Value to put into configuration associated with the given key..
- Object in this configuration that previously has been associated with the given key.
remove
public final Object remove(String key)
Remove any value previously associated with the given key from this configuration. The value
previously associated with the key int this configuration will be returned. If a mapping
for the key existed in the parent configuration only, the method returns null
and not the value of the parent. This allows to distingush if the mapping existed in this
configuration or one of its parents.
Removing the value from this configuration does not mean that consecutive gets return
null
as one of the parents may still contain a mapping for the key that
was hidden by the mapping in this configuration.
key
- Key of the property to remove from configuration.
- Object in this configuration that previously has been associated with the given key.