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

Quick Search    Search Deep

Source code: com/jabberwookie/ns/jabber/iq/DiscoInfo.java


1   /*
2    * DiscoInfo.java
3    *
4    * Created on June 24, 2003, 6:19 PM
5    * Copyright (c) 2003, Sean M. Meiners, sean@jabberwookie.com
6    * All rights reserved.
7    * 
8    * Redistribution and use in source and binary forms, with or without
9    * modification, are permitted provided that the following conditions are met:
10   * 
11   *     * Redistributions of source code must retain the above copyright notice,
12   *       this list of conditions and the following disclaimer.
13   *     * Redistributions in binary form must reproduce the above copyright notice,
14   *       this list of conditions and the following disclaimer in the documentation
15   *       and/or other materials provided with the distribution.
16   *     * Neither the name of JabberWookie nor the names of its contributors may be used
17   *       to endorse or promote products derived from this software without specific
18   *       prior written permission.
19   * 
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22   * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
24   * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
27   * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29   * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30   */
31  
32  package com.jabberwookie.ns.jabber.iq;
33  
34  import java.util.Vector;
35  import java.util.Hashtable;
36  
37  import com.ssttr.xml.XMLElement;
38  
39  /**
40   * This class and its sister-class DiscoItems implement the namspaces described in JEP-0030
41   * which can currently be found at <a href="http://www.jabber.org/jeps/jep-0030.html">http://www.jabber.org/jeps/jep-0030.html</a>.
42   * @author  smeiners
43   */
44  public class DiscoInfo
45  extends Query
46  {
47      public  static final String     NAMESPACE = "http://jabber.org/protocol/disco#info";
48      
49      /** Creates a new instance of DiscoInfo */
50      public DiscoInfo ()
51      {
52          setNameSpace(NAMESPACE);
53      }
54      
55      public String getNode()
56      { return getAttribute("node"); }
57      
58      public void setNode(String node)
59      { setAttribute("node",node); }
60      
61      public Vector getIdentities()
62      { return getChildren("identity"); }
63      
64      public Vector getFeatures()
65      { return getChildren("feature"); }
66      
67      public Vector getAll()
68      { return getChildren(); }
69      
70      public XMLElement addChild(String tag)
71      {
72          return null;
73      }
74      
75      public XMLElement addChild(String tag, Hashtable attrs)
76      {
77          if( tag.equals("identity") )
78          {
79              final Identity i = new Identity(attrs);
80              addChild(i);
81              return i;
82          }
83          
84          if( tag.equals("feature") )
85          {
86              final Feature i = new Feature(attrs);
87              addChild(i);
88              return i;
89          }
90          
91          return null;
92      }
93      
94      public void addChild(XMLElement child)
95      {
96          if( child instanceof DiscoInfo.Identity || child instanceof DiscoInfo.Feature )
97              super.addChild(child);
98      }
99      
100     public Identity addIdentity()
101     {
102         Identity i = new Identity();
103         addChild(i);
104         return i;
105     }
106     
107     public Identity addIdentity(String category)
108     {
109         Identity i = new Identity(category);
110         addChild(i);
111         return i;
112     }
113     
114     public Identity addIdentity(String category, String type)
115     {
116         Identity i = new Identity(category,type);
117         addChild(i);
118         return i;
119     }
120     
121     public Identity addIdentity(String category, String type, String name)
122     {
123         Identity i = new Identity(category,type,name);
124         addChild(i);
125         return i;
126     }
127     
128     public Feature addFeature(String var)
129     {
130         Feature f = new Feature(var);
131         addChild(f);
132         return f;
133     }
134 
135     public class Identity
136     extends XMLElement
137     {
138         Identity()
139         { super("identity"); }
140         
141         public Identity(Hashtable attrs)
142         { super("identity",attrs); }
143         
144         public Identity(String category)
145         { this(); setCategory(category); }
146      
147         public Identity(String category, String type)
148         { this(); setCategory(category); setType(type); }
149      
150         public Identity(String category, String type, String name)
151         { this(); setCategory(category); setType(type); setName(name); }
152      
153         public String getCategory()
154         { return getAttribute("category"); }
155         
156         public void setCategory(String category)
157         { setAttribute("category",category); }
158         
159         public String getIdentityName()
160         { return getAttribute("name"); }
161         
162         public void setIdentityName(String name)
163         { setAttribute("name",name); }
164         
165         public String getType()
166         { return getAttribute("type"); }
167         
168         public void setType(String type)
169         { setAttribute("type",type); }
170         
171         public XMLElement addChild(String tag)
172         { return null; }
173 
174         public XMLElement addChild(String tag, Hashtable attrs)
175         { return null; }
176 
177         public void addChild(XMLElement child)
178         { }
179 
180     }
181     
182     public class Feature
183     extends XMLElement
184     {
185         private Feature()
186         { super("feature"); }
187         
188         public Feature(Hashtable attrs)
189         { super("feature",attrs); }
190         
191         public Feature(String var)
192         { this(); setVar(var); }
193         
194         public String getVar()
195         { return getAttribute("var"); }
196         
197         public void setVar(String var)
198         { setAttribute("var",var); }
199 
200         public XMLElement addChild(String tag)
201         { return null; }
202 
203         public XMLElement addChild(String tag, Hashtable attrs)
204         { return null; }
205 
206         public void addChild(XMLElement child)
207         { }
208 
209     }
210     
211 }