A specialized hierarchical configuration class with a node model that uses a tracked node of another node model as its root node.
Configurations of this type are initialized with a special {@link NodeModel}operating on a specific tracked node of the parent configuration and the corresponding {@link NodeSelector}. All property accessor methods are evaluated relative to this root node. A good use case for a {@code SubnodeConfiguration} is when multiple properties from a specific subtree of the whole configuration need to be accessed. Then a {@code SubnodeConfiguration} can be created with the parent node of theaffected sub tree as root node. This allows for simpler property keys and is also more efficient.
By making use of a tracked node as root node, a {@code SubnodeConfiguration}and its parent configuration initially operate on the same hierarchy of configuration nodes. So if modifications are performed at the subnode configuration, these changes are immediately visible in the parent configuration. Analogously will updates of the parent configuration affect the {@code SubnodeConfiguration} if the sub tree spanned by the{@code SubnodeConfiguration}'s root node is involved.
Note that by making use of a {@code NodeSelector} the{@code SubnodeConfiguration} is not associated with a physical node instance,but the selection criteria stored in the selector are evaluated after each change of the nodes structure. As an example consider that the selector uses a key with an index into a list element, say index 2. Now if an update occurs on the underlying nodes structure which removes the first element in this list structure, the {@code SubnodeConfiguration} still references the elementwith index 2 which is now another one.
There are also possible changes of the underlying nodes structure which completely detach the {@code SubnodeConfiguration} from its parentconfiguration. For instance, the key referenced by the {@code SubnodeConfiguration} could be removed in the parent configuration. Ifthis happens, the {@code SubnodeConfiguration} stays functional; however, itnow operates on a separate node model than its parent configuration. Changes made by one configuration are no longer visible for the other one (as the node models have no longer overlapping nodes, there is no way to have a synchronization here).
When a subnode configuration is created, it inherits the settings of its parent configuration, e.g. some flags like the {@code throwExceptionOnMissing} flag or the settings for handling listdelimiters) or the expression engine. If these settings are changed later in either the subnode or the parent configuration, the changes are not visible for each other. So you could create a subnode configuration, and change its expression engine without affecting the parent configuration.
Because the {@code SubnodeConfiguration} operates on the same nodes structureas its parent it uses the same {@code Synchronizer} instance per default.This means that locks held on one {@code SubnodeConfiguration} also impactthe parent configuration and all of its other {@code SubnodeConfiguration}objects. You should not change this without a good reason! Otherwise, there is the risk of data corruption when multiple threads access these configuration concurrently.
From its purpose this class is quite similar to {@link SubsetConfiguration}. The difference is that a subset configuration of a hierarchical configuration may combine multiple configuration nodes from different sub trees of the configuration, while all nodes in a subnode configuration belong to the same sub tree. If an application can live with this limitation, it is recommended to use this class instead of {@code SubsetConfiguration} because creating asubset configuration is more expensive than creating a subnode configuration.
It is strongly recommended to create {@code SubnodeConfiguration} instancesonly through the {@code configurationAt()} methods of a hierarchicalconfiguration. These methods ensure that all necessary initializations are done. Creating instances manually without doing proper initialization may break some of the functionality provided by this class.
@since 1.3
@version $Id: SubnodeConfiguration.java 1624601 2014-09-12 18:04:36Z oheger $