Package net.sf.basedb.util
Class Tree.Entry<E>
- java.lang.Object
-
- net.sf.basedb.util.Tree.Entry<E>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tree.Entry<E>
addChild(E child)
Add a child to the node.private void
addChildEntry(Tree.Entry<E> child)
List<Tree.Entry<E>>
getChildren()
Get the list of entries for the children to this node.int
getDepth()
Get the depth of this entry within the tree.E
getNode()
Get the node element object.int
getNumChildren()
Get the number of children added to this node.Tree.Entry<E>
getParent()
Get the entry for the parent node.boolean
isFirstChild(E child)
Check if the specified object is the first child to this node.boolean
isLastChild(E child)
Check if the specified object is the last child to this node.
-
-
-
Field Detail
-
node
private final E node
-
parent
private final Tree.Entry<E> parent
-
children
private List<Tree.Entry<E>> children
-
depth
private final int depth
-
-
Constructor Detail
-
Entry
private Entry(Tree<E> tree, E node, Tree.Entry<E> parent)
-
-
Method Detail
-
getNode
public E getNode()
Get the node element object.- Returns:
- The node elemenet of this entry
-
getParent
public Tree.Entry<E> getParent()
Get the entry for the parent node.- Returns:
- An
Entry
object or null if this is the root entry
-
getDepth
public int getDepth()
Get the depth of this entry within the tree. The root node is at depth 0.- Returns:
- The depth starting with 0 at the root node
-
addChild
public Tree.Entry<E> addChild(E child)
Add a child to the node.- Parameters:
child
- The child to add- Returns:
- The
Entry
object of the new child node - Throws:
IllegalArgumentException
- If the child already exists in the tree
-
getNumChildren
public int getNumChildren()
Get the number of children added to this node.- Returns:
- The number of children
-
getChildren
public List<Tree.Entry<E>> getChildren()
Get the list of entries for the children to this node.- Returns:
- A
List
containing the entries for the children or null if no children has been added to this node
-
isFirstChild
public boolean isFirstChild(E child)
Check if the specified object is the first child to this node.- Parameters:
child
- The object to check- Returns:
- TRUE if the object is the first child, FALSE otherwise
-
isLastChild
public boolean isLastChild(E child)
Check if the specified object is the last child to this node.- Parameters:
child
- The object to check- Returns:
- TRUE if the object is the last child, FALSE otherwise
-
addChildEntry
private void addChildEntry(Tree.Entry<E> child)
-
-