public class HierarchyManagerImpl extends Object implements HierarchyManager
HierarchyManagerImpl
...Modifier and Type | Class and Description |
---|---|
protected static class |
HierarchyManagerImpl.CycleDetector
Utility class used to detect path cycles with as little overhead
as possible.
|
Modifier and Type | Field and Description |
---|---|
protected ItemStateManager |
provider |
protected NodeId |
rootNodeId |
Constructor and Description |
---|
HierarchyManagerImpl(NodeId rootNodeId,
ItemStateManager provider) |
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.
|
protected ChildNodeEntry |
getChildNodeEntry(NodeState parent,
Name name,
int index)
Returns the
ChildNodeEntry of parent with the
specified name and index or null
if there's no such entry. |
protected ChildNodeEntry |
getChildNodeEntry(NodeState parent,
NodeId id)
Returns the
ChildNodeEntry of parent with the
specified uuid or null if there's no such entry. |
int |
getDepth(ItemId id)
Returns the depth of the specified item which is equivalent to
getPath(id).getAncestorCount() . |
protected ItemState |
getItemState(ItemId id)
Return an item state, given its item id.
|
Name |
getName(ItemId itemId)
Returns the name of the specified item.
|
Name |
getName(NodeId id,
NodeId parentId)
Returns the name of the specified item, with the given parent id.
|
protected NodeId |
getParentId(ItemState state)
Returns the
parentUUID of the given item. |
protected Set<NodeId> |
getParentIds(ItemState state,
boolean useOverlayed)
Return all parents of a node.
|
Path |
getPath(ItemId id)
Returns the path to the given item.
|
int |
getRelativeDepth(NodeId ancestorId,
ItemId descendantId)
Returns the depth of the specified descendant relative to the given
ancestor.
|
NodeId |
getRootNodeId() |
int |
getShareRelativeDepth(NodeId ancestor,
ItemId descendant)
Returns the depth of the specified share-descendant relative to the given
share-ancestor.
|
protected boolean |
hasItemState(ItemId id)
Determines whether an item state for a given item id exists.
|
boolean |
isAncestor(NodeId nodeId,
ItemId itemId)
Determines whether the node with the specified
nodeId
is an ancestor of the item denoted by the given itemId . |
boolean |
isShareAncestor(NodeId ancestor,
NodeId descendant)
Determines whether the node with the specified
ancestor
is a share ancestor of the item denoted by the given descendant . |
protected void |
pathResolved(ItemId id,
PathBuilder builder)
|
NodeId |
resolveNodePath(Path path)
Resolves a path into a node id.
|
protected ItemId |
resolvePath(Path.Element[] elements,
int next,
ItemId id,
int typesAllowed)
Internal implementation that iteratively resolves a path into an item.
|
ItemId |
resolvePath(Path path)
Resolves a path into an item id.
|
protected ItemId |
resolvePath(Path path,
int typesAllowed)
Internal implementation of
resolvePath(Path) that will either
resolve to a node or a property. |
PropertyId |
resolvePropertyPath(Path path)
Resolves a path into a property id.
|
protected final NodeId rootNodeId
protected final ItemStateManager provider
public HierarchyManagerImpl(NodeId rootNodeId, ItemStateManager provider)
public NodeId getRootNodeId()
protected ItemId resolvePath(Path.Element[] elements, int next, ItemId id, int typesAllowed) throws ItemStateException, MalformedPathException
elements
- path elementsnext
- index of next item in elements
to inspectid
- id of item at path elements[0]
..elements[next - 1]
typesAllowed
- one of RETURN_ANY
, RETURN_NODE
or RETURN_PROPERTY
null
ItemStateException
- if an intermediate item state is not foundMalformedPathException
- if building an intermediate path failsprotected ItemState getItemState(ItemId id) throws NoSuchItemStateException, ItemStateException
Low-level hook provided for specialized derived classes.
id
- item idNoSuchItemStateException
- if the item does not existItemStateException
- if an error occursZombieHierarchyManager.getItemState(ItemId)
protected boolean hasItemState(ItemId id)
Low-level hook provided for specialized derived classes.
id
- item idtrue
if an item state exists, otherwise
false
ZombieHierarchyManager.hasItemState(ItemId)
protected NodeId getParentId(ItemState state)
parentUUID
of the given item.
Low-level hook provided for specialized derived classes.
state
- item stateparentUUID
of the given itemZombieHierarchyManager.getParentId(ItemState)
protected Set<NodeId> getParentIds(ItemState state, boolean useOverlayed)
state
- item stateuseOverlayed
- whether to use overlayed state for shareable nodesNodeId
s. If state has no parent,
array has length 0
.protected ChildNodeEntry getChildNodeEntry(NodeState parent, NodeId id)
ChildNodeEntry
of parent
with the
specified uuid
or null
if there's no such entry.
Low-level hook provided for specialized derived classes.
parent
- node stateid
- id of child node entryChildNodeEntry
of parent
with
the specified uuid
or null
if there's
no such entry.ZombieHierarchyManager.getChildNodeEntry(NodeState, NodeId)
protected ChildNodeEntry getChildNodeEntry(NodeState parent, Name name, int index)
ChildNodeEntry
of parent
with the
specified name
and index
or null
if there's no such entry.
Low-level hook provided for specialized derived classes.
parent
- node statename
- name of child node entryindex
- index of child node entryChildNodeEntry
of parent
with
the specified name
and index
or
null
if there's no such entry.ZombieHierarchyManager.getChildNodeEntry(NodeState, Name, int)
protected void buildPath(PathBuilder builder, ItemState state, HierarchyManagerImpl.CycleDetector detector) throws ItemStateException, javax.jcr.RepositoryException
builder
contains the path of state
.builder
- builder currently being usedstate
- item to find path ofdetector
- path cycle detectorItemStateException
javax.jcr.RepositoryException
protected ItemId resolvePath(Path path, int typesAllowed) throws javax.jcr.RepositoryException
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 resolvePath(org.apache.jackrabbit.spi.Path.Element[], int, ItemId, int)
with a value of next
greater than 1
.path
- path to resolvetypesAllowed
- one of RETURN_ANY
, RETURN_NODE
or RETURN_PROPERTY
null
javax.jcr.RepositoryException
- if an error occursprotected void pathResolved(ItemId id, PathBuilder builder) throws MalformedPathException
resolvePath(org.apache.jackrabbit.spi.Path.Element[], int, ItemId, int)
.
May be overridden by some subclass to process/cache intermediate state.id
- id of resolved itembuilder
- path builder containing path resolvedMalformedPathException
- if the path contained in builder
is malformedpublic final ItemId resolvePath(Path path) throws javax.jcr.RepositoryException
If there is both a node and a property at the specified path, this method will return the id of the node.
Note that, for performance reasons, this method returns null
rather than throwing a PathNotFoundException
if there's no
item to be found at path
.
resolvePath
in interface HierarchyManager
path
- path to resolvepath
or null
if there's no item at path
.javax.jcr.RepositoryException
- if an error occurspublic NodeId resolveNodePath(Path path) throws javax.jcr.RepositoryException
Note that, for performance reasons, this method returns null
rather than throwing a PathNotFoundException
if there's no
node to be found at path
.
resolveNodePath
in interface HierarchyManager
path
- path to resolvepath
or null
if there's no node at path
.javax.jcr.RepositoryException
- if an error occurspublic PropertyId resolvePropertyPath(Path path) throws javax.jcr.RepositoryException
Note that, for performance reasons, this method returns null
rather than throwing a PathNotFoundException
if there's no
property to be found at path
.
resolvePropertyPath
in interface HierarchyManager
path
- path to resolvepath
or null
if there's no property at path
.javax.jcr.RepositoryException
- if an error occurspublic Path getPath(ItemId id) throws javax.jcr.ItemNotFoundException, javax.jcr.RepositoryException
getPath
in interface HierarchyManager
javax.jcr.ItemNotFoundException
javax.jcr.RepositoryException
public Name getName(ItemId itemId) throws javax.jcr.ItemNotFoundException, javax.jcr.RepositoryException
getName
in interface HierarchyManager
itemId
- id of item whose name should be returnedjavax.jcr.ItemNotFoundException
javax.jcr.RepositoryException
public Name getName(NodeId id, NodeId parentId) throws javax.jcr.ItemNotFoundException, javax.jcr.RepositoryException
HierarchyManager.getName(ItemId)
.getName
in interface HierarchyManager
id
- node idparentId
- parent node idjavax.jcr.ItemNotFoundException
javax.jcr.RepositoryException
public int getDepth(ItemId id) throws javax.jcr.ItemNotFoundException, javax.jcr.RepositoryException
getPath(id).getAncestorCount()
. The depth reflects the
absolute hierarchy level.getDepth
in interface HierarchyManager
id
- item idjavax.jcr.ItemNotFoundException
- if the specified id
does not
denote an existing item.javax.jcr.RepositoryException
- if another error occurspublic int getRelativeDepth(NodeId ancestorId, ItemId descendantId) throws javax.jcr.ItemNotFoundException, javax.jcr.RepositoryException
ancestorId
and descendantId
denote the same item 0 is returned. If ancestorId
does not
denote an ancestor -1 is returned.getRelativeDepth
in interface HierarchyManager
ancestorId
- ancestor iddescendantId
- descendant idancestorId
does not
denote an ancestor of the item denoted by descendantId
(or itself).javax.jcr.ItemNotFoundException
- if either of the specified id's 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 HierarchyManager
nodeId
- 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 boolean isShareAncestor(NodeId ancestor, NodeId descendant) throws javax.jcr.ItemNotFoundException, javax.jcr.RepositoryException
ancestor
is a share ancestor of the item denoted by the given descendant
.
This is true
for two nodes A
, B
if either:
A
is a (proper) ancestor of B
N1
,...
,Nk
such that A
=
N1
and B
=Nk
and Ni
is the parent or a share-parent of
Ni+1
(for every i
in 1
...k-1
.isShareAncestor
in interface HierarchyManager
ancestor
- node iddescendant
- item idtrue
if the node denoted by ancestor
is a share ancestor of the item denoted by descendant
,
false
otherwisejavax.jcr.ItemNotFoundException
- if any of the specified id's does not
denote an existing item.javax.jcr.RepositoryException
- if another error occurspublic int getShareRelativeDepth(NodeId ancestor, ItemId descendant) throws javax.jcr.ItemNotFoundException, javax.jcr.RepositoryException
ancestor
and descendant
denote the same item, 0
is returned. If ancestor
does not denote an share-ancestor -1
is returned.getShareRelativeDepth
in interface HierarchyManager
ancestor
- ancestor iddescendant
- descendant id-1
if ancestor
does
not denote a share-ancestor of the item denoted by descendant
(or itself).javax.jcr.ItemNotFoundException
- if either of the specified id's does not
denote an existing item.javax.jcr.RepositoryException
- if another error occursCopyright © 2004-2020 The Apache Software Foundation. All Rights Reserved.