public class CompositeConfiguration extends AbstractConfiguration implements java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
private java.util.List |
configList
List holding all the configuration
|
private Configuration |
inMemoryConfiguration
Configuration that holds in memory stuff.
|
END_TOKEN, EVENT_ADD_PROPERTY, EVENT_CLEAR, EVENT_CLEAR_PROPERTY, EVENT_READ_PROPERTY, EVENT_SET_PROPERTY, START_TOKEN
Constructor and Description |
---|
CompositeConfiguration()
Creates an empty CompositeConfiguration object which can then
be added some other Configuration files
|
CompositeConfiguration(java.util.Collection configurations)
Create a CompositeConfiguration with an empty in memory configuration
and adds the collection of configurations specified.
|
CompositeConfiguration(Configuration inMemoryConfiguration)
Creates a CompositeConfiguration object with a specified in memory
configuration.
|
CompositeConfiguration(Configuration inMemoryConfiguration,
java.util.Collection configurations)
Creates a CompositeConfiguration with a specified in memory
configuration, and then adds the given collection of configurations.
|
Modifier and Type | Method and Description |
---|---|
void |
addConfiguration(Configuration config)
Add a configuration.
|
protected void |
addPropertyDirect(java.lang.String key,
java.lang.Object token)
Add this property to the inmemory Configuration.
|
void |
clear()
Remove all configuration reinitialize the in memory configuration.
|
protected void |
clearPropertyDirect(java.lang.String key)
Removes the specified property from this configuration.
|
java.lang.Object |
clone()
Returns a copy of this object.
|
boolean |
containsKey(java.lang.String key)
Check if the configuration contains the specified key.
|
Configuration |
getConfiguration(int index)
Return the configuration at the specified index.
|
Configuration |
getInMemoryConfiguration()
Returns the "in memory configuration".
|
java.util.Iterator |
getKeys()
Get the list of the keys contained in the configuration.
|
java.util.Iterator |
getKeys(java.lang.String key)
Get the list of the keys contained in the configuration that match the
specified prefix.
|
java.util.List |
getList(java.lang.String key,
java.util.List defaultValue)
Get a List of strings associated with the given configuration key.
|
int |
getNumberOfConfigurations()
Return the number of configurations.
|
java.lang.Object |
getProperty(java.lang.String key)
Read property from underlying composite
|
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)
Remove a configuration.
|
void |
setDelimiterParsingDisabled(boolean delimiterParsingDisabled)
Sets a flag whether added values for string properties should be checked
for the list delimiter.
|
void |
setListDelimiter(char listDelimiter)
Sets the character that is used as list delimiter.
|
addErrorLogListener, addProperty, clearProperty, createInterpolator, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDefaultListDelimiter, getDelimiter, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getInterpolator, getList, getListDelimiter, getLogger, getLong, getLong, getLong, getProperties, getProperties, getShort, getShort, getShort, getString, getString, getSubstitutor, interpolate, interpolate, interpolateHelper, isDelimiterParsingDisabled, isThrowExceptionOnMissing, resolveContainerStore, setDefaultListDelimiter, setDelimiter, setLogger, setProperty, setThrowExceptionOnMissing, subset
addConfigurationListener, addErrorListener, clearConfigurationListeners, clearErrorListeners, createErrorEvent, createEvent, fireError, fireEvent, getConfigurationListeners, getErrorListeners, isDetailEvents, removeConfigurationListener, removeErrorListener, setDetailEvents
private java.util.List configList
private Configuration inMemoryConfiguration
public CompositeConfiguration()
public CompositeConfiguration(Configuration inMemoryConfiguration)
inMemoryConfiguration
- the in memory configuration to usepublic CompositeConfiguration(java.util.Collection configurations)
configurations
- the collection of configurations to addpublic CompositeConfiguration(Configuration inMemoryConfiguration, java.util.Collection configurations)
inMemoryConfiguration
- the in memory configuration to useconfigurations
- the collection of configurations to addpublic void addConfiguration(Configuration config)
config
- the configuration to addpublic void removeConfiguration(Configuration config)
config
- The configuration to removepublic int getNumberOfConfigurations()
public void clear()
clear
in interface Configuration
clear
in class AbstractConfiguration
protected void addPropertyDirect(java.lang.String key, java.lang.Object token)
addPropertyDirect
in class AbstractConfiguration
key
- The Key to add the property to.token
- The Value to add.public java.lang.Object getProperty(java.lang.String key)
getProperty
in interface Configuration
key
- key to use for mappingpublic java.util.Iterator getKeys()
remove()
method is specific to
a concrete implementation. It may remove the corresponding
property from the configuration, but this is not guaranteed. In any case
it is no replacement for calling
Configuration.clearProperty(String)
for this property. So it is
highly recommended to avoid using the iterator's remove()
method.getKeys
in interface Configuration
getKeys
in class AbstractConfiguration
public java.util.Iterator getKeys(java.lang.String key)
getKeys
in interface Configuration
getKeys
in class AbstractConfiguration
key
- The prefix to test against.Configuration.getKeys()
public boolean isEmpty()
isEmpty
in interface Configuration
isEmpty
in class AbstractConfiguration
true
if the configuration contains no property,
false
otherwise.protected void clearPropertyDirect(java.lang.String key)
clearProperty()
after it has done some
preparations. It should be overriden in sub classes. This base
implementation is just left empty.clearPropertyDirect
in class AbstractConfiguration
key
- the key to be removedpublic boolean containsKey(java.lang.String key)
containsKey
in interface Configuration
containsKey
in class AbstractConfiguration
key
- the key whose presence in this configuration is to be testedtrue
if the configuration contains a value for this
key, false
otherwisepublic java.util.List getList(java.lang.String key, java.util.List defaultValue)
getList
in interface Configuration
getList
in class AbstractConfiguration
key
- The configuration key.defaultValue
- The default value.public java.lang.String[] getStringArray(java.lang.String key)
setListDelimiter()
method. If this is the case, the string
is splitted at these positions resulting in a property with multiple
values.getStringArray
in interface Configuration
getStringArray
in class AbstractConfiguration
key
- The configuration key.AbstractConfiguration.setListDelimiter(char)
,
AbstractConfiguration.setDelimiterParsingDisabled(boolean)
public Configuration getConfiguration(int index)
index
- The index of the configuration to retrievepublic Configuration getInMemoryConfiguration()
public java.lang.Object clone()
clone
in class EventSource
public void setDelimiterParsingDisabled(boolean delimiterParsingDisabled)
setDelimiterParsingDisabled
in class AbstractConfiguration
delimiterParsingDisabled
- the new value of the flagpublic void setListDelimiter(char listDelimiter)
setListDelimiter
in class AbstractConfiguration
listDelimiter
- the new list delimiter character