Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/wilko/jaim/Group.java


1   /*
2    *   (C) 2002 Paul Wilkinson  wilko@users.sourceforge.net
3    *
4    *   This program is free software; you can redistribute it and/or modify
5    *   it under the terms of the GNU General Public License as published by
6    *   the Free Software Foundation; either version 2 of the License, or
7    *   (at your option) any later version.
8    *
9    *   This program is distributed in the hope that it will be useful,
10   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   *   GNU General Public License for more details.
13   *
14   *   You should have received a copy of the GNU General Public License
15   *   along with this program; if not, write to the Free Software
16   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17   *
18   */
19  
20  /*
21   * Group.java
22   *
23   * Created on 4 May 2002, 12:05
24   */
25  
26  package com.wilko.jaim;
27  
28  import java.util.Vector;
29  import java.util.List;
30  import java.util.Enumeration;
31  
32  /** This is a logical user group.  It holds a set of users.
33   * @author Brett Humphreys
34   */
35  public class Group {
36      
37      /** Vector of buddies for this group */
38      private Vector buddies = new Vector();
39      
40      /** Name of this group */
41      private String groupName;
42      
43      /** This constructor sets the name of the group
44       * @param name the group name
45       */
46      public Group( String name ) {
47          groupName = name;
48      }
49      
50      /** This method adds a buddy to the end of the group
51       * @param buddy The buddy object to associate with this group
52       */
53      public void addBuddy(Buddy buddy) {
54          buddies.add(buddy);
55      }
56      
57      /** This method adds a buddy to the specified location in the group
58       *  If the specified location is beyond the end of the group, then the buddy is added to the end of the group
59       * @param buddy The buddy object to associate with this group
60       * @param pos the position to add the buddy
61       */
62      public void addBuddy(Buddy buddy,int pos) {
63          if (pos > buddies.size()) {
64              buddies.add(buddy);
65          }
66          else {
67              buddies.add(pos,buddy);
68          }
69      }
70      
71      /** This method gets the group name
72       * @return the group name
73       */
74      public String getName() {
75          return groupName;
76      }
77      
78      /** This method returns the buddies in this group
79       * @return an Enumeration of {@link Buddy} objects
80       */
81      public Enumeration enumerateBuddies() {
82          return buddies.elements();
83      }
84      
85      /** This method returns the number of buddies in this group
86       * @return buddy count
87       */
88      public int getBuddyCount() {
89          return(buddies.size());
90      }
91  
92      /** This method returns the buddies in this group
93       * @return a Collection of {@link Buddy} objects     
94       */
95      public java.util.Collection getBuddies() {
96          java.util.Collection cReturn = new java.util.Vector(buddies);
97          return cReturn;
98      }
99  
100 }