Package org.eclipse.jface.viewers
Class TreeNode
- java.lang.Object
-
- org.eclipse.jface.viewers.TreeNode
-
public class TreeNode extends java.lang.ObjectA simple data structure that is useful for implemented tree models. This can be returned byIStructuredContentProvider.getElements(Object). It allows simple delegation of methods fromITreeContentProvidersuch asITreeContentProvider.getChildren(Object),ITreeContentProvider.getParent(Object)andITreeContentProvider.hasChildren(Object)- Since:
- 3.2
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.ObjectvalueThe value contained in this node.
-
Constructor Summary
Constructors Constructor Description TreeNode(java.lang.Object value)Constructs a new instance ofTreeNode.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object object)TreeNode[]getChildren()Returns the child nodes.TreeNodegetParent()Returns the parent node.java.lang.ObjectgetValue()Returns the value held by this node.booleanhasChildren()Returns whether the tree has any children.inthashCode()voidsetChildren(TreeNode[] children)Sets the children for this node.voidsetParent(TreeNode parent)Sets the parent for this node.
-
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equalsin classjava.lang.Object
-
getChildren
public TreeNode[] getChildren()
Returns the child nodes. Empty arrays are converted tonullbefore being returned.- Returns:
- The child nodes; may be
null, but never empty. There should be nonullchildren in the array.
-
getParent
public TreeNode getParent()
Returns the parent node.- Returns:
- The parent node; may be
nullif there are no parent nodes.
-
getValue
public java.lang.Object getValue()
Returns the value held by this node.- Returns:
- The value; may be anything.
-
hasChildren
public boolean hasChildren()
Returns whether the tree has any children.- Returns:
trueif its array of children is notnulland is non-empty;falseotherwise.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
setChildren
public void setChildren(TreeNode[] children)
Sets the children for this node.- Parameters:
children- The child nodes; may benullor empty. There should be nonullchildren in the array.
-
setParent
public void setParent(TreeNode parent)
Sets the parent for this node.- Parameters:
parent- The parent node; may benull.
-
-