FileDocCategorySizeDatePackage
TreeNode.javaAPI DocExample2892Tue Jun 08 11:26:42 BST 2004com.mycompany.jsf.model

TreeNode

public class TreeNode extends Object implements Serializable
This class represents a node in a tree of nodes. Instances of this class are used as the nodes in the TreeModel.
author
Hans Bergsten, Gefion Software
version
1.0

Fields Summary
private TreeNode
parent
private String
name
private Object
value
private boolean
isExpanded
private boolean
isLeafNode
private List
children
Constructors Summary
Methods Summary
public voidaddChild(com.mycompany.jsf.model.TreeNode child)
Adds the provided node as a child of this node.

	if (children == null) {
	    children = new ArrayList();
	}
	child.setParent(this);
	children.add(child);
    
public java.util.ListgetChildren()
Returns all children of this node.

	if (children == null) {
	    children = new ArrayList();
	}
	return children;
    
public java.lang.StringgetName()
Returns the node name.

	return name;
    
private com.mycompany.jsf.model.TreeNodegetParent()
Returns the parent of this node.

	return parent;
    
public java.lang.StringgetPath()
Returns a String representing the path to this node, with the names of each parent node separated by a slash and ending with the name of the current node.

	List chain = new ArrayList();
	chain.add(getName());
	TreeNode parent = getParent();
	while (parent != null) {
	    chain.add(parent.getName());
	    parent = parent.getParent();	    
	}
	StringBuffer sb = new StringBuffer();
	for (int i = chain.size() - 1; i >= 0; i--) {
	    sb.append("/").append(chain.get(i));
	}
	return sb.toString();
    
public java.lang.ObjectgetValue()
Returns the node value.

	return value;
    
public booleanisExpanded()
Returns "true" if the node is expanded,

	return isExpanded;
    
public booleanisLeafNode()
Returns "true" if this is a leaf node.

	return isLeafNode;
    
public voidsetExpanded(boolean isExpanded)
Sets the "expanded" property value.

	this.isExpanded = isExpanded;
    
public voidsetLeafNode(boolean isLeafNode)
Sets the "leafNode" property value.

	this.isLeafNode = isLeafNode;
    
public voidsetName(java.lang.String name)
Sets the node name.

	this.name = name;
    
private voidsetParent(com.mycompany.jsf.model.TreeNode parent)
Sets the parent of this node, called by the addChild() method.

	this.parent = parent;
    
public voidsetValue(java.lang.Object value)
Sets the node value.

	this.value = value;