| Implements a tree hierarchy of groups.
This class process all group hierarchy, and each group may have unlimited sub groups.
Each group is called node ( net.jforum.model.GroupNode object ), and
each node may have sub-nodes. For example, given a table like the folowing:
+----+----------------+--------+
| id | name | parent |
+----+---------------+--------+
| 6 | Parent 1 | 0 |
| 7 | Sub 1.1 | 6 |
| 8 | Sub 1.2 | 6 |
| 9 | SubSub 1.2.1 | 8 |
| 10 | SubSub 1.2.2 | 8 |
| 11 | Parent 2 | 0 |
| 12 | Parent 3 | 0 |
| 13 | Sub 3.1 | 12 |
| 14 | SubSub 3.1.1 | 13 |
| 15 | Sub 3.2 | 12 |
| 16 | Parent 4 | 0 |
+----+---------------+--------+
results on the folowing hierarchy
Parent 1
------
|
Sub 1.1
----------
|
Sub 1.2
----------
|
SubSub 1.2.1
------------
|
SubSub 1.2.2
Parent 2
-----
Parent 3
-----
|
Sub 3.1
---------
|
SubSub 3.1.1
------------
|
Sub 3.2
---------
Parent 4
------
As is possible to see, we have 4 parent groups, called Parent 1 , Parent 2 ,
Parent 3 and Parent 4 . Parent 1 has 2 sub groups: Sub 1.1
and Sub 1.2 . Sub 1.2 contains 2 subgroups, SubSub 1.2.1 and
SubSub 1.2.2 . As every group is a node, ( GroupNode object ), and as each node
may have sub-nodes, the processing would be as:
When the method size() of the Parent 1 object is called, the number 2 will
be retorned, because Parent 1 has 2 sub groups;
when the size() method is called on the object of Sub 1.1 , will be returned 0, because
Sub 1.1 does not have any sub groups;
On the other hand, then we call the size() method of the object represented by Sub 1.2 object,
we wil have a return value of 2, because Sub 1.2 has 2 sub groups.
The same operation is done to all other groups and its sub groups.
author: Rafael Steil version: $Id: TreeGroup.java,v 1.10 2006/08/20 22:47:42 rafaelsteil Exp $ |