public abstract class ItemSequence extends Object
This class serves as main entry point for obtaining sequences of Node
s and Property
s. It provides factory methods for creating
NodeSequence
s and PropertySequence
s.
NodeSequence and PropertySequence instances provide a flat representation of a JCR hierarchy rooted at a certain node. They allow iterating over all items, retrieving items by key, checking whether a given key is mapped, adding new items and removing existing items.
The specifics of the mapping from the flat representation to the JCR
hierarchy are delegated to a TreeManager
. Particularly the
TreeManager specifies the order of the items when retrieved as sequence and
when and how to add and remove intermediate nodes when new items are inserted
or removed.
An TreeTraverser.ErrorHandler
is used to handle exceptions which occur while
traversing the hierarchy.
TreeTraverser
,
NodeSequence
,
PropertySequence
,
TreeManager
Modifier and Type | Class and Description |
---|---|
protected static class |
ItemSequence.NodeSequenceImpl |
protected static class |
ItemSequence.PropertySequenceImpl |
Modifier and Type | Field and Description |
---|---|
protected boolean |
autoSave |
protected TreeTraverser.ErrorHandler |
errorHandler
The
TreeTraverser.ErrorHandler instance used for handling exceptions occurring
while traversing the hierarchy. |
protected Comparator<String> |
order |
protected Node |
root |
protected TreeManager |
treeManager
The
TreeManager instance managing the mapping between the
sequence view and the JCR hierarchy. |
Modifier | Constructor and Description |
---|---|
protected |
ItemSequence(TreeManager treeManager,
TreeTraverser.ErrorHandler errorHandler)
Create a new
ItemSequence instance. |
Modifier and Type | Method and Description |
---|---|
static NodeSequence |
createNodeSequence(TreeManager treeManager)
Create a new
NodeSequence instance. |
static NodeSequence |
createNodeSequence(TreeManager treeManager,
TreeTraverser.ErrorHandler errorHandler)
Create a new
NodeSequence instance. |
static PropertySequence |
createPropertySequence(TreeManager treeManager)
Create a new
PropertySequence instance. |
static PropertySequence |
createPropertySequence(TreeManager treeManager,
TreeTraverser.ErrorHandler errorHandler)
Create a new
PropertySequence instance. |
protected Node |
getMinimal()
Returns the node with the minimal key wrt.
|
protected Node |
getMinimal(Node node)
Returns the node amongst the child nodes of
node whose key
is minimal wrt. |
NodeSequence |
getNodeSequence()
Create a new
NodeSequence instance with the same parameterization
as this instance. |
protected abstract Node |
getParent(String key)
Returns the parent node for the given key.
|
protected Node |
getPredecessor(Node node,
String key)
Returns the direct predecessor of
key amongst
node 's child nodes wrt. |
protected Node |
getPredecessor(String key)
Returns the predecessor node for the given
key . |
PropertySequence |
getPropertySequence()
Create a new
PropertySequence instance with the same
parametrization as this instance. |
protected Node |
getSuccessor(Node node,
String key)
Returns the successor node for the given
key . |
protected void |
renamePath(Node node,
String key)
Rename the path of the node with the minimal key.
|
protected final TreeManager treeManager
TreeManager
instance managing the mapping between the
sequence view and the JCR hierarchy.protected final TreeTraverser.ErrorHandler errorHandler
TreeTraverser.ErrorHandler
instance used for handling exceptions occurring
while traversing the hierarchy.protected final Node root
TreeManager.getRoot()
protected final Comparator<String> order
TreeManager.getOrder()
protected final boolean autoSave
TreeManager.getAutoSave()
protected ItemSequence(TreeManager treeManager, TreeTraverser.ErrorHandler errorHandler)
ItemSequence
instance.treeManager
- The TreeManager
for managing the mapping
between the sequence view and the JCR hierarchy.errorHandler
- The TreeTraverser.ErrorHandler
for handling exceptions
occurring while traversing the hierarchy.IllegalArgumentException
- If either treeManager
is
null
or TreeManager.getRoot()
return
null
or TreeManager.getOrder()
return
null
.public static NodeSequence createNodeSequence(TreeManager treeManager, TreeTraverser.ErrorHandler errorHandler)
NodeSequence
instance.treeManager
- The TreeManager
for managing the mapping
between the sequence view and the JCR hierarchy.errorHandler
- The TreeTraverser.ErrorHandler
for handling exceptions
occurring whilepublic static NodeSequence createNodeSequence(TreeManager treeManager)
NodeSequence
instance.treeManager
- The TreeManager
for managing the mapping
between the sequence view and the JCR hierarchy.public static PropertySequence createPropertySequence(TreeManager treeManager, TreeTraverser.ErrorHandler errorHandler)
PropertySequence
instance.treeManager
- The TreeManager
for managing the mapping
between the sequence view and the JCR hierarchy.errorHandler
- The TreeTraverser.ErrorHandler
for handling exceptions
occurring whilepublic static PropertySequence createPropertySequence(TreeManager treeManager)
PropertySequence
instance.treeManager
- The TreeManager
for managing the mapping
between the sequence view and the JCR hierarchy.public NodeSequence getNodeSequence()
NodeSequence
instance with the same parameterization
as this instance.public PropertySequence getPropertySequence()
PropertySequence
instance with the same
parametrization as this instance.protected abstract Node getParent(String key) throws RepositoryException
RepositoryException
protected final Node getPredecessor(String key) throws RepositoryException
key
. That is the node
whose key directly precedes the passed key
in the order
determined by TreeManager.getOrder()
. There are two cases:
key
is mapped: then that node is
returned.key
is not mapped: the the node
where that would contain that key if present is returned.RepositoryException
protected final Node getPredecessor(Node node, String key) throws RepositoryException
key
amongst
node
's child nodes wrt. to TreeManager.getOrder()
.
Returns null
if either node
has no child nodes
or node
is a leaf (see TreeManager.isLeaf(Node)
) or
key
is smaller than all the keys of all child nodes of
node
.RepositoryException
protected final Node getSuccessor(Node node, String key) throws RepositoryException
key
. That is the node
whose key directly succeeds the passed key
in the order
determined by TreeManager.getOrder()
. There are two cases:
key
is mapped: then that node is
returned.key
is not mapped: the the node
where that would contain that key if present is returned.RepositoryException
protected final Node getMinimal() throws RepositoryException
TreeManager.getOrder()
.
For the empty sequence this is TreeManager.getRoot()
.RepositoryException
protected final Node getMinimal(Node node) throws RepositoryException
node
whose key
is minimal wrt. TreeManager.getOrder()
. Returns null
id either node
has no child nodes or node
is a
leaf (see TreeManager.isLeaf(Node)
).RepositoryException
protected final void renamePath(Node node, String key) throws RepositoryException
node
is the node with the minimal key (see
getMinimal()
), this method renames every segment of the path of
node
up to TreeManager.getRoot()
to key
. Note: If node
is not the node with the minimal
key, the behavior of this method is not specified.RepositoryException
Copyright © 2004–2022 The Apache Software Foundation. All rights reserved.