org.richfaces.model
Interface TreeNode<T>

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
CacheableTreeNodeImpl, TreeNodeImpl

public interface TreeNode<T>
extends java.io.Serializable

Interface representing tree ADT nodes

Author:
Nick Belaevski - nbelaevski@exadel.com created 16.11.2006

Method Summary
 void addChild(java.lang.Object identifier, TreeNode<T> child)
          adds child to children collection
 TreeNode<T> getChild(java.lang.Object id)
          find child by id Please see 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 id)
          Please see 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
 

Method Detail

getData

T getData()
getter for node attached data

Returns:
node attached data

setData

void setData(T data)
setter for node attached data

Parameters:
data - data to set as attached node data

isLeaf

boolean isLeaf()
Returns whether this node is leaf

Returns:
true if this node is leaf else returns false

getChildren

java.util.Iterator<java.util.Map.Entry<java.lang.Object,TreeNode<T>>> getChildren()
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.

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

getChild

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

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

addChild

void addChild(java.lang.Object identifier,
              TreeNode<T> child)
adds child to children collection

Parameters:
identifier - child identifier. Please see getChildren() for more information about identifier constraints.
child - child

removeChild

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

Parameters:
id - id of the child to remove

getParent

TreeNode<T> getParent()
getter for parent TreeNode

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

setParent

void setParent(TreeNode<T> parent)
setter for parent TreeNode

Parameters:
parent - TreeNode to set as parent


Copyright © 2010. All Rights Reserved.