Class NodeHandlerDecorator<T>
java.lang.Object
org.apache.commons.configuration2.tree.NodeHandlerDecorator<T>
- Type Parameters:
T- the type of the nodes supported by this handler
- All Implemented Interfaces:
NodeHandler<T>
An abstract base class for decorators of a NodeHandler.
This class implements all methods of the NodeHandler interface by delegating to another instance. This is
convenient if specific functionality of a NodeHandler is to be adapted for a special use case. Concrete sub
classes have to implement the getDecoratedNodeHandler() method to provide the underlying handler.
- Since:
- 2.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAttributes(T node) Gets an unmodifiable set with the names of all attributes of the specified node.getAttributeValue(T node, String name) Gets the value of the specified attribute from the given node.Gets the child with the given index of the specified node.getChildren(T node) Gets an unmodifiable list with all children of the specified node.getChildren(T node, String name) Gets an unmodifiable list of all children of the specified node with the given name.intgetChildrenCount(T node, String name) Gets the number of children of the specified node with the given name.protected abstract NodeHandler<T> Gets theNodeHandlerobject that is decorated by this instance.getMatchingChildren(T node, NodeMatcher<C> matcher, C criterion) Gets an unmodifiable list of all children of the specified node which are matched by the passed inNodeMatcheragainst the provided criterion.<C> intgetMatchingChildrenCount(T node, NodeMatcher<C> matcher, C criterion) Gets the number of children of the specified node which are matched by the givenNodeMatcher.Gets the parent of the specified node.Gets the root node of the underlying hierarchy.Gets the value of the specified node.booleanhasAttributes(T node) Returns a flag whether the passed in node has any attributes.intindexOfChild(T parent, T child) Returns the index of the given child node in the list of children of its parent.booleanChecks whether the specified node is defined.Returns the name of the specified node
-
Constructor Details
-
NodeHandlerDecorator
public NodeHandlerDecorator()
-
-
Method Details
-
getAttributes
Description copied from interface:NodeHandlerGets an unmodifiable set with the names of all attributes of the specified node.- Specified by:
getAttributesin interfaceNodeHandler<T>- Parameters:
node- the node- Returns:
- a set with the names of all attributes of this node
-
getAttributeValue
Description copied from interface:NodeHandlerGets the value of the specified attribute from the given node. If a concreteNodeHandlersupports attributes with multiple values, result might be a collection.- Specified by:
getAttributeValuein interfaceNodeHandler<T>- Parameters:
node- the nodename- the name of the attribute- Returns:
- the value of this attribute
-
getChild
Description copied from interface:NodeHandlerGets the child with the given index of the specified node.- Specified by:
getChildin interfaceNodeHandler<T>- Parameters:
node- the nodeindex- the index (0-based)- Returns:
- the child with the given index
-
getChildren
Description copied from interface:NodeHandlerGets an unmodifiable list with all children of the specified node.- Specified by:
getChildrenin interfaceNodeHandler<T>- Parameters:
node- the node- Returns:
- a list with the child nodes of this node
-
getChildren
Description copied from interface:NodeHandlerGets an unmodifiable list of all children of the specified node with the given name.- Specified by:
getChildrenin interfaceNodeHandler<T>- Parameters:
node- the nodename- the name of the desired child nodes- Returns:
- a list with all children with the given name
-
getChildrenCount
Description copied from interface:NodeHandlerGets the number of children of the specified node with the given name. This method exists for performance reasons: for some node implementations it may be by far more efficient to count the children than to query a list of all children and determine its size. A concrete implementation can choose the most efficient way to determine the number of children. If a child name is passed in, only the children with this name are taken into account. If the name null is passed, the total number of children must be returned.- Specified by:
getChildrenCountin interfaceNodeHandler<T>- Parameters:
node- the nodename- the name of the children in question (can be null for all children)- Returns:
- the number of the selected children
-
getDecoratedNodeHandler
Gets theNodeHandlerobject that is decorated by this instance. All method calls are delegated to this object.- Returns:
- the decorated
NodeHandler
-
getMatchingChildren
Description copied from interface:NodeHandlerGets an unmodifiable list of all children of the specified node which are matched by the passed inNodeMatcheragainst the provided criterion. This method allows for advanced queries on a node's children.- Specified by:
getMatchingChildrenin interfaceNodeHandler<T>- Type Parameters:
C- the type of the criterion- Parameters:
node- the nodematcher- theNodeMatcherdefining filter criteriacriterion- the criterion to be matched against; this object is passed to theNodeMatcher- Returns:
- a list with all children matched by the matcher
-
getMatchingChildrenCount
Description copied from interface:NodeHandlerGets the number of children of the specified node which are matched by the givenNodeMatcher. This is a more generic version ofNodeHandler.getChildrenCount(Object, String). It allows checking for arbitrary filter conditions.- Specified by:
getMatchingChildrenCountin interfaceNodeHandler<T>- Type Parameters:
C- the type of the criterion- Parameters:
node- the nodematcher- theNodeMatchercriterion- the criterion to be passed to theNodeMatcher- Returns:
- the number of matched children
-
getParent
Description copied from interface:NodeHandlerGets the parent of the specified node.- Specified by:
getParentin interfaceNodeHandler<T>- Parameters:
node- the node- Returns:
- the parent node
-
getRootNode
Description copied from interface:NodeHandlerGets the root node of the underlying hierarchy.- Specified by:
getRootNodein interfaceNodeHandler<T>- Returns:
- the current root node
-
getValue
Description copied from interface:NodeHandlerGets the value of the specified node.- Specified by:
getValuein interfaceNodeHandler<T>- Parameters:
node- the node- Returns:
- the value of this node
-
hasAttributes
Description copied from interface:NodeHandlerReturns a flag whether the passed in node has any attributes.- Specified by:
hasAttributesin interfaceNodeHandler<T>- Parameters:
node- the node- Returns:
- a flag whether this node has any attributes
-
indexOfChild
Description copied from interface:NodeHandlerReturns the index of the given child node in the list of children of its parent. This method is the opposite operation ofNodeHandler.getChild(Object, int). This method returns 0 if the given node is the first child node with this name, 1 for the second child node and so on. If the node has no parent node or if it is an attribute, -1 is returned.- Specified by:
indexOfChildin interfaceNodeHandler<T>- Parameters:
parent- the parent nodechild- a child node whose index is to be retrieved- Returns:
- the index of this child node
-
isDefined
Description copied from interface:NodeHandlerChecks whether the specified node is defined. Nodes are "defined" if they contain any data, for example a value, or attributes, or defined children.- Specified by:
isDefinedin interfaceNodeHandler<T>- Parameters:
node- the node to test- Returns:
- a flag whether the passed in node is defined
-
nodeName
Description copied from interface:NodeHandlerReturns the name of the specified node- Specified by:
nodeNamein interfaceNodeHandler<T>- Parameters:
node- the node- Returns:
- the name of this node
-