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

java.lang.Object
  extended by org.apache.cocoon.forms.formmodel.tree.DefaultTreeModel
All Implemented Interfaces:
TreeModel
Direct Known Subclasses:
DefaultTreeModel.Sample

public class DefaultTreeModel
extends Object
implements TreeModel

A default tree model, implemented with DefaultTreeModel.TreeNodes.

Version:
$Id: DefaultTreeModel.html 1304258 2012-03-23 10:09:27Z ilgrosso $

Nested Class Summary
static class DefaultTreeModel.DefaultTreeNode
           
static class DefaultTreeModel.Sample
          The classical Swing sample tree model, that can be used for demonstration purposes.
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 TreeModel.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-2010 The Apache Software Foundation. All Rights Reserved.