de.enough.polish.ui
Interface TreeModel

All Known Implementing Classes:
FileSystemTreeModel, UiFileSystemTreeModel

public interface TreeModel

Provides data for a TreeItem. The TreeModel is read when needed, meaning this model allows to realize a lazy loading mechanism of structured data. The J2ME Polish TreeModel is a more convenient model than the Java Swing one, as the model implementation does not need so many lookups (there is no getChild( Object parent, int index ) method that requires getChildCount( Object parent), for example).

Author:
Robert Virkus
See Also:
TreeItem

Method Summary
 void addChildren(Object parent, ArrayList childrenList)
          Returns the number of children of parent.
 Object getRoot()
          Returns the root of the tree.
 boolean isLeaf(Object node)
          Returns true if node is a leaf.
 

Method Detail

getRoot

Object getRoot()
Returns the root of the tree. Returns null only if the tree has no nodes. Note: The root element itself is not shown by a TreeItem.

Returns:
the root of the tree

addChildren

void addChildren(Object parent,
                 ArrayList childrenList)
Returns the number of children of parent. Returns 0 if the node is a leaf or if it has no children. parent must be a node previously obtained from this TreeModel.

Parameters:
parent - a node in the tree, obtained from this TreeModel
childrenList - the ArrayList into which the children should be added

isLeaf

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 TreeModel
Returns:
true if the node is a leaf