source: branches/2.2/jabberit_messenger/java_source/src/nu/fw/jeti/backend/roster/JIDStatusGroup.java @ 3102

Revision 3102, 3.8 KB checked in by amuller, 14 years ago (diff)

Ticket #986 - Efetuado merge para o Branch 2.2( atualizacao do modulo)

  • Property svn:executable set to *
Line 
1/*
2 *      Jeti, a Java Jabber client, Copyright (C) 2001 E.S. de Boer 
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 *      For questions, comments etc,
19 *      use the website at http://jeti.jabberstudio.org
20 *  or mail/IM me at jeti@jabber.org
21 */
22
23package nu.fw.jeti.backend.roster;
24
25import java.util.ArrayList;
26import java.util.Collections;
27import java.util.Iterator;
28import java.util.List;
29
30import nu.fw.jeti.jabber.JIDStatus;
31
32/**
33 * Title:        im
34 * Description:
35 * Copyright:    Copyright (c) 2001
36 * Company:
37 * @author E.S. de Boer
38 * @version 1.0
39 */
40
41public class JIDStatusGroup implements Comparable
42{
43//      synchronized because used in event thread & jabberinput thread
44        private String name;
45        private List members;
46        private int onlines;
47
48        public JIDStatusGroup(String name)
49        {
50                this.name = name;
51                members = new ArrayList(16);
52        }
53
54        public synchronized int size()
55        {
56                return members.size();
57        }
58       
59//      public boolean isOffline()
60//      {
61//              for(Iterator i = members.iterator();i.hasNext();)
62//              {
63//                      if(((JIDStatus)i.next()).isOnline()) return false;             
64//              }
65//              return true;
66//      }
67       
68        public synchronized void addOnline() {onlines++;}
69       
70        public synchronized void removeOnline() {onlines--;}
71       
72        public synchronized int getOnlines() {return onlines;}
73                       
74        public Iterator iterator()
75        {
76                return new ArrayList(members).iterator();
77        }
78
79        /*
80        public void addJIDStatus(JIDStatus2 jid)
81        {
82                members.add(jid);
83                Collections.sort(members);
84        }
85        */
86       
87        public synchronized void addPrimaryJIDStatus(PrimaryJIDStatus jid)
88        {
89                members.add(jid);
90                Collections.sort(members);
91        }
92/*
93        public void sort()
94        {
95            Collections.sort(members);
96        }
97*/
98        public synchronized Object getPrimaryJIDStatus(int index)
99        {
100                return members.get(index);
101        }
102
103        /*
104        public  JIDStatus searchJID(JID jid)
105        {
106                for(int tel =0; tel<members.size();tel++)
107                {
108                        if (((JIDStatus)members.get(tel)).getJID().equals(jid)) return (JIDStatus)members.get(tel);
109                }
110                return null;
111        }
112        */
113
114        public synchronized PrimaryJIDStatus searchPrimaryJIDStatus(String nickname)
115        {
116                for(int tel =0; tel<members.size();tel++)
117                {
118                        PrimaryJIDStatus temp = (PrimaryJIDStatus)members.get(tel);
119                        if (temp.getNick().equals(nickname)) return temp;
120                }
121                return null;
122        }
123
124        /*
125        public boolean remove(JID jid)
126        {
127                for(int tel =0; tel<members.size();tel++)
128                {
129                        if (((JIDStatus)members.get(tel)).getJID().equals(jid))
130                        {
131                             members.remove(tel);
132                                 return true;
133                        }
134                }
135                return false;
136        }
137        */
138
139        public synchronized void removePrimaryJIDStatus(PrimaryJIDStatus primary)
140        {
141                members.remove(primary);
142        }
143
144        public synchronized int indexOfPrimaryJIDStatus(Object jidPrimaryStatus)
145        {
146            return members.indexOf(jidPrimaryStatus);
147        }
148
149        public String getName()
150        {
151                return name;
152        }
153
154        public String toString()
155        {
156                return name;
157        }
158
159        public boolean equals(Object object)
160        {//als name is gelijk object is gelijk
161                if(!(object instanceof JIDStatusGroup)) return false;
162                return name.equals(((JIDStatusGroup)object).name);
163        }
164       
165        public int hashCode()
166        {
167                return name.hashCode();
168        }
169
170        public int compareTo(Object o)
171        {
172                return name.compareTo(((JIDStatusGroup)o).name);
173        }
174}
175/*
176 * Overrides for emacs
177 * Local variables:
178 * tab-width: 4
179 * End:
180 */
Note: See TracBrowser for help on using the repository browser.