org.apache.cocoon.forms.formmodel.tree
Interface TreeModel

All Known Implementing Classes:
DefaultTreeModel, SourceTreeModel

public interface TreeModel

Data model for the Tree widget, inspired by Swing's TreeModel, with the difference that child nodes are accessed through keys rather than indices.

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

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).
 

Method Detail

getRoot

public Object getRoot()
Returns the root of the tree. Returns null only if the tree has no nodes.

Returns:
the root of the tree

getChildren

public Collection getChildren(Object parent)

isLeaf

public boolean isLeaf(Object node)
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.

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)

getChild

public Object getChild(Object parent,
                       String key)

getNode

public Object getNode(TreePath path)

addTreeModelListener

public void addTreeModelListener(TreeModelListener l)
Adds a listener for the TreeModelEvent posted after the tree changes.

Parameters:
l - the listener to add

removeTreeModelListener

public void removeTreeModelListener(TreeModelListener l)
Removes a listener previously added with addTreeModelListener(TreeModelListener).

Parameters:
l - the listener to remove


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