Class DynamicCombinedConfiguration
- All Implemented Interfaces:
Cloneable
,Configuration
,EventListener<ConfigurationEvent>
,EventSource
,HierarchicalConfiguration<ImmutableNode>
,ImmutableConfiguration
,ImmutableHierarchicalConfiguration
,SynchronizerSupport
,InMemoryNodeModelSupport
,NodeKeyResolver<ImmutableNode>
,NodeModelSupport<ImmutableNode>
DynamicCombinedConfiguration allows a set of CombinedConfigurations to be used.
Each CombinedConfiguration is referenced by a key that is dynamically constructed from a key pattern on each call. The key pattern will be resolved using the configured ConfigurationInterpolator.
This Configuration implementation uses the configured Synchronizer
to guard itself against concurrent access.
If there are multiple threads accessing an instance concurrently, a fully functional Synchronizer
implementation (e.g. ReadWriteSynchronizer
) has to be used to ensure consistency and to avoid exceptions. The
Synchronizer
assigned to an instance is also passed to child configuration objects when they are created.
- Since:
- 1.6
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.commons.configuration2.BaseHierarchicalConfiguration
BaseHierarchicalConfiguration.BuilderVisitor
-
Field Summary
Fields inherited from class org.apache.commons.configuration2.CombinedConfiguration
COMBINED_INVALIDATE
-
Constructor Summary
ConstructorDescriptionCreates a new instance ofDynamicCombinedConfiguration
that uses a union combiner.Creates a new instance ofDynamicCombinedConfiguration
and initializes the combiner to be used. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConfiguration
(Configuration config, String name, String at) Adds a new configuration to this combined configuration.<T extends Event>
voidaddEventListener
(EventType<T> eventType, EventListener<? super T> listener) Adds an event listener for the specified event type.protected void
addNodesInternal
(String key, Collection<? extends ImmutableNode> nodes) Actually adds a collection of new nodes to this configuration.protected void
addPropertyInternal
(String key, Object value) Adds the property with the specified key.protected void
beginRead
(boolean optimize) Notifies this configuration'sSynchronizer
that a read operation is about to start.protected void
beginWrite
(boolean optimize) Notifies this configuration'sSynchronizer
that an update operation is about to start.void
Removes all registered error listeners.void
Removes all registered event listeners.protected void
Clears this configuration.protected void
Removes the property with the given key.protected Object
clearTreeInternal
(String key) Actually clears the tree of elements referenced by the given key.configurationAt
(String key) Returns a hierarchical subnode configuration for the node specified by the given key.configurationAt
(String key, boolean supportUpdates) Returns a hierarchical sub configuration object that wraps the configuration node specified by the given key.configurationsAt
(String key) Returns a list of sub configurations for all configuration nodes selected by the given key.protected boolean
Checks if the specified key is contained in this configuration.protected boolean
containsValueInternal
(Object value) Tests whether this configuration contains one or more matches to this value.protected void
endRead()
Notifies this configuration'sSynchronizer
that a read operation has finished.protected void
endWrite()
Notifies this configuration'sSynchronizer
that an update operation has finished.getBigDecimal
(String key) Gets aBigDecimal
associated with the given configuration key.getBigDecimal
(String key, BigDecimal defaultValue) Gets aBigDecimal
associated with the given configuration key.getBigInteger
(String key) Gets aBigInteger
associated with the given configuration key.getBigInteger
(String key, BigInteger defaultValue) Gets aBigInteger
associated with the given configuration key.boolean
getBoolean
(String key) Gets a boolean associated with the given configuration key.boolean
getBoolean
(String key, boolean defaultValue) Gets a boolean associated with the given configuration key.getBoolean
(String key, Boolean defaultValue) Obtains the value of the specified key and tries to convert it into aBoolean
object.byte
Gets a byte associated with the given configuration key.byte
Gets a byte associated with the given configuration key.Gets aByte
associated with the given configuration key.getConfiguration
(int index) Gets the configuration at the specified index.getConfiguration
(String name) Gets the configuration with the given name.Gets a set with the names of all configurations contained in this combined configuration.double
Gets a double associated with the given configuration key.double
Gets a double associated with the given configuration key.Gets aDouble
associated with the given configuration key.float
Gets a float associated with the given configuration key.float
Gets a float associated with the given configuration key.Gets aFloat
associated with the given configuration key.int
Gets a int associated with the given configuration key.int
Gets a int associated with the given configuration key.getInteger
(String key, Integer defaultValue) Gets anInteger
associated with the given configuration key.Gets an iterator with all keys defined in this configuration.getKeysInternal
(String prefix) Gets an iterator with all keys defined in this configuration that start with the given prefix.Gets a List of the values associated with the given configuration key.Gets a List of strings associated with the given configuration key.long
Gets a long associated with the given configuration key.long
Gets a long associated with the given configuration key.Gets aLong
associated with the given configuration key.protected int
Actually retrieves the maximum defined index for the given key.Gets the node combiner that is used for creating the combined node structure.int
Gets the number of configurations that are contained in this combined configuration.getProperties
(String key) Gets a list of properties associated with the given configuration key.protected Object
Fetches the specified property.short
Gets a short associated with the given configuration key.short
Gets a short associated with the given configuration key.Gets aShort
associated with the given configuration key.Gets the configuration source, in which the specified key is defined.Gets a string associated with the given configuration key.Gets a string associated with the given configuration key.String[]
getStringArray
(String key) Gets an array of strings associated with the given configuration key.Returns a configuration with the same content as this configuration, but with all variables replaced by their actual values.void
Invalidates the current combined configuration.void
protected boolean
Checks if this configuration is empty.removeConfiguration
(String name) Removes the configuration with the specified name.boolean
removeConfiguration
(Configuration config) Removes the specified configuration from this combined configuration.removeConfigurationAt
(int index) Removes the configuration at the specified index.<T extends Event>
booleanremoveEventListener
(EventType<T> eventType, EventListener<? super T> listener) Removes the event listener registration for the given event type and listener.void
setKeyPattern
(String pattern) void
setLoggerName
(String name) Sets the name of the Logger to use on each CombinedConfiguration.void
setNodeCombiner
(NodeCombiner nodeCombiner) Sets the node combiner.protected void
setPropertyInternal
(String key, Object value) Sets the value of the specified property.protected int
Actually calculates the size of this configuration.Creates a newConfiguration
object containing all keys that start with the specified prefix.Methods inherited from class org.apache.commons.configuration2.CombinedConfiguration
addConfiguration, addConfiguration, clone, getConfigurationNameList, getConfigurations, getConversionExpressionEngine, getSources, onEvent, setConversionExpressionEngine
Methods inherited from class org.apache.commons.configuration2.BaseHierarchicalConfiguration
childConfigurationsAt, childConfigurationsAt, cloneNodeModel, configurationsAt, createSubConfigurationForTrackedNode, getNodeModel, getSubConfigurationNodeSelector, getSubConfigurationParentModel, immutableChildConfigurationsAt, immutableConfigurationAt, immutableConfigurationAt, immutableConfigurationsAt, initSubConfigurationForThisParent, subnodeConfigurationChanged
Methods inherited from class org.apache.commons.configuration2.AbstractHierarchicalConfiguration
addNodes, addPropertyDirect, clearTree, fetchNodeList, getExpressionEngine, getMaxIndex, getModel, getRootElementName, getRootElementNameInternal, nodeDefined, nodeKey, resolveAddKey, resolveKey, resolveNodeKey, resolveUpdateKey, setExpressionEngine, toString
Methods inherited from class org.apache.commons.configuration2.AbstractConfiguration
addErrorLogListener, addProperty, append, clear, clearProperty, cloneInterpolator, contains, containsKey, containsValue, copy, get, get, getArray, getArray, getCollection, getCollection, getConfigurationDecoder, getConversionHandler, getDuration, getDuration, getEncodedString, getEncodedString, getInterpolator, getKeys, getKeys, getKeys, getKeysInternal, getList, getList, getListDelimiterHandler, getLogger, getProperties, getProperty, getSynchronizer, immutableSubset, initLogger, installInterpolator, interpolate, interpolate, isEmpty, isScalarValue, isThrowExceptionOnMissing, lock, setConfigurationDecoder, setConversionHandler, setDefaultLookups, setInterpolator, setListDelimiterHandler, setLogger, setParentInterpolator, setPrefixLookups, setProperty, setSynchronizer, setThrowExceptionOnMissing, size, unlock
Methods inherited from class org.apache.commons.configuration2.event.BaseEventSource
copyEventListeners, createErrorEvent, createEvent, fireError, fireEvent, getEventListenerRegistrations, getEventListeners, isDetailEvents, setDetailEvents
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.commons.configuration2.Configuration
addProperty, clear, clearProperty, getInterpolator, installInterpolator, setInterpolator, setProperty
Methods inherited from interface org.apache.commons.configuration2.ImmutableConfiguration
containsKey, containsValue, get, get, getArray, getArray, getCollection, getCollection, getDuration, getDuration, getEncodedString, getEncodedString, getEnum, getEnum, getKeys, getKeys, getKeys, getList, getList, getProperty, immutableSubset, isEmpty, size
Methods inherited from interface org.apache.commons.configuration2.sync.SynchronizerSupport
getSynchronizer, lock, setSynchronizer, unlock
-
Constructor Details
-
DynamicCombinedConfiguration
public DynamicCombinedConfiguration()Creates a new instance ofDynamicCombinedConfiguration
that uses a union combiner.- See Also:
-
DynamicCombinedConfiguration
Creates a new instance ofDynamicCombinedConfiguration
and initializes the combiner to be used.- Parameters:
comb
- the node combiner (can be null, then a union combiner is used as default)
-
-
Method Details
-
addConfiguration
Adds a new configuration to this combined configuration. It is possible (but not mandatory) to give the new configuration a name. This name must be unique, otherwise aConfigurationRuntimeException
will be thrown. With the optionalat
argument you can specify where in the resulting node structure the content of the added configuration should appear. This is a string that uses dots as property delimiters (independent on the current expression engine). For instance if you pass in the string"database.tables"
, all properties of the added configuration will occur in this branch.- Overrides:
addConfiguration
in classCombinedConfiguration
- Parameters:
config
- the configuration to add (must not be null)name
- the name of this configuration (can be null)at
- the position of this configuration in the combined tree (can be null)
-
addEventListener
public <T extends Event> void addEventListener(EventType<T> eventType, EventListener<? super T> listener) Description copied from interface:EventSource
Adds an event listener for the specified event type. This listener is notified about events of this type and all its sub types.- Specified by:
addEventListener
in interfaceEventSource
- Overrides:
addEventListener
in classBaseEventSource
- Type Parameters:
T
- the type of events processed by this listener- Parameters:
eventType
- the event type (must not be null)listener
- the listener to be registered (must not be null)
-
addNodesInternal
Description copied from class:AbstractHierarchicalConfiguration
Actually adds a collection of new nodes to this configuration. This method is called byaddNodes()
. It can be overridden by subclasses that need to adapt this operation.- Overrides:
addNodesInternal
in classAbstractHierarchicalConfiguration<ImmutableNode>
- Parameters:
key
- the key where the nodes are to be added; can be null, then they are added to the root nodenodes
- a collection with theNode
objects to be added
-
addPropertyInternal
Description copied from class:AbstractHierarchicalConfiguration
Adds the property with the specified key. This task will be delegated to the associatedExpressionEngine
, so the passed in key must match the requirements of this implementation.- Overrides:
addPropertyInternal
in classAbstractHierarchicalConfiguration<ImmutableNode>
- Parameters:
key
- the key of the new propertyvalue
- the value of the new property
-
beginRead
Notifies this configuration'sSynchronizer
that a read operation is about to start. This method is called by all methods which access this configuration in a read-only mode. Subclasses may override it to perform additional actions before this read operation. The boolean optimize argument can be evaluated by overridden methods in derived classes. Some operations which require a lock do not need a fully initialized configuration object. By setting this flag to true, such operations can give a corresponding hint. An overridden implementation ofbeginRead()
can then decide to skip some initialization steps. All basic operations in this class (and most of the basicConfiguration
implementations) call this method with a parameter value of false. In any case the inherited method must be called! Otherwise, proper synchronization is not guaranteed. This implementation checks whether a combined root node is available. If not, it is constructed by requesting a write lock. This implementation ensures that the current configuration is initialized. The lock counter is increased.- Overrides:
beginRead
in classCombinedConfiguration
- Parameters:
optimize
- a flag whether optimization can be performed
-
beginWrite
Notifies this configuration'sSynchronizer
that an update operation is about to start. This method is called by all methods which modify this configuration. Subclasses may override it to perform additional operations before an update. For a description of the boolean optimize argument refer to the documentation ofbeginRead()
. In any case the inherited method must be called! Otherwise, proper synchronization is not guaranteed. This implementation checks whether a combined root node is available. If not, it is constructed now. This implementation ensures that the current configuration is initialized. If necessary, a new child configuration instance is created.- Overrides:
beginWrite
in classCombinedConfiguration
- Parameters:
optimize
- a flag whether optimization can be performed- See Also:
-
clearErrorListeners
Description copied from class:BaseEventSource
Removes all registered error listeners.- Overrides:
clearErrorListeners
in classBaseEventSource
-
clearEventListeners
Description copied from class:BaseEventSource
Removes all registered event listeners.- Overrides:
clearEventListeners
in classBaseEventSource
-
clearInternal
Description copied from class:CombinedConfiguration
Clears this configuration. All contained configurations will be removed.- Overrides:
clearInternal
in classCombinedConfiguration
-
clearPropertyDirect
Description copied from class:AbstractHierarchicalConfiguration
Removes the property with the given key. Properties with names that start with the given key (i.e. properties below the specified key in the hierarchy) won't be affected. This implementation delegates to the node+ model.- Overrides:
clearPropertyDirect
in classAbstractHierarchicalConfiguration<ImmutableNode>
- Parameters:
key
- the key of the property to be removed
-
clearTreeInternal
Description copied from class:AbstractHierarchicalConfiguration
Actually clears the tree of elements referenced by the given key. This method is called byclearTree()
. Subclasses that need to adapt this operation can override this method. This base implementation delegates to the node model.- Overrides:
clearTreeInternal
in classAbstractHierarchicalConfiguration<ImmutableNode>
- Parameters:
key
- the key of the property to be removed- Returns:
- an object with information about the nodes that have been removed (this is needed for firing a meaningful event of type CLEAR_TREE)
-
configurationAt
Description copied from class:BaseHierarchicalConfiguration
Returns a hierarchical subnode configuration for the node specified by the given key. This is a short form forconfigurationAt(key, <b>false</b>)
. This is a short form forconfigurationAt(key, <b>false</b>)
.- Specified by:
configurationAt
in interfaceHierarchicalConfiguration<ImmutableNode>
- Overrides:
configurationAt
in classBaseHierarchicalConfiguration
- Parameters:
key
- the key that selects the sub tree- Returns:
- a hierarchical configuration that contains this sub tree
- See Also:
-
configurationAt
Description copied from class:BaseHierarchicalConfiguration
Returns a hierarchical sub configuration object that wraps the configuration node specified by the given key. This method provides an easy means of accessing sub trees of a hierarchical configuration. In the returned configuration the sub tree can directly be accessed, it becomes the root node of this configuration. Because of this the passed in key must select exactly one configuration node; otherwise an
IllegalArgumentException
will be thrown.The difference between this method and the
Configuration.subset(String)
method is thatsubset()
supports arbitrary subsets of configuration nodes whileconfigurationAt()
only returns a single sub tree. Please refer to the documentation of theSubnodeConfiguration
class to obtain further information about sub configurations and when they should be used.With the
The result of this implementation depends on thesupportUpdate
flag the behavior of the returned sub configuration regarding updates of its parent configuration can be determined. If set to false, the configurations return on independent nodes structures. So changes made on one configuration cannot be seen by the other one. A value of true in contrast creates a direct connection between both configurations - they are then using the same underlying data structures as much as possible. There are however changes which break this connection; for instance, if the sub tree the sub configuration belongs to is completely removed from the parent configuration. If such a change happens, the sub configuration becomes detached from its parent. It can still be used in a normal way, but changes on it are not reflected by the parent and vice verse. Also, it is not possible to reattach a once detached sub configuration.supportUpdates
flag: If it is false, a plainBaseHierarchicalConfiguration
is returned using the selected node as root node. This is suitable for read-only access to properties. Because the configuration returned in this case is not connected to the parent configuration, updates on properties made by one configuration are not reflected by the other one. A value of true for this parameter causes a tracked node to be created, and result is aSubnodeConfiguration
based on this tracked node. This configuration is really connected to its parent, so that updated properties are visible on both.- Specified by:
configurationAt
in interfaceHierarchicalConfiguration<ImmutableNode>
- Overrides:
configurationAt
in classBaseHierarchicalConfiguration
- Parameters:
key
- the key that selects the sub treesupportUpdates
- a flag whether the returned sub configuration should be directly connected to its parent- Returns:
- a hierarchical configuration that contains this sub tree
- See Also:
-
configurationsAt
Description copied from class:BaseHierarchicalConfiguration
Returns a list of sub configurations for all configuration nodes selected by the given key. This method will evaluate the passed in key (using the currentExpressionEngine
) and then create a sub configuration for each returned node (likeHierarchicalConfiguration.configurationAt(String)
). This is especially useful when dealing with list-like structures. As an example consider the configuration that contains data about database tables and their fields. If you need access to all fields of a certain table, you can simply doList fields = config.configurationsAt("tables.table(0).fields.field"); for(Iterator it = fields.iterator(); it.hasNext();) { BaseHierarchicalConfiguration sub = (BaseHierarchicalConfiguration) it.next(); // now the children and attributes of the field node can be // directly accessed String fieldName = sub.getString("name"); String fieldType = sub.getString("type"); ...
The configuration objects returned are not connected to the parent configuration. This implementation creates sub configurations in the same way as described forBaseHierarchicalConfiguration.configurationAt(String)
.- Specified by:
configurationsAt
in interfaceHierarchicalConfiguration<ImmutableNode>
- Overrides:
configurationsAt
in classBaseHierarchicalConfiguration
- Parameters:
key
- the key for selecting the desired nodes- Returns:
- a list with hierarchical configuration objects; each configuration represents one of the nodes selected by the passed in key
-
containsKeyInternal
Description copied from class:AbstractHierarchicalConfiguration
Checks if the specified key is contained in this configuration. Note that for this configuration the term "contained" means that the key has an associated value. If there is a node for this key that has no value but children (either defined or undefined), this method will still return false .- Overrides:
containsKeyInternal
in classAbstractHierarchicalConfiguration<ImmutableNode>
- Parameters:
key
- the key to be checked- Returns:
- a flag if this key is contained in this configuration
-
containsValueInternal
Tests whether this configuration contains one or more matches to this value. This operation stops at first match but may be more expensive than the containsKey method.- Overrides:
containsValueInternal
in classAbstractHierarchicalConfiguration<ImmutableNode>
- Parameters:
value
- the value in question- Returns:
true
if and only if some key maps to thevalue
argument in this configuration as determined by theequals
method;false
otherwise.- Since:
- 2.11.0
-
endRead
Notifies this configuration'sSynchronizer
that a read operation has finished. This method is called by all methods which access this configuration in a read-only manner at the end of their execution. Subclasses may override it to perform additional actions after this read operation. In any case the inherited method must be called! Otherwise, the read lock will not be released. This implementation clears the current configuration if necessary.- Overrides:
endRead
in classAbstractConfiguration
-
endWrite
Notifies this configuration'sSynchronizer
that an update operation has finished. This method is called by all methods which modify this configuration at the end of their execution. Subclasses may override it to perform additional operations after an update. In any case the inherited method must be called! Otherwise, the write lock will not be released. This implementation clears the current configuration if necessary.- Overrides:
endWrite
in classAbstractConfiguration
-
getBigDecimal
Description copied from class:AbstractConfiguration
Gets aBigDecimal
associated with the given configuration key.- Specified by:
getBigDecimal
in interfaceImmutableConfiguration
- Overrides:
getBigDecimal
in classAbstractConfiguration
- Parameters:
key
- The configuration key.- Returns:
- The associated BigDecimal if key is found and has valid format
- See Also:
-
getBigDecimal
Description copied from interface:ImmutableConfiguration
Gets aBigDecimal
associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.- Specified by:
getBigDecimal
in interfaceImmutableConfiguration
- Overrides:
getBigDecimal
in classAbstractConfiguration
- Parameters:
key
- The configuration key.defaultValue
- The default value.- Returns:
- The associated BigDecimal if key is found and has valid format, default value otherwise.
-
getBigInteger
Description copied from class:AbstractConfiguration
Gets aBigInteger
associated with the given configuration key.- Specified by:
getBigInteger
in interfaceImmutableConfiguration
- Overrides:
getBigInteger
in classAbstractConfiguration
- Parameters:
key
- The configuration key.- Returns:
- The associated BigInteger if key is found and has valid format
- See Also:
-
getBigInteger
Description copied from interface:ImmutableConfiguration
Gets aBigInteger
associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.- Specified by:
getBigInteger
in interfaceImmutableConfiguration
- Overrides:
getBigInteger
in classAbstractConfiguration
- Parameters:
key
- The configuration key.defaultValue
- The default value.- Returns:
- The associated BigInteger if key is found and has valid format, default value otherwise.
-
getBoolean
Description copied from interface:ImmutableConfiguration
Gets a boolean associated with the given configuration key.- Specified by:
getBoolean
in interfaceImmutableConfiguration
- Overrides:
getBoolean
in classAbstractConfiguration
- Parameters:
key
- The configuration key.- Returns:
- The associated boolean.
-
getBoolean
Description copied from interface:ImmutableConfiguration
Gets a boolean associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.- Specified by:
getBoolean
in interfaceImmutableConfiguration
- Overrides:
getBoolean
in classAbstractConfiguration
- Parameters:
key
- The configuration key.defaultValue
- The default value.- Returns:
- The associated boolean.
-
getBoolean
Description copied from class:AbstractConfiguration
Obtains the value of the specified key and tries to convert it into aBoolean
object. If the property has no value, the passed in default value will be used.- Specified by:
getBoolean
in interfaceImmutableConfiguration
- Overrides:
getBoolean
in classAbstractConfiguration
- Parameters:
key
- the key of the propertydefaultValue
- the default value- Returns:
- the value of this key converted to a
Boolean
-
getByte
Description copied from interface:ImmutableConfiguration
Gets a byte associated with the given configuration key.- Specified by:
getByte
in interfaceImmutableConfiguration
- Overrides:
getByte
in classAbstractConfiguration
- Parameters:
key
- The configuration key.- Returns:
- The associated byte.
-
getByte
Description copied from interface:ImmutableConfiguration
Gets a byte associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.- Specified by:
getByte
in interfaceImmutableConfiguration
- Overrides:
getByte
in classAbstractConfiguration
- Parameters:
key
- The configuration key.defaultValue
- The default value.- Returns:
- The associated byte.
-
getByte
Description copied from interface:ImmutableConfiguration
Gets aByte
associated with the given configuration key.- Specified by:
getByte
in interfaceImmutableConfiguration
- Overrides:
getByte
in classAbstractConfiguration
- Parameters:
key
- The configuration key.defaultValue
- The default value.- Returns:
- The associated byte if key is found and has valid format, default value otherwise.
-
getConfiguration
Gets the configuration at the specified index. The contained configurations are numbered in the order they were added to this combined configuration. The index of the first configuration is 0.- Overrides:
getConfiguration
in classCombinedConfiguration
- Parameters:
index
- the index- Returns:
- the configuration at this index
-
getConfiguration
Gets the configuration with the given name. This can be null if no such configuration exists.- Overrides:
getConfiguration
in classCombinedConfiguration
- Parameters:
name
- the name of the configuration- Returns:
- the configuration with this name
-
getConfigurationNames
Gets a set with the names of all configurations contained in this combined configuration. Of course here are only these configurations listed, for which a name was specified when they were added.- Overrides:
getConfigurationNames
in classCombinedConfiguration
- Returns:
- a set with the names of the contained configurations (never null)
-
getDouble
Description copied from interface:ImmutableConfiguration
Gets a double associated with the given configuration key.- Specified by:
getDouble
in interfaceImmutableConfiguration
- Overrides:
getDouble
in classAbstractConfiguration
- Parameters:
key
- The configuration key.- Returns:
- The associated double.
-
getDouble
Description copied from interface:ImmutableConfiguration
Gets a double associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.- Specified by:
getDouble
in interfaceImmutableConfiguration
- Overrides:
getDouble
in classAbstractConfiguration
- Parameters:
key
- The configuration key.defaultValue
- The default value.- Returns:
- The associated double.
-
getDouble
Description copied from interface:ImmutableConfiguration
Gets aDouble
associated with the given configuration key.- Specified by:
getDouble
in interfaceImmutableConfiguration
- Overrides:
getDouble
in classAbstractConfiguration
- Parameters:
key
- The configuration key.defaultValue
- The default value.- Returns:
- The associated double if key is found and has valid format, default value otherwise.
-
getFloat
Description copied from interface:ImmutableConfiguration
Gets a float associated with the given configuration key.- Specified by:
getFloat
in interfaceImmutableConfiguration
- Overrides:
getFloat
in classAbstractConfiguration
- Parameters:
key
- The configuration key.- Returns:
- The associated float.
-
getFloat
Description copied from interface:ImmutableConfiguration
Gets a float associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.- Specified by:
getFloat
in interfaceImmutableConfiguration
- Overrides:
getFloat
in classAbstractConfiguration
- Parameters:
key
- The configuration key.defaultValue
- The default value.- Returns:
- The associated float.
-
getFloat
Description copied from interface:ImmutableConfiguration
Gets aFloat
associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.- Specified by:
getFloat
in interfaceImmutableConfiguration
- Overrides:
getFloat
in classAbstractConfiguration
- Parameters:
key
- The configuration key.defaultValue
- The default value.- Returns:
- The associated float if key is found and has valid format, default value otherwise.
-
getInt
Description copied from interface:ImmutableConfiguration
Gets a int associated with the given configuration key.- Specified by:
getInt
in interfaceImmutableConfiguration
- Overrides:
getInt
in classAbstractConfiguration
- Parameters:
key
- The configuration key.- Returns:
- The associated int.
-
getInt
Description copied from interface:ImmutableConfiguration
Gets a int associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.- Specified by:
getInt
in interfaceImmutableConfiguration
- Overrides:
getInt
in classAbstractConfiguration
- Parameters:
key
- The configuration key.defaultValue
- The default value.- Returns:
- The associated int.
-
getInteger
Description copied from interface:ImmutableConfiguration
Gets anInteger
associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.- Specified by:
getInteger
in interfaceImmutableConfiguration
- Overrides:
getInteger
in classAbstractConfiguration
- Parameters:
key
- The configuration key.defaultValue
- The default value.- Returns:
- The associated int if key is found and has valid format, default value otherwise.
-
getKeyPattern
-
getKeysInternal
Description copied from class:AbstractHierarchicalConfiguration
Gets an iterator with all keys defined in this configuration. Note that the keys returned by this method will not contain any indices. This means that some structure will be lost.- Overrides:
getKeysInternal
in classAbstractHierarchicalConfiguration<ImmutableNode>
- Returns:
- an iterator with the defined keys in this configuration
-
getKeysInternal
Description copied from class:AbstractHierarchicalConfiguration
Gets an iterator with all keys defined in this configuration that start with the given prefix. The returned keys will not contain any indices. This implementation tries to locate a node whose key is the same as the passed in prefix. Then the subtree of this node is traversed, and the keys of all nodes encountered (including attributes) are added to the result set.- Overrides:
getKeysInternal
in classAbstractHierarchicalConfiguration<ImmutableNode>
- Parameters:
prefix
- the prefix of the keys to start with- Returns:
- an iterator with the found keys
-
getList
Description copied from class:AbstractConfiguration
Gets a List of the values associated with the given configuration key. This method is different from the genericgetList()
method in that it does not recursively obtain all values stored for the specified property key. Rather, only the first level of the hierarchy is processed. So the resulting list may contain complex objects like arrays or collections - depending on the storage structure used by a concrete subclass. If the key doesn't map to an existing object, an empty List is returned.- Specified by:
getList
in interfaceImmutableConfiguration
- Overrides:
getList
in classAbstractConfiguration
- Parameters:
key
- The configuration key.- Returns:
- The associated List.
- See Also:
-
getList
Description copied from interface:ImmutableConfiguration
Gets a List of strings associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.- Specified by:
getList
in interfaceImmutableConfiguration
- Overrides:
getList
in classAbstractConfiguration
- Parameters:
key
- The configuration key.defaultValue
- The default value.- Returns:
- The associated List of strings.
- See Also:
-
getLong
Description copied from interface:ImmutableConfiguration
Gets a long associated with the given configuration key.- Specified by:
getLong
in interfaceImmutableConfiguration
- Overrides:
getLong
in classAbstractConfiguration
- Parameters:
key
- The configuration key.- Returns:
- The associated long.
-
getLong
Description copied from interface:ImmutableConfiguration
Gets a long associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.- Specified by:
getLong
in interfaceImmutableConfiguration
- Overrides:
getLong
in classAbstractConfiguration
- Parameters:
key
- The configuration key.defaultValue
- The default value.- Returns:
- The associated long.
-
getLong
Description copied from interface:ImmutableConfiguration
Gets aLong
associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.- Specified by:
getLong
in interfaceImmutableConfiguration
- Overrides:
getLong
in classAbstractConfiguration
- Parameters:
key
- The configuration key.defaultValue
- The default value.- Returns:
- The associated long if key is found and has valid format, default value otherwise.
-
getMaxIndexInternal
Description copied from class:AbstractHierarchicalConfiguration
Actually retrieves the maximum defined index for the given key. This method is called bygetMaxIndex()
. Subclasses that need to adapt this operation have to override this method.- Overrides:
getMaxIndexInternal
in classAbstractHierarchicalConfiguration<ImmutableNode>
- Parameters:
key
- the key to be checked- Returns:
- the maximum defined index for this key
-
getNodeCombiner
Gets the node combiner that is used for creating the combined node structure.- Overrides:
getNodeCombiner
in classCombinedConfiguration
- Returns:
- the node combiner
-
getNumberOfConfigurations
Gets the number of configurations that are contained in this combined configuration.- Overrides:
getNumberOfConfigurations
in classCombinedConfiguration
- Returns:
- the number of contained configurations
-
getProperties
Description copied from interface:ImmutableConfiguration
Gets a list of properties associated with the given configuration key. This method expects the given key to have an arbitrary number of String values, each of which is of the formkey=value
. These strings are split at the equals sign, and the key parts will become keys of the returnedProperties
object, the value parts become values.- Specified by:
getProperties
in interfaceImmutableConfiguration
- Overrides:
getProperties
in classAbstractConfiguration
- Parameters:
key
- The configuration key.- Returns:
- The associated properties if key is found.
-
getPropertyInternal
Description copied from class:AbstractHierarchicalConfiguration
Fetches the specified property. This task is delegated to the associated expression engine.- Overrides:
getPropertyInternal
in classAbstractHierarchicalConfiguration<ImmutableNode>
- Parameters:
key
- the key to be looked up- Returns:
- the found value
-
getShort
Description copied from interface:ImmutableConfiguration
Gets a short associated with the given configuration key.- Specified by:
getShort
in interfaceImmutableConfiguration
- Overrides:
getShort
in classAbstractConfiguration
- Parameters:
key
- The configuration key.- Returns:
- The associated short.
-
getShort
Description copied from interface:ImmutableConfiguration
Gets a short associated with the given configuration key.- Specified by:
getShort
in interfaceImmutableConfiguration
- Overrides:
getShort
in classAbstractConfiguration
- Parameters:
key
- The configuration key.defaultValue
- The default value.- Returns:
- The associated short.
-
getShort
Description copied from interface:ImmutableConfiguration
Gets aShort
associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.- Specified by:
getShort
in interfaceImmutableConfiguration
- Overrides:
getShort
in classAbstractConfiguration
- Parameters:
key
- The configuration key.defaultValue
- The default value.- Returns:
- The associated short if key is found and has valid format, default value otherwise.
-
getSource
Gets the configuration source, in which the specified key is defined. This method will determine the configuration node that is identified by the given key. The following constellations are possible:- If no node object is found for this key, null is returned.
- If the key maps to multiple nodes belonging to different configuration sources, a
IllegalArgumentException
is thrown (in this case no unique source can be determined). - If exactly one node is found for the key, the (child) configuration object, to which the node belongs is determined and returned.
- For keys that have been added directly to this combined configuration and that do not belong to the namespaces defined by existing child configurations this configuration will be returned.
- Overrides:
getSource
in classCombinedConfiguration
- Parameters:
key
- the key of a configuration property- Returns:
- the configuration, to which this property belongs or null if the key cannot be resolved
- Throws:
IllegalArgumentException
- if the key maps to multiple properties and the source cannot be determined, or if the key is null
-
getString
Description copied from class:AbstractConfiguration
Gets a string associated with the given configuration key.- Specified by:
getString
in interfaceImmutableConfiguration
- Overrides:
getString
in classAbstractConfiguration
- Parameters:
key
- The configuration key.- Returns:
- The associated string.
- See Also:
-
getString
Description copied from interface:ImmutableConfiguration
Gets a string associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.- Specified by:
getString
in interfaceImmutableConfiguration
- Overrides:
getString
in classAbstractConfiguration
- Parameters:
key
- The configuration key.defaultValue
- The default value.- Returns:
- The associated string if key is found and has valid format, default value otherwise.
-
getStringArray
Description copied from class:AbstractConfiguration
Gets an array of strings associated with the given configuration key. If the key doesn't map to an existing object, an empty array is returned. When a property is added to a configuration, it is checked whether it contains multiple values. This is obvious if the added object is a list or an array. For strings the associationListDelimiterHandler
is consulted to find out whether the string can be split into multiple values.- Specified by:
getStringArray
in interfaceImmutableConfiguration
- Overrides:
getStringArray
in classAbstractConfiguration
- Parameters:
key
- The configuration key.- Returns:
- The associated string array if key is found.
- See Also:
-
interpolatedConfiguration
Description copied from class:BaseHierarchicalConfiguration
Returns a configuration with the same content as this configuration, but with all variables replaced by their actual values. This implementation is specific for hierarchical configurations. It clones the current configuration and runs a specialized visitor on the clone, which performs interpolation on the single configuration nodes.- Overrides:
interpolatedConfiguration
in classBaseHierarchicalConfiguration
- Returns:
- a configuration with all variables interpolated
-
invalidate
Invalidates the current combined configuration. This means that the next time a property is accessed the combined node structure must be re-constructed. Invalidation of a combined configuration also means that an event of typeEVENT_COMBINED_INVALIDATE
is fired. Note that while other events most times appear twice (once before and once after an update), this event is only fired once (after update).- Overrides:
invalidate
in classCombinedConfiguration
-
invalidateAll
-
isEmptyInternal
Description copied from class:AbstractHierarchicalConfiguration
Checks if this configuration is empty. Empty means that there are no keys with any values, though there can be some (empty) nodes.- Overrides:
isEmptyInternal
in classAbstractHierarchicalConfiguration<ImmutableNode>
- Returns:
- a flag if this configuration is empty
-
removeConfiguration
Removes the specified configuration from this combined configuration.- Overrides:
removeConfiguration
in classCombinedConfiguration
- Parameters:
config
- the configuration to be removed- Returns:
- a flag whether this configuration was found and could be removed
-
removeConfiguration
Removes the configuration with the specified name.- Overrides:
removeConfiguration
in classCombinedConfiguration
- Parameters:
name
- the name of the configuration to be removed- Returns:
- the removed configuration (null if this configuration was not found)
-
removeConfigurationAt
Removes the configuration at the specified index.- Overrides:
removeConfigurationAt
in classCombinedConfiguration
- Parameters:
index
- the index- Returns:
- the removed configuration
-
removeEventListener
public <T extends Event> boolean removeEventListener(EventType<T> eventType, EventListener<? super T> listener) Description copied from interface:EventSource
Removes the event listener registration for the given event type and listener. An event listener instance may be registered multiple times for different event types. Therefore, when removing a listener the event type of the registration in question has to be specified. The return value indicates whether a registration was removed. A value of false means that no such combination of event type and listener was found.- Specified by:
removeEventListener
in interfaceEventSource
- Overrides:
removeEventListener
in classBaseEventSource
- Type Parameters:
T
- the type of events processed by this listener- Parameters:
eventType
- the event typelistener
- the event listener to be removed- Returns:
- a flag whether a listener registration was removed
-
setKeyPattern
-
setLoggerName
Sets the name of the Logger to use on each CombinedConfiguration.- Parameters:
name
- The Logger name.
-
setNodeCombiner
Sets the node combiner. This object will be used when the combined node structure is to be constructed. It must not be null, otherwise anIllegalArgumentException
exception is thrown. Changing the node combiner causes an invalidation of this combined configuration, so that the new combiner immediately takes effect.- Overrides:
setNodeCombiner
in classCombinedConfiguration
- Parameters:
nodeCombiner
- the node combiner
-
setPropertyInternal
Description copied from class:AbstractHierarchicalConfiguration
Sets the value of the specified property.- Overrides:
setPropertyInternal
in classAbstractHierarchicalConfiguration<ImmutableNode>
- Parameters:
key
- the key of the property to setvalue
- the new value of this property
-
sizeInternal
Description copied from class:AbstractHierarchicalConfiguration
Actually calculates the size of this configuration. This method is called bysize()
with a read lock held. The base implementation provided here calculates the size based on the iterator returned bygetKeys()
. Sub classes which can determine the size in a more efficient way should override this method. This implementation is slightly more efficient than the default implementation. It does not iterate over the key set, but directly queries its size after it has been constructed. Note that constructing the key set is still an O(n) operation.- Overrides:
sizeInternal
in classAbstractHierarchicalConfiguration<ImmutableNode>
- Returns:
- the size of this configuration (i.e. the number of keys)
-
subset
Description copied from class:BaseHierarchicalConfiguration
Creates a newConfiguration
object containing all keys that start with the specified prefix. This implementation will return aBaseHierarchicalConfiguration
object so that the structure of the keys will be saved. The nodes selected by the prefix (it is possible that multiple nodes are selected) are mapped to the root node of the returned configuration, i.e. their children and attributes will become children and attributes of the new root node. However, a value of the root node is only set if exactly one of the selected nodes contain a value (if multiple nodes have a value, there is simply no way to decide how these values are merged together). Note that the returnedConfiguration
object is not connected to its source configuration: updates on the source configuration are not reflected in the subset and vice versa. The returned configuration uses the sameSynchronizer
as this configuration.- Specified by:
subset
in interfaceConfiguration
- Overrides:
subset
in classBaseHierarchicalConfiguration
- Parameters:
prefix
- the prefix of the keys for the subset- Returns:
- a new configuration object representing the selected subset
- See Also:
-