org.apache.cocoon.forms.formmodel.tree
Class DefaultTreeModel

java.lang.Object
  extended byorg.apache.cocoon.forms.formmodel.tree.DefaultTreeModel
All Implemented Interfaces:
TreeModel

public class DefaultTreeModel
extends Object
implements TreeModel

A default tree model, implemented with DefaultTreeModel.TreeNodes.

Version:
$Id: DefaultTreeModel.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Nested Class Summary
static class DefaultTreeModel.DefaultTreeNode
           
static interface DefaultTreeModel.TreeNode
           
 
Field Summary
static TreeModel UNSPECIFIED_MODEL
          Default model that is used by a Tree when no model has been specified.
 
Constructor Summary
DefaultTreeModel(DefaultTreeModel.TreeNode root)
           
 
Method Summary
 void addTreeModelListener(TreeModelListener l)
          Adds a listener for the TreeModelEvent posted after the tree changes.
 Object getChild(Object parent, String key)
           
 String getChildKey(Object parent, Object child)
           
 Collection getChildren(Object parent)
           
 Object getNode(TreePath path)
           
 Object getRoot()
          Returns the root of the tree.
 boolean isLeaf(Object node)
          Returns true if node is a leaf.
 void removeTreeModelListener(TreeModelListener l)
          Removes a listener previously added with addTreeModelListener(TreeModelListener).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNSPECIFIED_MODEL

public static final TreeModel UNSPECIFIED_MODEL
Default model that is used by a Tree when no model has been specified.

Constructor Detail

DefaultTreeModel

public DefaultTreeModel(DefaultTreeModel.TreeNode root)
Method Detail

getRoot

public Object getRoot()
Description copied from interface: TreeModel
Returns the root of the tree. Returns null only if the tree has no nodes.

Specified by:
getRoot in interface TreeModel
Returns:
the root of the tree

getChildren

public Collection getChildren(Object parent)
Specified by:
getChildren in interface TreeModel

isLeaf

public boolean isLeaf(Object node)
Description copied from interface: TreeModel
Returns true if node is a leaf. It is possible for this method to return false even if node has no children. A directory in a filesystem, for example, may contain no files; the node representing the directory is not a leaf, but it also has no children.

Specified by:
isLeaf in interface TreeModel
Parameters:
node - a node in the tree, obtained from this data source
Returns:
true if node is a leaf

getChildKey

public String getChildKey(Object parent,
                          Object child)
Specified by:
getChildKey in interface TreeModel

getChild

public Object getChild(Object parent,
                       String key)
Specified by:
getChild in interface TreeModel

getNode

public Object getNode(TreePath path)
Specified by:
getNode in interface TreeModel

addTreeModelListener

public void addTreeModelListener(TreeModelListener l)
Description copied from interface: TreeModel
Adds a listener for the TreeModelEvent posted after the tree changes.

Specified by:
addTreeModelListener in interface TreeModel
Parameters:
l - the listener to add

removeTreeModelListener

public void removeTreeModelListener(TreeModelListener l)
Description copied from interface: TreeModel
Removes a listener previously added with TreeModel.addTreeModelListener(TreeModelListener).

Specified by:
removeTreeModelListener in interface TreeModel
Parameters:
l - the listener to remove


Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.