Search in sources :

Example 31 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 32 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 33 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)

Example 34 with XmlStringBuilder

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

the class MUCInitialPresence method toXML.

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

Example 35 with XmlStringBuilder

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

the class MUCItem method toXML.

@Override
public XmlStringBuilder toXML() {
    XmlStringBuilder xml = new XmlStringBuilder(this);
    xml.optAttribute("affiliation", getAffiliation());
    xml.optAttribute("jid", getJid());
    xml.optAttribute("nick", getNick());
    xml.optAttribute("role", getRole());
    xml.rightAngleBracket();
    xml.optElement("reason", getReason());
    if (getActor() != null) {
        xml.halfOpenElement("actor").attribute("jid", getActor()).closeEmptyElement();
    }
    xml.closeElement(Stanza.ITEM);
    return xml;
}
Also used : XmlStringBuilder(org.jivesoftware.smack.util.XmlStringBuilder)

Aggregations

XmlStringBuilder (org.jivesoftware.smack.util.XmlStringBuilder)59 IQChildElementXmlStringBuilder (org.jivesoftware.smack.packet.IQ.IQChildElementXmlStringBuilder)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Element (org.jivesoftware.smack.packet.Element)1 ExtensionElement (org.jivesoftware.smack.packet.ExtensionElement)1 MultiMap (org.jivesoftware.smack.util.MultiMap)1 FormField (org.jivesoftware.smackx.xdata.FormField)1