public final class TreeTraverser extends Object implements Iterable<javax.jcr.Node>
Utility class for traversing the Item
s of a JCR hierarchy rooted at a
specific Node
.
This class provides an Iterator
of JCR items either through its
implementation of Iterable
or through various static factory methods.
The iterators return its elements in pre-order. That is, each node occurs
before its child nodes are traversed. The order in which child nodes are
traversed is determined by the underlying JCR implementation. Generally the
order is not specified unless a Node
has orderable child nodes.
Whether a specific node is included is determined by an
inclusionPolicy
. Error occurring while traversing are delegated to
an errorHandler
.
Modifier and Type | Class and Description |
---|---|
static interface |
TreeTraverser.ErrorHandler
Error handler for handling
RepositoryException s occurring on
traversal. |
static interface |
TreeTraverser.InclusionPolicy<T extends javax.jcr.Item>
Inclusion policy to determine which items to include when traversing.
|
Constructor and Description |
---|
TreeTraverser(javax.jcr.Node root)
Create a new instance of a TreeTraverser rooted at
node . |
TreeTraverser(javax.jcr.Node root,
TreeTraverser.ErrorHandler errorHandler,
TreeTraverser.InclusionPolicy<? super javax.jcr.Node> inclusionPolicy)
Create a new instance of a TreeTraverser rooted at
node . |
Modifier and Type | Method and Description |
---|---|
Iterator<javax.jcr.Node> |
iterator()
Returns an iterator of
Node for this instance. |
static Iterator<javax.jcr.Node> |
nodeIterator(javax.jcr.Node root)
Create an iterator for the nodes of the sub-tree rooted at
root . |
static Iterator<javax.jcr.Node> |
nodeIterator(javax.jcr.Node root,
TreeTraverser.ErrorHandler errorHandler,
TreeTraverser.InclusionPolicy<? super javax.jcr.Node> inclusionPolicy)
Create an iterator for the nodes of the sub-tree rooted at
root . |
static Iterator<javax.jcr.Property> |
propertyIterator(Iterator<javax.jcr.Node> nodes)
Create an iterator of the properties for a given iterator of nodes.
|
static Iterator<javax.jcr.Property> |
propertyIterator(Iterator<javax.jcr.Node> nodes,
TreeTraverser.ErrorHandler errorHandler,
TreeTraverser.InclusionPolicy<? super javax.jcr.Property> inclusionPolicy)
Create an iterator of the properties for a given iterator of nodes.
|
static Iterator<javax.jcr.Property> |
propertyIterator(javax.jcr.Node root)
Create an iterator of the properties of all nodes of the sub-tree rooted
at
root . |
static Iterator<javax.jcr.Property> |
propertyIterator(javax.jcr.Node root,
TreeTraverser.ErrorHandler errorHandler,
TreeTraverser.InclusionPolicy<javax.jcr.Item> inclusionPolicy)
Create an iterator of the properties of all nodes of the sub-tree rooted
at
root . |
public TreeTraverser(javax.jcr.Node root, TreeTraverser.ErrorHandler errorHandler, TreeTraverser.InclusionPolicy<? super javax.jcr.Node> inclusionPolicy)
node
.root
- The root node of the sub-tree to traverseerrorHandler
- Handler for errors while traversinginclusionPolicy
- Inclusion policy to determine which nodes to
includepublic TreeTraverser(javax.jcr.Node root)
node
.root
- The root node of the sub-tree to traversepublic static Iterator<javax.jcr.Node> nodeIterator(javax.jcr.Node root, TreeTraverser.ErrorHandler errorHandler, TreeTraverser.InclusionPolicy<? super javax.jcr.Node> inclusionPolicy)
root
.root
- root node of the sub-tree to traverseerrorHandler
- handler for exceptions occurring on traversalinclusionPolicy
- inclusion policy to determine which nodes to
includeNode
public static Iterator<javax.jcr.Node> nodeIterator(javax.jcr.Node root)
root
. Exceptions occurring on traversal are ignored.root
- root node of the sub-tree to traverseNode
public static Iterator<javax.jcr.Property> propertyIterator(Iterator<javax.jcr.Node> nodes, TreeTraverser.ErrorHandler errorHandler, TreeTraverser.InclusionPolicy<? super javax.jcr.Property> inclusionPolicy)
n1
occurs before node n2
in the iterator of
nodes, then any property of n1
will occur before any
property of n2
.nodes
- nodes whose properties to chainerrorHandler
- handler for exceptions occurring on traversalinclusionPolicy
- inclusion policy to determine properties items to includeProperty
public static Iterator<javax.jcr.Property> propertyIterator(Iterator<javax.jcr.Node> nodes)
n1
occurs before node n2
in the iterator of
nodes, then any property of n1
will occur before any
property of n2
. Exceptions occurring on traversal are
ignored.nodes
- nodes whose properties to chainProperty
public static Iterator<javax.jcr.Property> propertyIterator(javax.jcr.Node root, TreeTraverser.ErrorHandler errorHandler, TreeTraverser.InclusionPolicy<javax.jcr.Item> inclusionPolicy)
root
.root
- root node of the sub-tree to traverseerrorHandler
- handler for exceptions occurring on traversalinclusionPolicy
- inclusion policy to determine which items to
includeProperty
public static Iterator<javax.jcr.Property> propertyIterator(javax.jcr.Node root)
root
. Exceptions occurring on traversal are ignored.root
- root node of the sub-tree to traverseProperty
public Iterator<javax.jcr.Node> iterator()
Node
for this instance.iterator
in interface Iterable<javax.jcr.Node>
TreeTraverser(Node, ErrorHandler, InclusionPolicy)
,
Iterable.iterator()
Copyright © 2004-2020 The Apache Software Foundation. All Rights Reserved.