Class Tree
- java.lang.Object
-
- org.eclipse.nebula.widgets.nattable.columnCategories.Tree
-
- All Implemented Interfaces:
Serializable
public class Tree extends Object implements Serializable
Represents a Tree of Objects. The Tree is represented as a single rootElement which points to a List<Node> of children. Adapted from public domain code at http://sujitpal.blogspot.com/.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Tree()
Default ctor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Node
find(String nodeData)
Find the Node in the tree containing the supplied data.Node
find(Node element, String nodeData)
Find a Node in a tree, containing the given dataNode
getRootElement()
Return the root Node of the tree.boolean
remove(String nodeData)
Removes the node with the supplied node data.void
setRootElement(Node rootElement)
Set the root Element for the tree.List<Node>
toList()
Returns the Tree as a List of Node objects.String
toString()
Returns a String representation of the Tree.
-
-
-
Method Detail
-
getRootElement
public Node getRootElement()
Return the root Node of the tree.- Returns:
- the root element.
-
setRootElement
public void setRootElement(Node rootElement)
Set the root Element for the tree.- Parameters:
rootElement
- the root element to set.
-
toList
public List<Node> toList()
Returns the Tree as a List of Node objects. The elements of the List are generated from a pre-order traversal of the tree.- Returns:
- a List<Node>.
-
toString
public String toString()
Returns a String representation of the Tree. The elements are generated from a pre-order traversal of the Tree.
-
find
public Node find(String nodeData)
Find the Node in the tree containing the supplied data. Stops searching at the first match.- Parameters:
nodeData
- the node data- Returns:
- matching Node if found, NULL otherwise
-
find
public Node find(Node element, String nodeData)
Find a Node in a tree, containing the given data- Parameters:
element
- Node to start searching atnodeData
- to search for- Returns:
- matching Node if found, NULL otherwise
-
clear
public void clear()
-
remove
public boolean remove(String nodeData)
Removes the node with the supplied node data. Deletes the first matching node.- Parameters:
nodeData
- the node data- Returns:
- TRUE if a node was found and removed
-
-