T - the type of the nodes supported by this handlerpublic abstract class NodeHandlerDecorator<T> extends Object implements 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.
| Constructor and Description |
|---|
NodeHandlerDecorator() |
| Modifier and Type | Method and Description |
|---|---|
Set<String> |
getAttributes(T node)
Returns an unmodifiable set with the names of all attributes of the
specified node.
|
Object |
getAttributeValue(T node,
String name)
Returns the value of the specified attribute from the given node.
|
T |
getChild(T node,
int index)
Returns the child with the given index of the specified node.
|
List<T> |
getChildren(T node)
Returns an unmodifiable list with all children of the specified node.
|
List<T> |
getChildren(T node,
String name)
Returns an unmodifiable list of all children of the specified node with
the given name.
|
int |
getChildrenCount(T node,
String name)
Returns the number of children of the specified node with the given name.
|
protected abstract NodeHandler<T> |
getDecoratedNodeHandler()
Returns the
NodeHandler object that is decorated by this
instance. |
<C> List<T> |
getMatchingChildren(T node,
NodeMatcher<C> matcher,
C criterion)
Returns an unmodifiable list of all children of the specified node which
are matched by the passed in
NodeMatcher against the provided
criterion. |
<C> int |
getMatchingChildrenCount(T node,
NodeMatcher<C> matcher,
C criterion)
Returns the number of children of the specified node which are matched by
the given
NodeMatcher. |
T |
getParent(T node)
Returns the parent of the specified node.
|
T |
getRootNode()
Returns the root node of the underlying hierarchy.
|
Object |
getValue(T node)
Returns the value of the specified node.
|
boolean |
hasAttributes(T node)
Returns a flag whether the passed in node has any attributes.
|
int |
indexOfChild(T parent,
T child)
Returns the index of the given child node in the list of children of its
parent.
|
boolean |
isDefined(T node)
Checks whether the specified node is defined.
|
String |
nodeName(T node)
Returns the name of the specified node
|
public String nodeName(T node)
NodeHandlernodeName in interface NodeHandler<T>node - the nodepublic Object getValue(T node)
NodeHandlergetValue in interface NodeHandler<T>node - the nodepublic T getParent(T node)
NodeHandlergetParent in interface NodeHandler<T>node - the nodepublic List<T> getChildren(T node)
NodeHandlergetChildren in interface NodeHandler<T>node - the nodepublic <C> List<T> getMatchingChildren(T node, NodeMatcher<C> matcher, C criterion)
NodeHandlerNodeMatcher against the provided
criterion. This method allows for advanced queries on a node's children.getMatchingChildren in interface NodeHandler<T>C - the type of the criterionnode - the nodematcher - the NodeMatcher defining filter criteriacriterion - the criterion to be matched against; this object is
passed to the NodeMatcherpublic <C> int getMatchingChildrenCount(T node, NodeMatcher<C> matcher, C criterion)
NodeHandlerNodeMatcher. This is a more generic version of
NodeHandler.getChildrenCount(Object, String). It allows checking for
arbitrary filter conditions.getMatchingChildrenCount in interface NodeHandler<T>C - the type of the criterionnode - the nodematcher - the NodeMatchercriterion - the criterion to be passed to the NodeMatcherpublic List<T> getChildren(T node, String name)
NodeHandlergetChildren in interface NodeHandler<T>node - the nodename - the name of the desired child nodespublic T getChild(T node, int index)
NodeHandlergetChild in interface NodeHandler<T>node - the nodeindex - the index (0-based)public int indexOfChild(T parent, T child)
NodeHandlerNodeHandler.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.indexOfChild in interface NodeHandler<T>parent - the parent nodechild - a child node whose index is to be retrievedpublic int getChildrenCount(T node, String name)
NodeHandlergetChildrenCount in interface NodeHandler<T>node - the nodename - the name of the children in question (can be null for
all children)public Set<String> getAttributes(T node)
NodeHandlergetAttributes in interface NodeHandler<T>node - the nodepublic boolean hasAttributes(T node)
NodeHandlerhasAttributes in interface NodeHandler<T>node - the nodepublic Object getAttributeValue(T node, String name)
NodeHandlerNodeHandler supports attributes with multiple values,
result might be a collection.getAttributeValue in interface NodeHandler<T>node - the nodename - the name of the attributepublic boolean isDefined(T node)
NodeHandlerisDefined in interface NodeHandler<T>node - the node to testpublic T getRootNode()
NodeHandlergetRootNode in interface NodeHandler<T>protected abstract NodeHandler<T> getDecoratedNodeHandler()
NodeHandler object that is decorated by this
instance. All method calls are delegated to this object.NodeHandlerCopyright © 2001–2020 The Apache Software Foundation. All rights reserved.