KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > adminGui > feature > account > AccountItem


1 //// You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
package org.ozoneDB.adminGui.feature.account;
8
9 import java.util.Vector JavaDoc;
10
11
12 //#############################################################################
13
/**
14  * This class creates users/groups objects that are loaded into the Groups tree.
15  *
16  * @author <p align=center>Ibsen Ramos-Bonilla
17  * <br>Copyright &copy 1997-@year@ by SMB GmbH. All Rights Reserved.</p>
18  *
19  * @version 1.0
20  */

21 //#############################################################################
22

23 public class AccountItem {
24
25     /** The name associated with this item. */
26     private String JavaDoc name = null;
27     /** The id associated with this item. */
28     private int id = 0;
29     /** Identifies the associated item as part of the admin group. */
30     private boolean admin = false;
31     /** The list of children associated with this item. */
32     private Vector JavaDoc children = new Vector JavaDoc();
33
34
35     /**
36      * Overloaded constructor initializes the a new item.
37      *
38      * @param name - the item name.
39      * @param id - the item id.
40      */

41     public AccountItem(String JavaDoc name, int id) {
42         //initialize the group item
43
this.name = name;
44         this.id = id;
45     }
46
47     /**
48      * This method returns the group item name.
49      *
50      * @return String - group item name.
51      */

52     public String JavaDoc toString() {
53         return this.name;
54     }
55
56     /**
57      * This method returns the group item id.
58      *
59      * @return int - group item id.
60      */

61     public int getId() {
62         return this.id;
63     }
64
65     /**
66      * This method returns a flag indicating if the account is admin.
67      *
68      * @return boolean - TRUE = is admin.
69      * FALSE = is not admin.
70      */

71     public boolean isAdmin() {
72         return this.admin;
73     }
74
75     /**
76      * This method returns number of children for this item.
77      *
78      * @param item - the selected child.
79      * @return int - number of children.
80      */

81     public int getIndexOfChild(AccountItem item) {
82         //index of selected child
83
if (this.children != null)
84             return this.children.indexOf(item);
85
86         //no index for selected child
87
else
88             return -1;
89     }
90
91     /**
92      * This method returns the specific child at a selected location.
93      *
94      * @param i - the selected position of a child.
95      * @return GroupItem - child.
96      */

97     public AccountItem getChildAt(int i) {
98         //child at selected location
99
if (this.children != null)
100             return (AccountItem) this.children.elementAt(i);
101
102         //no child at selected location
103
else
104             return null;
105     }
106
107     /**
108      * This method returns number of children for this item.
109      *
110      * @return int - number of children.
111      */

112     public int getChildCount() {
113         //children available
114
if (this.children != null)
115             return this.children.size();
116
117         //no children available
118
else
119             return 0;
120     }
121
122     /**
123      * This method sets this object child objects.
124      *
125      * @param children - item children.
126      */

127     public void setChildren(Vector JavaDoc children) {
128         this.children = children;
129
130         if (this.children == null)
131             this.children = new Vector JavaDoc();
132     }
133
134     /**
135      * This method returns this object child objects.
136      *
137      * @return Vector - object item children.
138      */

139     public Vector JavaDoc getChildren() {
140         return this.children;
141     }
142
143     /**
144      * This method adds a new children node to the parent.
145      *
146      * @param item - the account item node being added to the parent.
147      */

148     public void addChild(AccountItem item) {
149         this.children.add(item);
150     }
151
152     /**
153      * This method removes a children node from the parent.
154      *
155      * @param item - the account item node being removed from the parent.
156      */

157     public void removeChild(AccountItem item) {
158         this.children.remove(item);
159     }
160
161 } //--------------------------------- E O F -----------------------------------
162

163
Popular Tags