1 | /* |
---|
2 | * Jeti, a Java Jabber client, Copyright (C) 2003 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 on 26-apr-2003 |
---|
23 | */ |
---|
24 | |
---|
25 | package nu.fw.jeti.jabber.elements; |
---|
26 | |
---|
27 | import java.util.Iterator; |
---|
28 | import java.util.List; |
---|
29 | |
---|
30 | import nu.fw.jeti.jabber.Backend; |
---|
31 | import nu.fw.jeti.jabber.JID; |
---|
32 | |
---|
33 | /** |
---|
34 | * @author E.S. de Boer |
---|
35 | * implements the http://jabber.org/protocol/disco#items'/ spec |
---|
36 | */ |
---|
37 | public class IQDiscoItems extends Extension implements IQExtension, DiscoveryItem |
---|
38 | { |
---|
39 | private String node; |
---|
40 | private List items; |
---|
41 | |
---|
42 | public IQDiscoItems() |
---|
43 | {} |
---|
44 | |
---|
45 | public IQDiscoItems(String node) |
---|
46 | { |
---|
47 | this.node = node; |
---|
48 | } |
---|
49 | |
---|
50 | public IQDiscoItems(String node,List items) |
---|
51 | { |
---|
52 | this.node = node; |
---|
53 | this.items = items; |
---|
54 | } |
---|
55 | |
---|
56 | public String getNode() |
---|
57 | { |
---|
58 | return node; |
---|
59 | } |
---|
60 | |
---|
61 | public Iterator getItems() |
---|
62 | { |
---|
63 | if (items == null)return null; |
---|
64 | return items.iterator(); |
---|
65 | } |
---|
66 | |
---|
67 | public int getSize() |
---|
68 | { |
---|
69 | if (items == null)return 0; |
---|
70 | return items.size(); |
---|
71 | } |
---|
72 | |
---|
73 | |
---|
74 | public boolean hasItems() |
---|
75 | { |
---|
76 | return items != null; |
---|
77 | } |
---|
78 | |
---|
79 | //---------------------------discoveryInfo implementation, returns null-------------- |
---|
80 | public JID getJID() |
---|
81 | { |
---|
82 | return null; |
---|
83 | } |
---|
84 | |
---|
85 | public String getName() |
---|
86 | { |
---|
87 | return null; |
---|
88 | } |
---|
89 | |
---|
90 | //---------------------------------------------------------------------------- |
---|
91 | |
---|
92 | |
---|
93 | |
---|
94 | public void execute(InfoQuery iq,Backend backend){} |
---|
95 | |
---|
96 | |
---|
97 | |
---|
98 | public void appendToXML(StringBuffer xml) |
---|
99 | { |
---|
100 | xml.append("<query xmlns= \"http://jabber.org/protocol/disco#items\""); |
---|
101 | appendAttribute(xml, "node", node); |
---|
102 | if (items == null) |
---|
103 | { //short cut |
---|
104 | xml.append("/>"); |
---|
105 | return; |
---|
106 | } |
---|
107 | xml.append('>'); |
---|
108 | if (items != null) |
---|
109 | { |
---|
110 | for (Iterator i = items.iterator(); i.hasNext();) |
---|
111 | { |
---|
112 | ((DiscoItem) i.next()).appendToXML(xml); |
---|
113 | } |
---|
114 | } |
---|
115 | xml.append("</query>"); |
---|
116 | } |
---|
117 | } |
---|
118 | |
---|
119 | /* |
---|
120 | * Overrides for emacs |
---|
121 | * Local variables: |
---|
122 | * tab-width: 4 |
---|
123 | * End: |
---|
124 | */ |
---|