Package org.apache.jackrabbit.commons
Class AbstractItem
java.lang.Object
org.apache.jackrabbit.commons.AbstractItem
- All Implemented Interfaces:
Item
- Direct Known Subclasses:
AbstractNode,AbstractProperty
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAncestor(int depth) Returns the ancestor of this item at the given depth.intgetDepth()Returns the depth of this item.toString()Returns a string representation of this item.
-
Constructor Details
-
AbstractItem
public AbstractItem()
-
-
Method Details
-
getAncestor
public Item getAncestor(int depth) throws ItemNotFoundException, AccessDeniedException, RepositoryException Returns the ancestor of this item at the given depth.The default implementation handles the root node at depth zero and this item at depth equal to the depth of this item as special cases, and uses
Session.getItem(String)to retrieve other ancestors based on the ancestor path calculated from the path of this node as returned byItem.getPath().- Specified by:
getAncestorin interfaceItem- Parameters:
depth- depth of the returned ancestor item- Returns:
- ancestor item
- Throws:
ItemNotFoundException- if the given depth is negative or greater than the depth of this itemAccessDeniedException- if access to the ancestor item is deniedRepositoryException- if an error occurs
-
getDepth
Returns the depth of this item.The default implementation determines the depth by counting the slashes in the path returned by
Item.getPath().- Specified by:
getDepthin interfaceItem- Returns:
- depth of this item
- Throws:
RepositoryException- if an error occurs
-
toString
Returns a string representation of this item.The default implementation returns the path of this item and falls back to the
Object.toString()implementation if the item path can not be retrieved.
-