public class DefaultTreeNode<E> extends java.lang.Object implements TreeNode<E>, java.lang.Comparable<DefaultTreeNode<E>>, java.lang.Cloneable, java.io.Serializable
Notice that if a node is added to another (i.e., become a child of another node), it will be removed from the previous parent automatically.
Modifier and Type | Class and Description |
---|---|
protected class |
DefaultTreeNode.TreeNodeChildrenList |
Constructor and Description |
---|
DefaultTreeNode(E data)
Creates a leaf node, i.e., it won't allow any children.
|
DefaultTreeNode(E data,
boolean nullAsMax)
Creates a leaf node, i.e., it won't allow any children.
|
DefaultTreeNode(E data,
java.util.Collection<? extends TreeNode<E>> children)
Creates a branch (non-leaf) node.
|
DefaultTreeNode(E data,
java.util.Collection<? extends TreeNode<E>> children,
boolean nullAsMax)
Creates a branch (non-leaf) node.
|
DefaultTreeNode(E data,
TreeNode<E>[] children)
Creates a branch (non-leaf) node.
|
Modifier and Type | Method and Description |
---|---|
void |
add(TreeNode<E> child)
Adds a child to this node at the end.
|
java.lang.Object |
clone()
Clones the tree node.
|
int |
compareTo(DefaultTreeNode<E> node) |
TreeNode<E> |
getChildAt(int childIndex)
Returns the child
TreeNode at index
childIndex . |
int |
getChildCount()
Returns the number of children
TreeNode s this node
contains. |
java.util.List<TreeNode<E>> |
getChildren()
Return children of the receiver
|
E |
getData()
Returns the application-specific data of this node.
|
int |
getIndex(TreeNode<E> node)
Returns the index of
node in this node's children. |
DefaultTreeModel<E> |
getModel()
Returns the tree model it belongs to.
|
TreeNode<E> |
getParent()
Returns the parent
TreeNode of this node. |
void |
insert(TreeNode<E> child,
int index)
Adds child to this node at the given index.
|
boolean |
isLeaf()
Returns true if this node is a leaf.
|
void |
remove(int index)
Removes the child at index from this node.
|
void |
remove(TreeNode<E> child)
Removes the child from this node.
|
void |
removeFromParent()
Removes the receiver from its parent.
|
void |
setData(E data)
Sets the application-specific data associated with this node.
|
void |
setModel(DefaultTreeModel<E> model)
Sets the tree model it belongs to.
|
protected void |
setParent(DefaultTreeNode<E> parent)
Sets the parent.
|
java.lang.String |
toString() |
public DefaultTreeNode(E data, java.util.Collection<? extends TreeNode<E>> children)
children
- a collection of children (they must be DefaultTreeNode
too).
If null or empty, it means
no children at all. However, it still allows to add children.
If it is not allowed, please use DefaultTreeNode(Object)
instead.public DefaultTreeNode(E data, java.util.Collection<? extends TreeNode<E>> children, boolean nullAsMax)
children
- a collection of children (they must be DefaultTreeNode
too).
If null or empty, it means
no children at all. However, it still allows to add children.
If it is not allowed, please use DefaultTreeNode(Object)
instead.public DefaultTreeNode(E data, TreeNode<E>[] children)
children
- a collection of children (they must be DefaultTreeNode
too).
If null or empty, it means
no children at all. However, it still allows to add children.
If it is not allowed, please use DefaultTreeNode(Object)
instead.public DefaultTreeNode(E data)
public DefaultTreeNode(E data, boolean nullAsMax)
nullAsMax
- whether to consider null as the maximum value.
If false, null is considered as the minimum value.public void removeFromParent()
public DefaultTreeModel<E> getModel()
TreeNode
public void setModel(DefaultTreeModel<E> model)
TreeNode
This method is invoked automatically if DefaultTreeModel
,
so you don't have to invoke it.
public E getData()
TreeNode
public void setData(E data)
TreeNode
public java.util.List<TreeNode<E>> getChildren()
TreeNode
getChildren
in interface TreeNode<E>
public TreeNode<E> getChildAt(int childIndex)
TreeNode
TreeNode
at index
childIndex
.getChildAt
in interface TreeNode<E>
public int getChildCount()
TreeNode
TreeNode
s this node
contains.getChildCount
in interface TreeNode<E>
public TreeNode<E> getParent()
TreeNode
TreeNode
of this node.protected void setParent(DefaultTreeNode<E> parent)
insert(org.zkoss.zul.TreeNode<E>, int)
, add(org.zkoss.zul.TreeNode<E>)
or remove(int)
is
called.
The deriving class rarely needs to override it.public int getIndex(TreeNode<E> node)
TreeNode
node
in this node's children.
If this node does not contain node
, -1 will be
returned.public boolean isLeaf()
TreeNode
public void insert(TreeNode<E> child, int index)
TreeNode
public void add(TreeNode<E> child)
TreeNode
public void remove(int index)
TreeNode
public void remove(TreeNode<E> child)
TreeNode
public int compareTo(DefaultTreeNode<E> node)
compareTo
in interface java.lang.Comparable<DefaultTreeNode<E>>
public java.lang.Object clone()
TreeNode
Notes:
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2005-2011 Potix Corporation. All Rights Reserved.