public interface ImmutableHierarchicalConfiguration extends ImmutableConfiguration
An interface for immutable hierarchical configurations.
There are some sources of configuration data that cannot be stored very well
in a flat configuration object (like BaseConfiguration
) because then
their structure is lost. A prominent example are XML documents.
This interface extends the basic ImmutableConfiguration
interface by
structured access to configuration properties. An ExpressionEngine
is
used to evaluate complex property keys and to map them to nodes of a
tree-like structure.
Modifier and Type | Method and Description |
---|---|
ExpressionEngine |
getExpressionEngine()
Returns the expression engine used by this configuration.
|
int |
getMaxIndex(String key)
Returns the maximum defined index for the given key.
|
String |
getRootElementName()
Returns the name of the root element of this configuration.
|
List<ImmutableHierarchicalConfiguration> |
immutableChildConfigurationsAt(String key)
Returns a list of immutable configurations for all direct child elements
of the node selected by the given key.
|
ImmutableHierarchicalConfiguration |
immutableConfigurationAt(String key)
Returns an immutable hierarchical configuration for the node specified by
the given key.
|
ImmutableHierarchicalConfiguration |
immutableConfigurationAt(String key,
boolean supportUpdates)
Returns an immutable hierarchical configuration object that wraps the
configuration node specified by the given key.
|
List<ImmutableHierarchicalConfiguration> |
immutableConfigurationsAt(String key)
Returns a list of immutable configurations for all configuration nodes selected
by the given key.
|
containsKey, get, get, getArray, getArray, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getCollection, getCollection, getDouble, getDouble, getDouble, getEncodedString, getEncodedString, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getKeys, getKeys, getList, getList, getList, getList, getLong, getLong, getLong, getProperties, getProperty, getShort, getShort, getShort, getString, getString, getStringArray, immutableSubset, isEmpty, size
ExpressionEngine getExpressionEngine()
int getMaxIndex(String key)
key
- the key to be checkedString getRootElementName()
immutableConfigurationsAt()
method. The exact
meaning of the string returned by this method is specific to a concrete
implementation. For instance, an XML configuration might return the name
of the document element.ImmutableHierarchicalConfiguration immutableConfigurationAt(String key, boolean supportUpdates)
Returns an immutable hierarchical 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
ImmutableConfiguration.immutableSubset(String)
method is that
immutableSubset()
supports arbitrary subsets of configuration nodes
while immutableConfigurationAt()
only returns a single sub tree.
Please refer to the documentation of the
SubnodeConfiguration
class to obtain further information
about subnode configurations and when they should be used.
key
- the key that selects the sub treesupportUpdates
- a flag whether the returned subnode configuration
should be able to handle updates of its parentImmutableHierarchicalConfiguration immutableConfigurationAt(String key)
immutableConfigurationAt(key,
<b>false</b>)
.key
- the key that selects the sub treeList<ImmutableHierarchicalConfiguration> immutableConfigurationsAt(String key)
ExpressionEngine
) and then create an immutable subnode
configuration for each returned node (like
immutableConfigurationAt(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 do
List<ImmutableHierarchicalConfiguration> fields = config.immutableConfigurationsAt("tables.table(0).fields.field"); for(Iterator<ImmutableHierarchicalConfiguration> it = fields.iterator(); it.hasNext();) { ImmutableHierarchicalConfiguration sub = 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"); ...
key
- the key for selecting the desired nodesList<ImmutableHierarchicalConfiguration> immutableChildConfigurationsAt(String key)
key
- the key for selecting the desired parent nodeCopyright © 2001–2020 The Apache Software Foundation. All rights reserved.