source: 3thparty/jmessenger/src/nu/fw/jeti/jabber/elements/InfoQuery.java @ 3952

Revision 3952, 2.0 KB checked in by alexandrecorreia, 13 years ago (diff)

Ticket #1710 - Adicao do codigo fonte java do componente jmessenger(jabberit_messenger)

  • Property svn:executable set to *
Line 
1package nu.fw.jeti.jabber.elements;
2
3import nu.fw.jeti.jabber.JID;
4
5/**
6 * Info/Query, or IQ, is a simple request-response mechanism. Just as HTTP is a request-response medium,
7 * the iq element enables an entity to make a request of, and receive a response from, another entity.
8 * The data content of the request and response is defined by the namespace declaration of a
9 * direct child element of the iq element.
10 * @see <a href=http://www.jabber.org/ietf/draft-miller-xmpp-core-00.html#iq>xmpp-core</a>
11 * @author E.S. de Boer
12 * @version 1.0
13 */
14
15public class InfoQuery extends Packet
16{
17        private static int ids=0;
18        private String type;
19        private static String ID_PREFIX = "Jeti_" + Math.random() +"_";
20
21        public InfoQuery(String type,IQExtension ex)
22    {
23                this(null,type,ID_PREFIX + ids++,ex);
24    }
25
26    public InfoQuery(JID to,String type,IQExtension ex)
27    {
28                this(to,type,ID_PREFIX + ids++,ex);
29    }
30
31        public InfoQuery(JID to,String type,String id,IQExtension ex)
32    {
33                super(to,id,(Extension)ex);
34                if(super.id==null) super.id = ID_PREFIX + ids++;
35                this.type = type;
36    }
37   
38//      public InfoQuery(JID to,String type,String id,IQExtension ex,String error,int errorCode)
39//      {//TODO remove
40//              super(to,id,error,errorCode);
41//              type = "error";
42//      }
43       
44        public InfoQuery(JID to,String id,XMPPError error)
45        {
46                super(to,id,error);
47                if(super.id==null) super.id = ID_PREFIX + ids++;
48                type = "error";
49        }
50
51
52        protected InfoQuery(InfoQueryBuilder iqb)
53        {
54            super(iqb);
55            if(id==null) id = ID_PREFIX + ids++;
56                type = iqb.getType();
57        }
58
59        public String getType(){return type;}
60
61    public void appendToXML(StringBuffer xml)
62    {
63        xml.append("<iq");
64                appendBaseAttributes(xml);
65                appendAttribute(xml,"type",type);
66                if(getExtensions() == null && !"error".equals(getType()))
67                {//short cut
68                    xml.append("/>");
69                        return;
70                }
71                xml.append('>');
72                if("error".equals(type)) appendError(xml);
73                appendExtensions(xml);
74                xml.append("</iq>");
75    }
76}
77/*
78 * Overrides for emacs
79 * Local variables:
80 * tab-width: 4
81 * End:
82 */
Note: See TracBrowser for help on using the repository browser.