Class PathMap.Element<T>
java.lang.Object
org.apache.jackrabbit.spi.commons.name.PathMap.Element<T>
Internal class holding the object associated with a certain
path element.
-
Method Summary
Modifier and TypeMethodDescriptionget()Return the object associated with this elementReturn an iterator over all of this element's children.intReturn the children count of this elementintgetDepth()Return the depth of this element.getDescendant(Path relPath, boolean exact) Map a relPath starting atthisElement.intgetIndex()Return the non-normalized 1-based index of this element.getName()Return the name of this elementintReturn the 1-based index of this element.Return the parent of this elementgetPath()Return the path of this element.Return a path element pointing to this elementbooleanChecks whether this element has the specified path.voidinsert(Path.Element nameIndex) Insert an empty child.booleanisAncestorOf(PathMap.Element<T> other) Return a flag indicating whether the specified node is a child of this node.voidput(Path.Element nameIndex, PathMap.Element<T> element) Link a child of this node.voidremove()Remove this element.voidremove(boolean shift) Remove this element.remove(Path.Element nameIndex) Remove a child.voidRemove all children of this element.voidSet the object associated with this elementvoidsetChildren(Map<Path.Element, PathMap.Element<T>> children) Sets a new list of children of this element.voidtraverse(PathMap.ElementVisitor<T> visitor, boolean includeEmpty) Recursively invoked traversal method.
-
Method Details
-
insert
Insert an empty child. Will shift all children having an index greater than or equal to the child inserted to the right.- Parameters:
nameIndex- position where child is inserted
-
put
Link a child of this node. Position is given bynameIndex.- Parameters:
nameIndex- position where child should be locatedelement- element to add
-
remove
Remove a child. Will shift all children having an index greater than the child removed to the left. If there are no more children left in this element and no object is associated with this element, the element itself gets removed.- Parameters:
nameIndex- child's path element- Returns:
- removed child, may be
null
-
remove
public void remove()Remove this element. Delegates the call to the parent item. Index of same name siblings will be shifted! -
remove
public void remove(boolean shift) Remove this element. Delegates the call to the parent item.- Parameters:
shift- if index of same name siblings will be shifted.
-
removeAll
public void removeAll()Remove all children of this element. Removes this element itself if this element does not contain associated information. -
setChildren
Sets a new list of children of this element.- Parameters:
children- map of children; keys are of typePath.PathElementand values are of typeElement
-
get
Return the object associated with this element- Returns:
- object associated with this element
-
set
Set the object associated with this element- Parameters:
obj- object associated with this element
-
getName
Return the name of this element- Returns:
- name
-
getIndex
public int getIndex()Return the non-normalized 1-based index of this element. Note that this method can return a value of 0 which should be treated as 1.- Returns:
- index
- See Also:
-
getNormalizedIndex
public int getNormalizedIndex()Return the 1-based index of this element. Same asgetIndex()except that anundefined indexvalue is automatically converted to thedefault indexvalue.- Returns:
- 1-based index
-
getPathElement
Return a path element pointing to this element- Returns:
- path element
-
getPath
Return the path of this element.- Returns:
- path
- Throws:
MalformedPathException- if building the path fails
-
hasPath
Checks whether this element has the specified path. Introduced to avoid catching aMalformedPathExceptionfor simple path comparisons.- Parameters:
path- path to compare to- Returns:
trueif this child has the pathpath,falseotherwise
-
traverse
Recursively invoked traversal method. This method visits the element first, then its children.- Parameters:
visitor- visitor to invokeincludeEmpty- iftrueinvoke call back on every element regardless, whether the associated object is empty or not; otherwise call back on non-empty children only
-
getDepth
public int getDepth()Return the depth of this element. Defined to be0for the root element andn + 1for some element if the depth of its parent isn. -
isAncestorOf
Return a flag indicating whether the specified node is a child of this node.- Parameters:
other- node to check
-
getParent
Return the parent of this element- Returns:
- parent or
nullif this is the root element
-
getChildrenCount
public int getChildrenCount()Return the children count of this element- Returns:
- children count
-
getChildren
Return an iterator over all of this element's children. Every element returned by this iterator is of typePathMap.Element. -
getDescendant
Map a relPath starting atthisElement. Ifexactisfalse, returns the last available item along the relPath that is stored in the map.- Parameters:
relPath- relPath to mapexact- flag indicating whether an exact match is required- Returns:
- descendant, maybe
nullifexactistrue
-