Search in sources :

Example 81 with XmlStringBuilder

use of org.jivesoftware.smack.util.XmlStringBuilder in project Smack by igniterealtime.

the class IQ method toXML.

@Override
public final XmlStringBuilder toXML() {
    XmlStringBuilder buf = new XmlStringBuilder();
    buf.halfOpenElement(IQ_ELEMENT);
    addCommonAttributes(buf);
    if (type == null) {
        buf.attribute("type", "get");
    } else {
        buf.attribute("type", type.toString());
    }
    buf.rightAngleBracket();
    buf.append(getChildElementXML());
    buf.closeElement(IQ_ELEMENT);
    return buf;
}
Also used : XmlStringBuilder(org.jivesoftware.smack.util.XmlStringBuilder)

Example 82 with XmlStringBuilder

use of org.jivesoftware.smack.util.XmlStringBuilder in project Smack by igniterealtime.

the class Mechanisms method toXML.

@Override
public XmlStringBuilder toXML() {
    XmlStringBuilder xml = new XmlStringBuilder(this);
    xml.rightAngleBracket();
    for (String mechanism : mechanisms) {
        xml.element("mechanism", mechanism);
    }
    xml.closeElement(this);
    return xml;
}
Also used : XmlStringBuilder(org.jivesoftware.smack.util.XmlStringBuilder)

Example 83 with XmlStringBuilder

use of org.jivesoftware.smack.util.XmlStringBuilder in project Smack by igniterealtime.

the class Message method toXML.

@Override
public XmlStringBuilder toXML() {
    XmlStringBuilder buf = new XmlStringBuilder();
    buf.halfOpenElement(ELEMENT);
    addCommonAttributes(buf);
    buf.optAttribute("type", type);
    buf.rightAngleBracket();
    // Add the subject in the default language
    Subject defaultSubject = getMessageSubject(null);
    if (defaultSubject != null) {
        buf.element("subject", defaultSubject.subject);
    }
    // Add the subject in other languages
    for (Subject subject : getSubjects()) {
        // Skip the default language
        if (subject.equals(defaultSubject))
            continue;
        buf.append(subject.toXML());
    }
    // Add the body in the default language
    Body defaultBody = getMessageBody(null);
    if (defaultBody != null) {
        buf.element("body", defaultBody.message);
    }
    // Add the bodies in other languages
    for (Body body : getBodies()) {
        // Skip the default language
        if (body.equals(defaultBody))
            continue;
        buf.append(body.toXML());
    }
    buf.optElement("thread", thread);
    // Append the error subpacket if the message type is an error.
    if (type == Type.error) {
        appendErrorIfExists(buf);
    }
    // Add packet extensions, if any are defined.
    buf.append(getExtensionsXML());
    buf.closeElement(ELEMENT);
    return buf;
}
Also used : XmlStringBuilder(org.jivesoftware.smack.util.XmlStringBuilder)

Example 84 with XmlStringBuilder

use of org.jivesoftware.smack.util.XmlStringBuilder in project Smack by igniterealtime.

the class StartTls method toXML.

@Override
public XmlStringBuilder toXML() {
    XmlStringBuilder xml = new XmlStringBuilder(this);
    xml.rightAngleBracket();
    xml.condEmptyElement(required, "required");
    xml.closeElement(this);
    return xml;
}
Also used : XmlStringBuilder(org.jivesoftware.smack.util.XmlStringBuilder)

Example 85 with XmlStringBuilder

use of org.jivesoftware.smack.util.XmlStringBuilder in project Smack by igniterealtime.

the class XMPPError method toXML.

/**
     * Returns the error as XML.
     *
     * @return the error as XML.
     */
public XmlStringBuilder toXML() {
    XmlStringBuilder xml = new XmlStringBuilder();
    xml.halfOpenElement(ERROR);
    xml.attribute("type", type.toString());
    xml.optAttribute("by", errorGenerator);
    xml.rightAngleBracket();
    xml.halfOpenElement(condition.toString());
    xml.xmlnsAttribute(NAMESPACE);
    if (conditionText != null) {
        xml.rightAngleBracket();
        xml.escape(conditionText);
        xml.closeElement(condition.toString());
    } else {
        xml.closeEmptyElement();
    }
    addDescriptiveTextsAndExtensions(xml);
    xml.closeElement(ERROR);
    return xml;
}
Also used : XmlStringBuilder(org.jivesoftware.smack.util.XmlStringBuilder)

Aggregations

XmlStringBuilder (org.jivesoftware.smack.util.XmlStringBuilder)157 IQChildElementXmlStringBuilder (org.jivesoftware.smack.packet.IQ.IQChildElementXmlStringBuilder)6 Map (java.util.Map)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ObjectOutputStream (java.io.ObjectOutputStream)2 LinkedHashMap (java.util.LinkedHashMap)2 MultiMap (org.jivesoftware.smack.util.MultiMap)2 FormField (org.jivesoftware.smackx.xdata.FormField)2 IOException (java.io.IOException)1 Buffer (java.nio.Buffer)1 ByteBuffer (java.nio.ByteBuffer)1 SocketChannel (java.nio.channels.SocketChannel)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ListIterator (java.util.ListIterator)1 QName (javax.xml.namespace.QName)1 SelectionKeyAttachment (org.jivesoftware.smack.SmackReactor.SelectionKeyAttachment)1 XmppInputOutputFilter (org.jivesoftware.smack.XmppInputOutputFilter)1 SmackDebugger (org.jivesoftware.smack.debugger.SmackDebugger)1