public class CachingHierarchyManager extends HierarchyManagerImpl implements NodeStateListener
HierarchyManager that caches paths of
 items.HierarchyManagerImpl.CycleDetector| Modifier and Type | Field and Description | 
|---|---|
| static int | DEFAULT_UPPER_LIMITDefault upper limit of cached states | 
provider, rootNodeId| Constructor and Description | 
|---|
| CachingHierarchyManager(NodeId rootNodeId,
                       ItemStateManager provider)Create a new instance of this class. | 
| Modifier and Type | Method and Description | 
|---|---|
| protected void | buildPath(PathBuilder builder,
         ItemState state,
         HierarchyManagerImpl.CycleDetector detector)Adds the path element of an item id to the path currently being built. | 
| void | enableConsistencyChecks(boolean enable)Enable or disable consistency checks in this instance. | 
| int | getDepth(ItemId id)Returns the depth of the specified item which is equivalent to
  getPath(id).getAncestorCount(). | 
| Name | getName(ItemId id)Returns the name of the specified item. | 
| Path | getPath(ItemId id)Returns the path to the given item. | 
| boolean | isAncestor(NodeId nodeId,
          ItemId itemId)Determines whether the node with the specified  nodeIdis an ancestor of the item denoted by the givenitemId. | 
| void | nodeAdded(NodeState state,
         Name name,
         int index,
         NodeId id)Called when a child node has been added | 
| void | nodeModified(NodeState modified)Called when a node has been modified, typically as a result of removal
 or addition of a child node. | 
| void | nodeRemoved(NodeState state,
           Name name,
           int index,
           NodeId id)Called when a child node has been removed | 
| void | nodesReplaced(NodeState state)Called when the children nodes were replaced by other nodes, typically
 as result of a reorder operation. | 
| protected void | pathResolved(ItemId id,
            PathBuilder builder) | 
| protected ItemId | resolvePath(Path path,
           int typesAllowed)Internal implementation of  HierarchyManagerImpl.resolvePath(Path)that will either
 resolve to a node or a property. | 
