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 | * Created in 2002 |
---|
23 | */ |
---|
24 | |
---|
25 | package nu.fw.jeti.backend.roster; |
---|
26 | |
---|
27 | |
---|
28 | import java.util.List; |
---|
29 | |
---|
30 | import nu.fw.jeti.jabber.JID; |
---|
31 | import nu.fw.jeti.jabber.JIDStatus; |
---|
32 | |
---|
33 | |
---|
34 | /** |
---|
35 | * @author E.S. de Boer |
---|
36 | */ |
---|
37 | |
---|
38 | public class ResourceJIDStatus extends SecondaryJIDStatus implements Cloneable |
---|
39 | { |
---|
40 | private NormalJIDStatus normalJIDStatus; |
---|
41 | |
---|
42 | public ResourceJIDStatus(JID jid,NormalJIDStatus normalJIDStatus) |
---|
43 | { |
---|
44 | this.completeJID = jid; |
---|
45 | this.normalJIDStatus = normalJIDStatus; |
---|
46 | } |
---|
47 | |
---|
48 | void update(JID jid,int show, String status,boolean online) |
---|
49 | { |
---|
50 | this.online = online; |
---|
51 | this.show = show; |
---|
52 | this.status = status; |
---|
53 | this.completeJID = jid; |
---|
54 | } |
---|
55 | |
---|
56 | public String toString() |
---|
57 | {//jid |
---|
58 | return completeJID.toString(); |
---|
59 | } |
---|
60 | |
---|
61 | public JIDStatus normalJIDStatus() |
---|
62 | { |
---|
63 | return normalJIDStatus; |
---|
64 | } |
---|
65 | |
---|
66 | public JID getJID(){return normalJIDStatus.getJID();} |
---|
67 | |
---|
68 | |
---|
69 | |
---|
70 | public String getNick() |
---|
71 | { |
---|
72 | return normalJIDStatus.getNick(); |
---|
73 | } |
---|
74 | |
---|
75 | public String getType() |
---|
76 | { |
---|
77 | return normalJIDStatus.getType(); |
---|
78 | } |
---|
79 | |
---|
80 | public String getSubscription(){return normalJIDStatus.getSubscription();} |
---|
81 | |
---|
82 | public String getWaiting() |
---|
83 | { |
---|
84 | return normalJIDStatus.getWaiting(); |
---|
85 | } |
---|
86 | |
---|
87 | public List getGroupsCopy(){return normalJIDStatus.getGroupsCopy();} |
---|
88 | |
---|
89 | public int groupCount(){return normalJIDStatus.groupCount();} |
---|
90 | |
---|
91 | public boolean isGroupPresent(String group){return normalJIDStatus.isGroupPresent(group);} |
---|
92 | |
---|
93 | public int compareTo(Object o) |
---|
94 | {//compare jid |
---|
95 | //if(nickname==null) return -1; |
---|
96 | //return nickname.compareTo(((JIDStatus2)o).nickname); |
---|
97 | if(!(o instanceof ResourceJIDStatus)) return normalJIDStatus.compareTo(this,(JIDStatus)o); |
---|
98 | ResourceJIDStatus resourceJIDStatus = (ResourceJIDStatus)o; |
---|
99 | if(this.equals(resourceJIDStatus)) return 0; |
---|
100 | int result = (normalJIDStatus.compareTo(this,resourceJIDStatus)); |
---|
101 | if(result == 0) |
---|
102 | { |
---|
103 | return completeJID.getResource().compareTo(resourceJIDStatus.getCompleteJID().getResource()); |
---|
104 | } |
---|
105 | return result; |
---|
106 | } |
---|
107 | |
---|
108 | |
---|
109 | |
---|
110 | public Object clone() |
---|
111 | {//shallow copy |
---|
112 | try |
---|
113 | { |
---|
114 | return super.clone(); |
---|
115 | } |
---|
116 | catch (CloneNotSupportedException ex) |
---|
117 | { |
---|
118 | ex.printStackTrace(); |
---|
119 | return null; |
---|
120 | } |
---|
121 | } |
---|
122 | } |
---|
123 | |
---|
124 | /* |
---|
125 | * Overrides for emacs |
---|
126 | * Local variables: |
---|
127 | * tab-width: 4 |
---|
128 | * End: |
---|
129 | */ |
---|