public abstract class ItemSequence extends Object
This class serves as main entry point for obtaining sequences of Node
s and Propertys. It provides factory methods for creating
NodeSequences and PropertySequences.
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 javax.jcr.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 javax.jcr.Node |
getMinimal()
Returns the node with the minimal key wrt.
|
protected javax.jcr.Node |
getMinimal(javax.jcr.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 javax.jcr.Node |
getParent(String key)
Returns the parent node for the given key.
|
protected javax.jcr.Node |
getPredecessor(javax.jcr.Node node,
String key)
Returns the direct predecessor of
key amongst
node's child nodes wrt. |
protected javax.jcr.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 javax.jcr.Node |
getSuccessor(javax.jcr.Node node,
String key)
Returns the successor node for the given
key. |
protected void |
renamePath(javax.jcr.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 javax.jcr.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 javax.jcr.Node getParent(String key) throws javax.jcr.RepositoryException
javax.jcr.RepositoryExceptionprotected final javax.jcr.Node getPredecessor(String key) throws javax.jcr.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.javax.jcr.RepositoryExceptionprotected final javax.jcr.Node getPredecessor(javax.jcr.Node node,
String key)
throws javax.jcr.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.javax.jcr.RepositoryExceptionprotected final javax.jcr.Node getSuccessor(javax.jcr.Node node,
String key)
throws javax.jcr.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.javax.jcr.RepositoryExceptionprotected final javax.jcr.Node getMinimal()
throws javax.jcr.RepositoryException
TreeManager.getOrder().
For the empty sequence this is TreeManager.getRoot().javax.jcr.RepositoryExceptionprotected final javax.jcr.Node getMinimal(javax.jcr.Node node)
throws javax.jcr.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)).javax.jcr.RepositoryExceptionprotected final void renamePath(javax.jcr.Node node,
String key)
throws javax.jcr.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.javax.jcr.RepositoryExceptionCopyright © 2004-2020 The Apache Software Foundation. All Rights Reserved.