org.apache.myfaces.custom.tree2

Class TreeModelBase

Implemented Interfaces:
Serializable, TreeModel

public class TreeModelBase
extends java.lang.Object
implements TreeModel

Model class for the tree component. It provides random access to nodes in a tree made up of instances of the TreeNode class.
Version:
$Revision: 168205 $ $Date: 2005-05-04 18:59:21 -0400 (Wed, 04 May 2005) $
Authors:
Sean Schofield
Hans Bergsten (Some code taken from an example in his O'Reilly JavaServer Faces book. Copied with permission)

Fields inherited from interface org.apache.myfaces.custom.tree2.TreeModel

SEPARATOR

Constructor Summary

TreeModelBase(TreeNode root)
Constructor

Method Summary

TreeNode
getNode()
Gets the current TreeNode or null if no node ID is selected.
String[]
getPathInformation(String nodeId)
Gets an array of String containing the ID's of all of the TreeNodes in the path to the specified node.
TreeState
getTreeState()
boolean
isLastChild(String nodeId)
Indicates whether or not the specified TreeNode is the last child in the List of children.
void
setNodeId(String nodeId)
Sets the current TreeNode to the specified node ID, which is a colon-separated list of node indexes.
void
setTreeState(TreeState treeState)

Constructor Details

TreeModelBase

public TreeModelBase(TreeNode root)
Constructor
Parameters:
root - The root TreeNode

Method Details

getNode

public TreeNode getNode()
Gets the current TreeNode or null if no node ID is selected.
Specified by:
getNode in interface TreeModel
Returns:
The current node

getPathInformation

public String[] getPathInformation(String nodeId)
Gets an array of String containing the ID's of all of the TreeNodes in the path to the specified node. The path information will be an array of String objects representing node ID's. The array will starting with the ID of the root node and end with the ID of the specified node.
Specified by:
getPathInformation in interface TreeModel
Parameters:
nodeId - The id of the node for whom the path information is needed.
Returns:
String[]

getTreeState

public TreeState getTreeState()
Specified by:
getTreeState in interface TreeModel

isLastChild

public boolean isLastChild(String nodeId)
Indicates whether or not the specified TreeNode is the last child in the List of children. If the node id provided corresponds to the root node, this returns true.
Specified by:
isLastChild in interface TreeModel
Parameters:
nodeId - The ID of the node to check
Returns:
boolean

setNodeId

public void setNodeId(String nodeId)
Sets the current TreeNode to the specified node ID, which is a colon-separated list of node indexes. For instance, "0:0:1" means "the second child node of the first child node under the root node."
Specified by:
setNodeId in interface TreeModel
Parameters:
nodeId - The id of the node to set

setTreeState

public void setTreeState(TreeState treeState)
Specified by:
setTreeState in interface TreeModel