org.apache.jackrabbit.core
Class PathMap.Element

java.lang.Object
  extended byorg.apache.jackrabbit.core.PathMap.Element
Enclosing class:
PathMap

public static class PathMap.Element
extends Object

Internal class holding the object associated with a certain path element.


Method Summary
 Object get()
          Return the object associated with this element
 Iterator getChildren()
          Return an iterator over all of this element's children.
 int getChildrenCount()
          Return the children count of this element
 int getDepth()
          Return the depth of this element.
 int getIndex()
          Return the non-normalized 1-based index of this element.
 QName getName()
          Return the name of this element
 int getNormalizedIndex()
          Return the 1-based index of this element.
 PathMap.Element getParent()
          Return the parent of this element
 Path getPath()
          Return the path of this element.
 Path.PathElement getPathElement()
          Return a path element pointing to this element
 boolean hasPath(Path path)
          Checks whether this element has the specified path.
 void insert(Path.PathElement nameIndex)
          Insert an empty child.
 boolean isAncestorOf(PathMap.Element other)
          Return a flag indicating whether the specified node is a child of this node.
 void put(Path.PathElement nameIndex, PathMap.Element element)
          Link a child of this node.
 void remove()
          Remove this element.
 PathMap.Element remove(Path.PathElement nameIndex)
          Remove a child.
 void removeAll()
          Remove all children of this element.
 void set(Object obj)
          Set the object associated with this element
 void traverse(PathMap.ElementVisitor visitor, boolean includeEmpty)
          Recursively invoked traversal method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

insert

public void insert(Path.PathElement nameIndex)
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

public void put(Path.PathElement nameIndex,
                PathMap.Element element)
Link a child of this node. Position is given by nameIndex.

Parameters:
nameIndex - position where child should be located
element - element to add

remove

public PathMap.Element remove(Path.PathElement nameIndex)
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.


removeAll

public void removeAll()
Remove all children of this element. Removes this element itself if this element does not contain associated information.


get

public Object get()
Return the object associated with this element

Returns:
object associated with this element

set

public void set(Object obj)
Set the object associated with this element

Parameters:
obj - object associated with this element

getName

public QName 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()

getNormalizedIndex

public int getNormalizedIndex()
Return the 1-based index of this element. Same as getIndex() except that an index value of 0 is automatically converted to 1.

Returns:
1-based index

getPathElement

public Path.PathElement getPathElement()
Return a path element pointing to this element

Returns:
path element

getPath

public Path getPath()
             throws MalformedPathException
Return the path of this element.

Returns:
path
Throws:
MalformedPathException - if building the path fails

hasPath

public boolean hasPath(Path path)
Checks whether this element has the specified path. Introduced to avoid catching a MalformedPathException for simple path comparisons.

Parameters:
path - path to compare to
Returns:
true if this child has the path path, false otherwise

traverse

public void traverse(PathMap.ElementVisitor visitor,
                     boolean includeEmpty)
Recursively invoked traversal method.

Parameters:
visitor - visitor to invoke
includeEmpty - if true invoke 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 be 0 for the root element and n + 1 for some element if the depth of its parent is n.


isAncestorOf

public boolean isAncestorOf(PathMap.Element other)
Return a flag indicating whether the specified node is a child of this node.

Parameters:
other - node to check

getParent

public PathMap.Element getParent()
Return the parent of this element

Returns:
parent or null if this is the root element

getChildrenCount

public int getChildrenCount()
Return the children count of this element

Returns:
children count

getChildren

public Iterator getChildren()
Return an iterator over all of this element's children. Every element returned by this iterator is of type #Element.



Copyright © 2004-2006 The Apache Software Foundation. All Rights Reserved.