org.richfaces.model
Class TreeNodeImpl<T>

java.lang.Object
  extended by org.richfaces.model.TreeNodeImpl<T>
All Implemented Interfaces:
java.io.Serializable, TreeNode<T>
Direct Known Subclasses:
CacheableTreeNodeImpl

public class TreeNodeImpl<T>
extends java.lang.Object
implements TreeNode<T>

Default TreeNode implementation based on LinkedHashMap to preserve elements ordering

Author:
Nick Belaevski - nbelaevski@exadel.com created 16.11.2006
See Also:
Serialized Form

Constructor Summary
TreeNodeImpl()
           
 
Method Summary
 void addChild(java.lang.Object identifier, TreeNode<T> child)
          adds child to children collection
 TreeNode<T> getChild(java.lang.Object identifier)
          find child by id Please see TreeNode.getChildren() for more information about identifier constraints.
 java.util.Iterator<java.util.Map.Entry<java.lang.Object,TreeNode<T>>> getChildren()
          Getter for children entries.
 T getData()
          getter for node attached data
 TreeNode<T> getParent()
          getter for parent TreeNode
 boolean isLeaf()
          Returns whether this node is leaf
 void removeChild(java.lang.Object identifier)
          Please see TreeNode.getChildren() for more information about identifier constraints.
 void setData(T data)
          setter for node attached data
 void setParent(TreeNode<T> parent)
          setter for 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()
Description copied from interface: TreeNode
getter for node attached data

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

getChild

public TreeNode<T> getChild(java.lang.Object identifier)
Description copied from interface: TreeNode
find child by id Please see TreeNode.getChildren() for more information about identifier constraints.

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

addChild

public void addChild(java.lang.Object identifier,
                     TreeNode<T> child)
Description copied from interface: TreeNode
adds child to children collection

Specified by:
addChild in interface TreeNode<T>
Parameters:
identifier - child identifier. Please see TreeNode.getChildren() for more information about identifier constraints.
child - child

removeChild

public void removeChild(java.lang.Object identifier)
Description copied from interface: TreeNode
Please see TreeNode.getChildren() for more information about identifier constraints. removes child from children collection by child id

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

setData

public void setData(T data)
Description copied from interface: TreeNode
setter for node attached data

Specified by:
setData in interface TreeNode<T>
Parameters:
data - data to set as attached node data

getParent

public TreeNode<T> getParent()
Description copied from interface: TreeNode
getter for parent TreeNode

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

setParent

public void setParent(TreeNode<T> parent)
Description copied from interface: TreeNode
setter for parent TreeNode

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

getChildren

public java.util.Iterator<java.util.Map.Entry<java.lang.Object,TreeNode<T>>> getChildren()
Description copied from interface: TreeNode
Getter for children entries. Each children entry contains identifier (key) and child node (value). Identifiers are used to generate model keys representing paths to tree node. Model keys are used:
  1. For persisting tree state. That means that identifiers should be serializable when some JSF features are used, e.g. client-side state saving.
  2. For constructing client identifiers. Client identifier for tree nodes consists of Object.toString() representations of identifier separated with NamingContainer.SEPARATOR_CHAR chars. String representation of identifier should be a valid XML ID, e.g. conform to this: XML Name Production production.

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

isLeaf

public boolean isLeaf()
Description copied from interface: TreeNode
Returns whether this node is leaf

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


Copyright © 2010. All Rights Reserved.