org.openwms.core.util
Class TreeNodeImpl<T>

java.lang.Object
  extended by org.openwms.core.util.TreeNodeImpl<T>
Type Parameters:
T - The type of the node
All Implemented Interfaces:
Serializable, TreeNode<T>

public class TreeNodeImpl<T>
extends Object
implements TreeNode<T>, Serializable

A TreeNodeImpl is a simple implementation of a TreeNode.

Since:
0.1
Version:
$Revision: 1507 $
Author:
Heiko Scherrer
See Also:
Serialized Form

Constructor Summary
TreeNodeImpl()
           
 
Method Summary
 void addChild(Object identifier, TreeNode<T> child)
          Adds a child to the children.
 TreeNode<T> getChild(Object identifier)
          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 identifier)
          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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeNodeImpl

public TreeNodeImpl()
Method Detail

getData

public T getData()
Get the data of the node.

Specified by:
getData in interface TreeNode<T>
Returns:
The attached Node data

getChild

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

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

Specified by:
getChild in interface TreeNode<T>
Parameters:
identifier - The identifier of the child to find
Returns:
designated TreeNode instance or null

addChild

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

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

Specified by:
addChild in interface TreeNode<T>
Parameters:
identifier - child identifier
child - The child

removeChild

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

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

Specified by:
removeChild in interface TreeNode<T>
Parameters:
identifier - The id of the child to remove

setData

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

Specified by:
setData in interface TreeNode<T>
Parameters:
data - Data to set

getParent

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

Specified by:
getParent in interface TreeNode<T>
Returns:
parent TreeNode instance or null if the node is the root

setParent

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

Specified by:
setParent in interface TreeNode<T>
Parameters:
parent - TreeNode to set as parent

getChildren

public 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.

Specified by:
getChildren in interface TreeNode<T>
Returns:
Iterator over Map.Entry instances containing TreeNode as values and their identifiers as keys

isLeaf

public boolean isLeaf()
Return whether this node is leaf.

Specified by:
isLeaf in interface TreeNode<T>
Returns:
true if this node is leaf, otherwise false


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