KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > webui > tree > WebTreeModel


1 /*
2 Copyright (c) 2003 eInnovation Inc. All rights reserved
3
4 This library is free software; you can redistribute it and/or modify it under the terms
5 of the GNU Lesser General Public License as published by the Free Software Foundation;
6 either version 2.1 of the License, or (at your option) any later version.
7
8 This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the GNU Lesser General Public License for more details.
11 */

12
13 package com.openedit.webui.tree;
14
15 import java.util.List JavaDoc;
16
17
18 /**
19  * This is the model for a <code>{@link WebTree}</code>.
20  *
21  * @author Eric Galluzzo
22  */

23 public interface WebTreeModel
24 {
25     /**
26      * Returns the child of <code>parent</code> at index <code>index</code> in the parent's child
27      * array. <code>parent</code> must be a node previously obtained from this data source. This
28      * should not return <code>null</code> if <code>index</code> is a valid index for
29      * <code>parent</code> (that is <code>index &gt;= 0 && index &lt;
30      * getChildCount(parent)</code>).
31      *
32      * @param parent A node in the tree, obtained from this data source
33      *
34      * @return The child of <code>parent</code> at index <code>index</code>
35      */

36     public Object JavaDoc getChild(Object JavaDoc parent, int index);
37
38     public List JavaDoc getChildren(Object JavaDoc parent);
39
40     public List JavaDoc getChildrenInRows(Object JavaDoc inParent, int inColCount);
41
42     /**
43      * Returns the number of children of <code>parent</code>. Returns 0 if the node is a leaf or
44      * if it has no children. <code>parent</code> must be a node previously obtained from this
45      * data source.
46      *
47      * @param parent A node in the tree, obtained from this data source
48      *
49      * @return The number of children of the node <code>parent</code>
50      */

51     public int getChildCount(Object JavaDoc parent);
52
53     /**
54      * Returns the index of <code>child</code> in <code>parent</code>. If <code>parent</code> is
55      * <code>null</code> or <code>child</code> is <code>null</code>, returns -1.
56      *
57      * @param parent A node in the tree, obtained from this data source
58      * @param child The node we are interested in
59      *
60      * @return The index of the child in the parent, or -1 if either <code>child</code> or
61      * <code>parent</code> is <code>null</code>
62      */

63     public int getIndexOfChild(Object JavaDoc parent, Object JavaDoc child);
64
65     /**
66      * Returns <code>true</code> if <code>node</code> is a leaf. It is possible for this method to
67      * return <code>false</code> even if <code>node</code> has no children. A directory in a
68      * filesystem, for example, may contain no files; the node representing the directory is not a
69      * leaf, but it also has no children.
70      *
71      * @param node A node in the tree, obtained from this data source
72      *
73      * @return <code>true</code> if <code>node</code> is a leaf
74      */

75     public boolean isLeaf(Object JavaDoc node);
76
77     /**
78      * Returns the root of the tree. Returns <code>null</code> only if the tree has no nodes.
79      *
80      * @return the root of the tree
81      */

82     public Object JavaDoc getRoot();
83     
84     /**
85      * Returns a unique ID for the given node. This ID should be unique
86      * throughout the tree.
87      *
88      * @param inNode The node
89      *
90      * @return The node's ID
91      */

92     public String JavaDoc getId( Object JavaDoc inNode );
93
94     public Object JavaDoc getParent(Object JavaDoc inNode);
95
96     public Object JavaDoc getChildById(String JavaDoc inId);
97 }
98
Popular Tags