package nu.fw.jeti.jabber.elements;
import nu.fw.jeti.jabber.JID;
/**
* Info/Query, or IQ, is a simple request-response mechanism. Just as HTTP is a request-response medium,
* the iq element enables an entity to make a request of, and receive a response from, another entity.
* The data content of the request and response is defined by the namespace declaration of a
* direct child element of the iq element.
* @see xmpp-core
* @author E.S. de Boer
* @version 1.0
*/
public class InfoQuery extends Packet
{
private static int ids=0;
private String type;
private static String ID_PREFIX = "Jeti_" + Math.random() +"_";
public InfoQuery(String type,IQExtension ex)
{
this(null,type,ID_PREFIX + ids++,ex);
}
public InfoQuery(JID to,String type,IQExtension ex)
{
this(to,type,ID_PREFIX + ids++,ex);
}
public InfoQuery(JID to,String type,String id,IQExtension ex)
{
super(to,id,(Extension)ex);
if(super.id==null) super.id = ID_PREFIX + ids++;
this.type = type;
}
// public InfoQuery(JID to,String type,String id,IQExtension ex,String error,int errorCode)
// {//TODO remove
// super(to,id,error,errorCode);
// type = "error";
// }
public InfoQuery(JID to,String id,XMPPError error)
{
super(to,id,error);
if(super.id==null) super.id = ID_PREFIX + ids++;
type = "error";
}
protected InfoQuery(InfoQueryBuilder iqb)
{
super(iqb);
if(id==null) id = ID_PREFIX + ids++;
type = iqb.getType();
}
public String getType(){return type;}
public void appendToXML(StringBuffer xml)
{
xml.append("");
return;
}
xml.append('>');
if("error".equals(type)) appendError(xml);
appendExtensions(xml);
xml.append("");
}
}
/*
* Overrides for emacs
* Local variables:
* tab-width: 4
* End:
*/