|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.mmm.util.collection.base.AbstractTreeNode<NODE>
NODE
- is the generic type for self-references. Each sub-type of this
class should specialize this type to itself.public abstract class AbstractTreeNode<NODE extends AbstractTreeNode<NODE>>
This is the abstract base implementation of the TreeNode
interface.
Field Summary | |
---|---|
private List<NODE> |
children
|
private List<NODE> |
mutableChildList
|
private NODE |
parent
|
Constructor Summary | |
---|---|
AbstractTreeNode()
The constructor. |
|
AbstractTreeNode(ListFactory listFactory)
The constructor. |
|
AbstractTreeNode(NODE parent)
The constructor. |
|
AbstractTreeNode(NODE parent,
ListFactory listFactory)
The constructor. |
Method Summary | |
---|---|
protected void |
addChild(NODE child)
This method adds the given child to the children of this TreeNode . |
List<NODE> |
getChildren()
This method gets the List containing all children of this
TreeNode . |
NODE |
getParent()
This method gets the parent of this TreeNode . |
boolean |
isAncestor(TreeNode<?> node)
This method determines if this TreeNode is an ancestor of the given
node . |
boolean |
isDescendant(TreeNode<?> node)
This method determines if this TreeNode is a descendant of the
given node . |
protected NODE |
removeChild(int index)
This method removes the child from the
children of this TreeNode at the given
index . |
protected boolean |
removeChild(NODE child)
This method removes the given child from the
children of this TreeNode . |
protected void |
setParent(NODE parent)
This method sets the parent of this TreeNode . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final List<NODE extends AbstractTreeNode<NODE>> mutableChildList
getChildren()
private final List<NODE extends AbstractTreeNode<NODE>> children
getChildren()
private NODE extends AbstractTreeNode<NODE> parent
getParent()
Constructor Detail |
---|
public AbstractTreeNode()
public AbstractTreeNode(NODE parent)
parent
- is the parent
node.public AbstractTreeNode(ListFactory listFactory)
listFactory
- the factory used to create the internal List
.public AbstractTreeNode(NODE parent, ListFactory listFactory)
parent
- is the parent
node.listFactory
- the factory used to create the internal List
.Method Detail |
---|
public NODE getParent()
TreeNode
.
getParent
in interface TreeNode<NODE extends AbstractTreeNode<NODE>>
TreeNode
or null
if this is the
root- TreeNode
.protected void setParent(NODE parent)
parent
of this TreeNode
.
parent
- is the parent
to set. It may be
null
. However you should typically only call this
method once with a non-null argument. It is still legal to
re-arrange the tree-structure on existing TreeNode
s.public List<NODE> getChildren()
List
containing all children of this
TreeNode
. The List
may be empty
- in
such case we call this TreeNode
a leaf. Each item of the
returned List
is called a child or child-node. It
should return this TreeNode
as parent
.
getChildren
in interface TreeNode<NODE extends AbstractTreeNode<NODE>>
List
containing all children of this TreeNode
.protected void addChild(NODE child)
child
to the children
of this TreeNode
.
child
- is the child
to add. It's
parent
has to be identical to this
TreeNode
.protected boolean removeChild(NODE child)
child
from the
children
of this TreeNode
.
child
- is the child
to remove.
true
if the given child
was contained in
this TreeNode
s children
and has been
removed successfully, false
otherwise.protected NODE removeChild(int index)
child
from the
children
of this TreeNode
at the given
index
.
index
- is index
of the child
to remove.
child
that has actually been removed.public boolean isAncestor(TreeNode<?> node)
TreeNode
is an ancestor of the given
node
. In other words this method checks if this
TreeNode
is the direct or indirect parent
of
the given node
.
isAncestor
in interface TreeNode<NODE extends AbstractTreeNode<NODE>>
node
- is the TreeNode
to check (the potential
descendant
).
true
if this TreeNode
is an ancestor of the
given node
.public boolean isDescendant(TreeNode<?> node)
TreeNode
is a descendant of the
given node
. In other words this method checks if this
TreeNode
is the direct or indirect child
of
the given node
.
isDescendant
in interface TreeNode<NODE extends AbstractTreeNode<NODE>>
node
- is the TreeNode
to check (the potential
ancestor
).
true
if this TreeNode
is an descendant of the
given node
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |