KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > adminGui > feature > account > groups > GroupItem


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.groups;
8
9 import java.util.Vector JavaDoc;
10
11 import org.ozoneDB.adminGui.feature.account.AccountItem;
12 import org.ozoneDB.adminGui.feature.account.users.UserItem;
13
14
15 //#############################################################################
16
/**
17  * This class creates groups objects that are loaded into the Groups tree.
18  *
19  * @author <p align=center>Ibsen Ramos-Bonilla
20  * <br>Copyright &copy 1997-@year@ by SMB GmbH. All Rights Reserved.</p>
21  *
22  * @version 1.0
23  */

24 //#############################################################################
25

26 public class GroupItem extends AccountItem {
27
28     /**
29      * Overloaded constructor initializes the a new item.
30      *
31      * @param name - the item name.
32      * @param id - the item id.
33      */

34     public GroupItem(String JavaDoc name, int id) {
35         super(name, id);
36     }
37
38     /**
39      * This method returns a list of names of users assigned to this group.
40      *
41      * @return Vector - list of account names.
42      */

43     public Vector JavaDoc getAssignedUsers() {
44         Vector JavaDoc users = new Vector JavaDoc();
45
46         //get all the assigned account names
47
for (int i = 0; i < this.getChildCount(); i++) {
48             users.add(this.getChildAt(i).toString());
49         }
50
51         return users;
52     }
53
54     /**
55      * This method returns an account assigned to this group based on the account
56      * name.
57      *
58      * @param name - the account name to look for.
59      * @return UserItem - the account node.
60      */

61     public UserItem getUser(String JavaDoc name) {
62         UserItem uItem = null;
63
64         if (name != null) {
65             for (int i = 0; i < this.getChildCount(); i++) {
66                 if (this.getChildAt(i).toString().equals(name)) {
67                     uItem = (UserItem) this.getChildAt(i);
68                     break;
69                 }
70             }
71         }
72         return uItem;
73     }
74
75 } //--------------------------------- E O F -----------------------------------
76

77
Popular Tags