org.openwms.core.util
Interface TreeNode<T>

Type Parameters:
T - The type of node.
All Known Implementing Classes:
TreeNodeImpl

public interface TreeNode<T>

A TreeNode to define a tree data structure.

Since:
0.1
Version:
$Revision: 1585 $
Author:
Heiko Scherrer

Method Summary
 void addChild(Object identifier, TreeNode<T> child)
          Adds a child to the children.
 TreeNode<T> getChild(Object id)
          Find a child by id.
 Iterator<Map.Entry<Object,TreeNode<T>>> getChildren()
          Get all child entries.
 T getData()
          Get the data of the node.
 TreeNode<T> getParent()
          Get the parent TreeNode.
 boolean isLeaf()
          Return whether this node is leaf.
 void removeChild(Object id)
          Removes a child from the children collection.
 void setData(T data)
          Set the data of the node.
 void setParent(TreeNode<T> parent)
          Set the parent TreeNode.
 

Method Detail

getData

T getData()
Get the data of the node.

Returns:
The attached Node data

setData

void setData(T data)
Set the data of the node.

Parameters:
data - Data to set

isLeaf

boolean isLeaf()
Return whether this node is leaf.

Returns:
true if this node is leaf, otherwise false

getChildren

Iterator<Map.Entry<Object,TreeNode<T>>> getChildren()
Get all child entries. Each child entry contains an identifier (key) and a child node (value). Identifiers are used to generate model keys representing paths to tree nodes. Model keys are used:
  1. For persisting tree state. That means identifiers should be serializable when some JSF features are used, e.g. client-side state saving.
  2. For construction of client identifiers. Client identifier for tree nodes consists of String representations of identifiers separated by a separator char. A String representation of identifier should be a valid XML ID, e.g. conform to XML Name Production production.

Returns:
Iterator over Map.Entry instances containing TreeNode as values and their identifiers as keys

getChild

TreeNode<T> getChild(Object id)
Find a child by id.

See getChildren() for more information about the identifier constraints.

Parameters:
id - The identifier of the child to find
Returns:
designated TreeNode instance or null

addChild

void addChild(Object identifier,
              TreeNode<T> child)
Adds a child to the children.

See getChildren() for more information about identifier constraints.

Parameters:
identifier - child identifier
child - The child

removeChild

void removeChild(Object id)
Removes a child from the children collection.

See getChildren() for more information about identifier constraints.

Parameters:
id - The id of the child to remove

getParent

TreeNode<T> getParent()
Get the parent TreeNode.

Returns:
parent TreeNode instance or null if the node is the root

setParent

void setParent(TreeNode<T> parent)
Set the parent TreeNode.

Parameters:
parent - TreeNode to set as parent


Copyright © 2005-2011 openwms.org. All Rights Reserved.