| void | stateCreated(ItemState created)Called when an  ItemStatehas successfully
 been created (i.e. | 
| void | stateDestroyed(ItemState destroyed)Called when an  ItemStatehas successfully been
 removed (i.e. | 
| void | stateDiscarded(ItemState discarded)Called when an  ItemStatehas been discarded (i.e. | 
| void | stateModified(ItemState modified)Called when an  ItemStatehas successfully
 been modified (i.e. | 
| String | toString()Dump contents of path map and elements included to a string. | 
getChildNodeEntry, getChildNodeEntry, getItemState, getName, getParentId, getParentIds, getRelativeDepth, getRootNodeId, getShareRelativeDepth, hasItemState, isShareAncestor, resolveNodePath, resolvePath, resolvePath, resolvePropertyPathpublic static final int DEFAULT_UPPER_LIMIT
public CachingHierarchyManager(NodeId rootNodeId, ItemStateManager provider)
rootNodeId - root node idprovider - item state managerpublic void enableConsistencyChecks(boolean enable)
enable - true to enable consistency checks;
               false to disableprotected ItemId resolvePath(Path path, int typesAllowed) throws javax.jcr.RepositoryException
HierarchyManagerImpl.resolvePath(Path) that will either
 resolve to a node or a property. Should be overridden by a subclass
 that can resolve an intermediate path into an ItemId. This
 subclass can then invoke HierarchyManagerImpl.resolvePath(org.apache.jackrabbit.spi.Path.Element[], int, ItemId, int)
 with a value of next greater than 1.resolvePath in class HierarchyManagerImplpath - path to resolvetypesAllowed - one of RETURN_ANY, RETURN_NODE
                     or RETURN_PROPERTYnulljavax.jcr.RepositoryException - if an error occursprotected void pathResolved(ItemId id, PathBuilder builder) throws MalformedPathException
HierarchyManagerImpl.resolvePath(org.apache.jackrabbit.spi.Path.Element[], int, ItemId, int).
 May be overridden by some subclass to process/cache intermediate state.pathResolved in class HierarchyManagerImplid - id of resolved itembuilder - path builder containing path resolvedMalformedPathException - if the path contained in builder
                                is malformedprotected void buildPath(PathBuilder builder, ItemState state, HierarchyManagerImpl.CycleDetector detector) throws ItemStateException, javax.jcr.RepositoryException
builder contains the path of state.
 
 Overridden method tries to find a mapping for the intermediate item
 state and add its path elements to the builder currently
 being used. If no mapping is found, the item is cached instead after
 the base implementation has been invoked.
buildPath in class HierarchyManagerImplbuilder - builder currently being usedstate - item to find path ofdetector - path cycle detectorItemStateExceptionjavax.jcr.RepositoryExceptionpublic Path getPath(ItemId id) throws javax.jcr.ItemNotFoundException, javax.jcr.RepositoryException
Overridden method simply checks whether we have an item matching the id and returns its path, otherwise calls base implementation.
getPath in interface HierarchyManagergetPath in class HierarchyManagerImpljavax.jcr.ItemNotFoundExceptionjavax.jcr.RepositoryExceptionpublic Name getName(ItemId id) throws javax.jcr.ItemNotFoundException, javax.jcr.RepositoryException
getName in interface HierarchyManagergetName in class HierarchyManagerImplid - id of item whose name should be returnedjavax.jcr.ItemNotFoundExceptionjavax.jcr.RepositoryExceptionpublic int getDepth(ItemId id) throws javax.jcr.ItemNotFoundException, javax.jcr.RepositoryException
getPath(id).getAncestorCount(). The depth reflects the
 absolute hierarchy level.getDepth in interface HierarchyManagergetDepth in class HierarchyManagerImplid - item idjavax.jcr.ItemNotFoundException - if the specified id does not
                               denote an existing item.javax.jcr.RepositoryException - if another error occurspublic boolean isAncestor(NodeId nodeId, ItemId itemId) throws javax.jcr.ItemNotFoundException, javax.jcr.RepositoryException
nodeId
 is an ancestor of the item denoted by the given itemId.
 This is equivalent to
 getPath(nodeId).isAncestorOf(getPath(itemId)).isAncestor in interface HierarchyManagerisAncestor in class HierarchyManagerImplnodeId - node iditemId - item idtrue if the node with the specified
         nodeId is an ancestor of the item denoted by the
         given itemId; false otherwisejavax.jcr.ItemNotFoundException - if any of the specified id's does not
                               denote an existing item.javax.jcr.RepositoryException - if another error occurspublic void stateCreated(ItemState created)
ItemState has successfully
 been created (i.e. its underlying persistent state was created).stateCreated in interface ItemStateListenercreated - the ItemState that has been 'created'public void stateModified(ItemState modified)
ItemState has successfully
 been modified (i.e. its underlying persistent state has changed).stateModified in interface ItemStateListenermodified - the ItemState that has been 'modified'public void nodeModified(NodeState modified)
 Please note, that this method is not called if
 ItemStateListener.stateModified(ItemState) was called.
 If path information is cached for modified, this iterates
 over all child nodes in the path map, evicting the ones that do not
 (longer) exist in the underlying NodeState.
nodeModified in interface NodeStateListenermodified - node state that changedpublic void stateDestroyed(ItemState destroyed)
ItemState has successfully been
 removed (i.e. its underlying persistent state has been destroyed).stateDestroyed in interface ItemStateListenerdestroyed - the ItemState that has been 'destroyed'public void stateDiscarded(ItemState discarded)
ItemState has been discarded (i.e. it has
 been rendered 'invalid').stateDiscarded in interface ItemStateListenerdiscarded - the ItemState that has been discardedItemState.discard()public void nodeAdded(NodeState state, Name name, int index, NodeId id)
nodeAdded in interface NodeStateListenerstate - node state that changedname - name of node that was addedindex - index of new nodeid - id of new nodepublic void nodesReplaced(NodeState state)
Iterate over all cached children of this state and verify each child's position.
nodesReplaced in interface NodeStateListenerstate - node state that changedpublic void nodeRemoved(NodeState state, Name name, int index, NodeId id)
nodeRemoved in interface NodeStateListenerstate - node state that changedname - name of node that was removedindex - index of removed nodeid - id of removed nodeCopyright © 2004-2020 The Apache Software Foundation. All Rights Reserved.