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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations