Class ItemSequence
- java.lang.Object
-
- org.apache.jackrabbit.commons.flat.ItemSequence
-
- Direct Known Subclasses:
ItemSequence.NodeSequenceImpl,ItemSequence.PropertySequenceImpl
public abstract class ItemSequence extends Object
This class serves as main entry point for obtaining sequences of
Nodes andPropertys. It provides factory methods for creatingNodeSequences andPropertySequences.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.ErrorHandleris used to handle exceptions which occur while traversing the hierarchy.- See Also:
TreeTraverser,NodeSequence,PropertySequence,TreeManager
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classItemSequence.NodeSequenceImplprotected static classItemSequence.PropertySequenceImpl
-
Field Summary
Fields Modifier and Type Field Description protected booleanautoSaveprotected TreeTraverser.ErrorHandlererrorHandlerTheTreeTraverser.ErrorHandlerinstance used for handling exceptions occurring while traversing the hierarchy.protected Comparator<String>orderprotected Noderootprotected TreeManagertreeManagerTheTreeManagerinstance managing the mapping between the sequence view and the JCR hierarchy.
-
Constructor Summary
Constructors Modifier Constructor Description protectedItemSequence(TreeManager treeManager, TreeTraverser.ErrorHandler errorHandler)Create a newItemSequenceinstance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static NodeSequencecreateNodeSequence(TreeManager treeManager)Create a newNodeSequenceinstance.static NodeSequencecreateNodeSequence(TreeManager treeManager, TreeTraverser.ErrorHandler errorHandler)Create a newNodeSequenceinstance.static PropertySequencecreatePropertySequence(TreeManager treeManager)Create a newPropertySequenceinstance.static PropertySequencecreatePropertySequence(TreeManager treeManager, TreeTraverser.ErrorHandler errorHandler)Create a newPropertySequenceinstance.protected NodegetMinimal()Returns the node with the minimal key wrt.protected NodegetMinimal(Node node)Returns the node amongst the child nodes ofnodewhose key is minimal wrt.NodeSequencegetNodeSequence()Create a newNodeSequenceinstance with the same parameterization as this instance.protected abstract NodegetParent(String key)Returns the parent node for the given key.protected NodegetPredecessor(String key)Returns the predecessor node for the givenkey.protected NodegetPredecessor(Node node, String key)Returns the direct predecessor ofkeyamongstnode's child nodes wrt.PropertySequencegetPropertySequence()Create a newPropertySequenceinstance with the same parametrization as this instance.protected NodegetSuccessor(Node node, String key)Returns the successor node for the givenkey.protected voidrenamePath(Node node, String key)Rename the path of the node with the minimal key.
-
-
-
Field Detail
-
treeManager
protected final TreeManager treeManager
TheTreeManagerinstance managing the mapping between the sequence view and the JCR hierarchy.
-
errorHandler
protected final TreeTraverser.ErrorHandler errorHandler
TheTreeTraverser.ErrorHandlerinstance used for handling exceptions occurring while traversing the hierarchy.
-
root
protected final Node root
- See Also:
TreeManager.getRoot()
-
order
protected final Comparator<String> order
- See Also:
TreeManager.getOrder()
-
autoSave
protected final boolean autoSave
- See Also:
TreeManager.getAutoSave()
-
-
Constructor Detail
-
ItemSequence
protected ItemSequence(TreeManager treeManager, TreeTraverser.ErrorHandler errorHandler)
Create a newItemSequenceinstance.- Parameters:
treeManager- TheTreeManagerfor managing the mapping between the sequence view and the JCR hierarchy.errorHandler- TheTreeTraverser.ErrorHandlerfor handling exceptions occurring while traversing the hierarchy.- Throws:
IllegalArgumentException- If eithertreeManagerisnullorTreeManager.getRoot()returnnullorTreeManager.getOrder()returnnull.
-
-
Method Detail
-
createNodeSequence
public static NodeSequence createNodeSequence(TreeManager treeManager, TreeTraverser.ErrorHandler errorHandler)
Create a newNodeSequenceinstance.- Parameters:
treeManager- TheTreeManagerfor managing the mapping between the sequence view and the JCR hierarchy.errorHandler- TheTreeTraverser.ErrorHandlerfor handling exceptions occurring while- Returns:
-
createNodeSequence
public static NodeSequence createNodeSequence(TreeManager treeManager)
Create a newNodeSequenceinstance.- Parameters:
treeManager- TheTreeManagerfor managing the mapping between the sequence view and the JCR hierarchy.- Returns:
-
createPropertySequence
public static PropertySequence createPropertySequence(TreeManager treeManager, TreeTraverser.ErrorHandler errorHandler)
Create a newPropertySequenceinstance.- Parameters:
treeManager- TheTreeManagerfor managing the mapping between the sequence view and the JCR hierarchy.errorHandler- TheTreeTraverser.ErrorHandlerfor handling exceptions occurring while- Returns:
-
createPropertySequence
public static PropertySequence createPropertySequence(TreeManager treeManager)
Create a newPropertySequenceinstance.- Parameters:
treeManager- TheTreeManagerfor managing the mapping between the sequence view and the JCR hierarchy.- Returns:
-
getNodeSequence
public NodeSequence getNodeSequence()
Create a newNodeSequenceinstance with the same parameterization as this instance.- Returns:
-
getPropertySequence
public PropertySequence getPropertySequence()
Create a newPropertySequenceinstance with the same parametrization as this instance.- Returns:
-
getParent
protected abstract Node getParent(String key) throws RepositoryException
Returns the parent node for the given key. When the key is not present in this sequence already, the returned node is the node that would contain that key if it where present.- Throws:
RepositoryException
-
getPredecessor
protected final Node getPredecessor(String key) throws RepositoryException
Returns the predecessor node for the givenkey. That is the node whose key directly precedes the passedkeyin the order determined byTreeManager.getOrder(). There are two cases:- A node with the given
keyis mapped: then that node is returned. - A node with the given
keyis not mapped: the the node where that would contain that key if present is returned.
- Throws:
RepositoryException
- A node with the given
-
getPredecessor
protected final Node getPredecessor(Node node, String key) throws RepositoryException
Returns the direct predecessor ofkeyamongstnode's child nodes wrt. toTreeManager.getOrder(). Returnsnullif eithernodehas no child nodes ornodeis a leaf (seeTreeManager.isLeaf(Node)) orkeyis smaller than all the keys of all child nodes ofnode.- Throws:
RepositoryException
-
getSuccessor
protected final Node getSuccessor(Node node, String key) throws RepositoryException
Returns the successor node for the givenkey. That is the node whose key directly succeeds the passedkeyin the order determined byTreeManager.getOrder(). There are two cases:- A node with the given
keyis mapped: then that node is returned. - A node with the given
keyis not mapped: the the node where that would contain that key if present is returned.
- Throws:
RepositoryException
- A node with the given
-
getMinimal
protected final Node getMinimal() throws RepositoryException
Returns the node with the minimal key wrt.TreeManager.getOrder(). For the empty sequence this isTreeManager.getRoot().- Throws:
RepositoryException
-
getMinimal
protected final Node getMinimal(Node node) throws RepositoryException
Returns the node amongst the child nodes ofnodewhose key is minimal wrt.TreeManager.getOrder(). Returnsnullid eithernodehas no child nodes ornodeis a leaf (seeTreeManager.isLeaf(Node)).- Throws:
RepositoryException
-
renamePath
protected final void renamePath(Node node, String key) throws RepositoryException
Rename the path of the node with the minimal key. That is, assumingnodeis the node with the minimal key (seegetMinimal()), this method renames every segment of the path ofnodeup toTreeManager.getRoot()tokey. Note: Ifnodeis not the node with the minimal key, the behavior of this method is not specified.- Throws:
RepositoryException
-
-