KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nemesis > forum > TreeWalker


1 /*
2  * NEMESIS-FORUM.
3  * Copyright (C) 2002 David Laurent(lithium2@free.fr). All rights reserved.
4  *
5  * Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
6  *
7  * Copyright (C) 2001 Yasna.com. All rights reserved.
8  *
9  * Copyright (C) 2000 CoolServlets.com. All rights reserved.
10  *
11  * NEMESIS-FORUM. is free software; you can redistribute it and/or
12  * modify it under the terms of the Apache Software License, Version 1.1,
13  * or (at your option) any later version.
14  *
15  * NEMESIS-FORUM core framework, NEMESIS-FORUM backoffice, NEMESIS-FORUM frontoffice
16  * application are parts of NEMESIS-FORUM and are distributed under
17  * same terms of licence.
18  *
19  *
20  * NEMESIS-FORUM includes software developed by the Apache Software Foundation (http://www.apache.org/)
21  * and software developed by CoolServlets.com (http://www.coolservlets.com).
22  * and software developed by Yasna.com (http://www.yasna.com).
23  *
24  */

25
26
27 package org.nemesis.forum;
28
29 /**
30  * Allows hierarchical navigation of a Thread. It closely follows the
31  * TreeModel interface in Swing in the hopes of being easier to use.
32  *
33  * @see ForumThread
34  */

35 public interface TreeWalker {
36
37     /**
38      * Returns the root of the tree. Returns null only if the tree has no nodes.
39      *
40      * @returns the root of the tree
41      */

42     public Message getRoot();
43
44     /**
45      * Returns the child of parent at index index in the parent's child array.
46      * This should not return null if index is a valid index for parent (that
47      * is index >= 0 && index < getChildCount(parent)).
48      *
49      * @param parent the parent message.
50      * @param index the index of the child.
51      * @returns the child of parent at index.
52      */

53     public Message getChild(Message parent, int index);
54
55     /**
56      * Returns the number of children of parent. Returns 0 if the node is a
57      * leaf or if it has no children.
58      *
59      * @param parent a node in the tree, obtained from this data source.
60      * @returns the number of children of the node parent.
61      */

62     public int getChildCount(Message parent);
63
64     /**
65      * Returns the total number of recursive children of a parent. Returns 0
66      * if there are no children. This method is not intended to aid in
67      * navigation of a Thread but is included as an added utility.
68      */

69     public int getRecursiveChildCount(Message parent);
70
71     /**
72      * Returns the index of child in parent.
73      */

74     public int getIndexOfChild(Message parent, Message child);
75
76     /**
77      * Returns true if node is a leaf. A node is a leaf when it has no children
78      * messages.
79      *
80      * @param node a node in the tree, obtained from this data source
81      * @returns true if node is a leaf
82      */

83     public boolean isLeaf(Message node);
84 }
85
Popular Tags