|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.configuration.CompositeConfiguration
This Configuration class allows you to add multiple different types of Configuration to this CompositeConfiguration. If you add Configuration1, and then Configuration2, any properties shared will mean that Configuration1 will be returned. You can add multiple different types or the same type of properties file. If Configuration1 doesn't have the property, then Configuration2 will be checked.
Field Summary | |
private java.util.LinkedList |
configList
Array holding all the configuration |
private BaseConfiguration |
inMemoryConfiguration
Configuration that holds in memory stuff. |
Constructor Summary | |
CompositeConfiguration()
Creates an empty CompositeConfiguration object which can then be added some other Configuration files |
Method Summary | |
void |
addConfiguration(Configuration config)
|
void |
addProperty(java.lang.String key,
java.lang.Object token)
CompositeConfigurations can not be added to |
void |
clear()
|
void |
clearProperty(java.lang.String key)
Clear a property in the configuration. |
boolean |
containsKey(java.lang.String key)
check if the configuration contains the key |
boolean |
getBoolean(java.lang.String key)
Get a boolean associated with the given configuration key. |
boolean |
getBoolean(java.lang.String key,
boolean defaultValue)
Get a boolean associated with the given configuration key. |
java.lang.Boolean |
getBoolean(java.lang.String key,
java.lang.Boolean defaultValue)
Get a boolean associated with the given configuration key. |
byte |
getByte(java.lang.String key)
Get a byte associated with the given configuration key. |
byte |
getByte(java.lang.String key,
byte defaultValue)
Get a byte associated with the given configuration key. |
java.lang.Byte |
getByte(java.lang.String key,
java.lang.Byte defaultValue)
Get a byte associated with the given configuration key. |
Configuration |
getConfiguration(int index)
|
double |
getDouble(java.lang.String key)
Get a double associated with the given configuration key. |
double |
getDouble(java.lang.String key,
double defaultValue)
Get a double associated with the given configuration key. |
java.lang.Double |
getDouble(java.lang.String key,
java.lang.Double defaultValue)
Get a double associated with the given configuration key. |
private Configuration |
getFirstMatchingConfig(java.lang.String key)
|
float |
getFloat(java.lang.String key)
Get a float associated with the given configuration key. |
float |
getFloat(java.lang.String key,
float defaultValue)
Get a float associated with the given configuration key. |
java.lang.Float |
getFloat(java.lang.String key,
java.lang.Float defaultValue)
Get a float associated with the given configuration key. |
int |
getInt(java.lang.String key)
Get a int associated with the given configuration key. |
int |
getInt(java.lang.String key,
int defaultValue)
Get a int associated with the given configuration key. |
java.lang.Integer |
getInteger(java.lang.String key,
java.lang.Integer defaultValue)
Get a int associated with the given configuration key. |
java.util.Iterator |
getKeys()
Get the list of the keys contained in the configuration repository. |
java.util.Iterator |
getKeys(java.lang.String key)
Get the list of the keys contained in the configuration repository. |
java.util.List |
getList(java.lang.String key)
Get a List of strings associated with the given configuration key. |
java.util.List |
getList(java.lang.String key,
java.util.List defaultValue)
Get a List of strings associated with the given configuration key. |
long |
getLong(java.lang.String key)
Get a long associated with the given configuration key. |
long |
getLong(java.lang.String key,
long defaultValue)
Get a long associated with the given configuration key. |
java.lang.Long |
getLong(java.lang.String key,
java.lang.Long defaultValue)
Get a long associated with the given configuration key. |
int |
getNumberOfConfigurations()
|
java.util.Properties |
getProperties(java.lang.String key)
Get a list of properties associated with the given configuration key. |
java.lang.Object |
getProperty(java.lang.String key)
Gets a property from the configuration. |
short |
getShort(java.lang.String key)
Get a short associated with the given configuration key. |
short |
getShort(java.lang.String key,
short defaultValue)
Get a short associated with the given configuration key. |
java.lang.Short |
getShort(java.lang.String key,
java.lang.Short defaultValue)
Get a short associated with the given configuration key. |
java.lang.String |
getString(java.lang.String key)
Get a string associated with the given configuration key. |
java.lang.String |
getString(java.lang.String key,
java.lang.String defaultValue)
Get a string associated with the given configuration key. |
java.lang.String[] |
getStringArray(java.lang.String key)
Get an array of strings associated with the given configuration key. |
boolean |
isEmpty()
Check if the configuration is empty. |
void |
removeConfiguration(Configuration config)
|
void |
setProperty(java.lang.String key,
java.lang.Object value)
Set a property, this will replace any previously set values. |
Configuration |
subset(java.lang.String prefix)
Create a CompositeConfiguration object that is a subset of this one. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private java.util.LinkedList configList
private BaseConfiguration inMemoryConfiguration
Constructor Detail |
public CompositeConfiguration()
Method Detail |
public void addConfiguration(Configuration config)
public void removeConfiguration(Configuration config)
public int getNumberOfConfigurations()
public void clear()
public void addProperty(java.lang.String key, java.lang.Object token)
addProperty
in interface Configuration
key
- The Key to add the property to.token
- The Value to add.public java.util.Iterator getKeys()
getKeys
in interface Configuration
public java.util.Iterator getKeys(java.lang.String key)
getKeys
in interface Configuration
key
- The prefix to test against.
public java.util.Properties getProperties(java.lang.String key)
getProperties
in interface Configuration
key
- The configuration key.
java.lang.ClassCastException
- is thrown if the key maps to an
object that is not a String/List.
java.lang.IllegalArgumentException
- if one of the tokens is
malformed (does not contain an equals sign).#getProperties(String, Properties)
public boolean isEmpty()
Configuration
isEmpty
in interface Configuration
public java.lang.Object getProperty(java.lang.String key)
getProperty
in interface Configuration
key
- property to retrieve
public void setProperty(java.lang.String key, java.lang.Object value)
setProperty
in interface Configuration
key
- value
- public void clearProperty(java.lang.String key)
clearProperty
in interface Configuration
key
- the key to remove along with corresponding value.public boolean containsKey(java.lang.String key)
containsKey
in interface Configuration
public Configuration subset(java.lang.String prefix)
subset
in interface Configuration
prefix
- public float getFloat(java.lang.String key)
getFloat
in interface Configuration
key
- The configuration key.
public boolean getBoolean(java.lang.String key)
getBoolean
in interface Configuration
key
- The configuration key.
java.util.NoSuchElementException
- is thrown if the key doesn't
map to an existing object.
java.lang.ClassCastException
- is thrown if the key maps to an
object that is not a Boolean.public boolean getBoolean(java.lang.String key, boolean defaultValue)
getBoolean
in interface Configuration
key
- The configuration key.defaultValue
- The default value.
java.lang.ClassCastException
- is thrown if the key maps to an
object that is not a Boolean.public java.lang.Boolean getBoolean(java.lang.String key, java.lang.Boolean defaultValue)
getBoolean
in interface Configuration
key
- The configuration key.defaultValue
- The default value.
java.lang.ClassCastException
- is thrown if the key maps to an
object that is not a Boolean.public byte getByte(java.lang.String key)
getByte
in interface Configuration
key
- The configuration key.
java.util.NoSuchElementException
- is thrown if the key doesn't
map to an existing object.
java.lang.ClassCastException
- is thrown if the key maps to an
object that is not a Byte.
java.lang.NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public byte getByte(java.lang.String key, byte defaultValue)
getByte
in interface Configuration
key
- The configuration key.defaultValue
- The default value.
java.lang.ClassCastException
- is thrown if the key maps to an
object that is not a Byte.
java.lang.NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public java.lang.Byte getByte(java.lang.String key, java.lang.Byte defaultValue)
getByte
in interface Configuration
key
- The configuration key.defaultValue
- The default value.
java.lang.ClassCastException
- is thrown if the key maps to an object that
is not a Byte.
java.lang.NumberFormatException
- is thrown if the value mapped by the key
has not a valid number format.public double getDouble(java.lang.String key)
getDouble
in interface Configuration
key
- The configuration key.
java.util.NoSuchElementException
- is thrown if the key doesn't
map to an existing object.
java.lang.ClassCastException
- is thrown if the key maps to an
object that is not a Double.
java.lang.NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public double getDouble(java.lang.String key, double defaultValue)
getDouble
in interface Configuration
key
- The configuration key.defaultValue
- The default value.
java.lang.ClassCastException
- is thrown if the key maps to an
object that is not a Double.
java.lang.NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public java.lang.Double getDouble(java.lang.String key, java.lang.Double defaultValue)
getDouble
in interface Configuration
key
- The configuration key.defaultValue
- The default value.
java.lang.ClassCastException
- is thrown if the key maps to an
object that is not a Double.
java.lang.NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public float getFloat(java.lang.String key, float defaultValue)
getFloat
in interface Configuration
key
- The configuration key.defaultValue
- The default value.
java.lang.ClassCastException
- is thrown if the key maps to an
object that is not a Float.
java.lang.NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public java.lang.Float getFloat(java.lang.String key, java.lang.Float defaultValue)
getFloat
in interface Configuration
key
- The configuration key.defaultValue
- The default value.
java.lang.ClassCastException
- is thrown if the key maps to an
object that is not a Float.
java.lang.NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public int getInt(java.lang.String key)
getInt
in interface Configuration
key
- The configuration key.
java.util.NoSuchElementException
- is thrown if the key doesn't
map to an existing object.
java.lang.ClassCastException
- is thrown if the key maps to an
object that is not a Integer.
java.lang.NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public int getInt(java.lang.String key, int defaultValue)
getInt
in interface Configuration
key
- The configuration key.defaultValue
- The default value.
java.lang.ClassCastException
- is thrown if the key maps to an
object that is not a Integer.
java.lang.NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public java.lang.Integer getInteger(java.lang.String key, java.lang.Integer defaultValue)
getInteger
in interface Configuration
key
- The configuration key.defaultValue
- The default value.
java.lang.ClassCastException
- is thrown if the key maps to an object that
is not a Integer.
java.lang.NumberFormatException
- is thrown if the value mapped by the key
has not a valid number format.public long getLong(java.lang.String key)
getLong
in interface Configuration
key
- The configuration key.
java.util.NoSuchElementException
- is thrown if the key doesn't
map to an existing object.
java.lang.ClassCastException
- is thrown if the key maps to an
object that is not a Long.
java.lang.NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public long getLong(java.lang.String key, long defaultValue)
getLong
in interface Configuration
key
- The configuration key.defaultValue
- The default value.
java.lang.ClassCastException
- is thrown if the key maps to an
object that is not a Long.
java.lang.NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public java.lang.Long getLong(java.lang.String key, java.lang.Long defaultValue)
getLong
in interface Configuration
key
- The configuration key.defaultValue
- The default value.
java.lang.ClassCastException
- is thrown if the key maps to an
object that is not a Long.
java.lang.NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public short getShort(java.lang.String key)
getShort
in interface Configuration
key
- The configuration key.
java.util.NoSuchElementException
- is thrown if the key doesn't
map to an existing object.
java.lang.ClassCastException
- is thrown if the key maps to an
object that is not a Short.
java.lang.NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public short getShort(java.lang.String key, short defaultValue)
getShort
in interface Configuration
key
- The configuration key.defaultValue
- The default value.
java.lang.ClassCastException
- is thrown if the key maps to an
object that is not a Short.
java.lang.NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public java.lang.Short getShort(java.lang.String key, java.lang.Short defaultValue)
getShort
in interface Configuration
key
- The configuration key.defaultValue
- The default value.
java.lang.ClassCastException
- is thrown if the key maps to an
object that is not a Short.
java.lang.NumberFormatException
- is thrown if the value mapped
by the key has not a valid number format.public java.lang.String getString(java.lang.String key)
getString
in interface Configuration
key
- The configuration key.
java.lang.ClassCastException
- is thrown if the key maps to an object that
is not a String.public java.lang.String getString(java.lang.String key, java.lang.String defaultValue)
getString
in interface Configuration
key
- The configuration key.defaultValue
- The default value.
java.lang.ClassCastException
- is thrown if the key maps to an object that
is not a String.public java.lang.String[] getStringArray(java.lang.String key)
getStringArray
in interface Configuration
key
- The configuration key.
java.lang.ClassCastException
- is thrown if the key maps to an
object that is not a String/List of Strings.public java.util.List getList(java.lang.String key)
getList
in interface Configuration
key
- The configuration key.
java.lang.ClassCastException
- is thrown if the key maps to an
object that is not a List.public java.util.List getList(java.lang.String key, java.util.List defaultValue)
getList
in interface Configuration
key
- The configuration key.defaultValue
- The default value.
java.lang.ClassCastException
- is thrown if the key maps to an
object that is not a List.private Configuration getFirstMatchingConfig(java.lang.String key)
public Configuration getConfiguration(int index)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |