1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-23 04:22:05 +01:00

Improve XmlStringBuilder usage in Bytestream

This commit is contained in:
Florian Schmaus 2014-08-19 12:43:21 +02:00
parent 6021f8a8ce
commit 650da55b23

View file

@ -221,17 +221,13 @@ public class Bytestream extends IQ {
@Override @Override
public XmlStringBuilder getChildElementXML() { public XmlStringBuilder getChildElementXML() {
XmlStringBuilder xml = new XmlStringBuilder(); XmlStringBuilder xml = new XmlStringBuilder();
xml.halfOpenElement(IQ.QUERY_ELEMENT); xml.halfOpenElement(QUERY_ELEMENT);
xml.xmlnsAttribute(NAMESPACE); xml.xmlnsAttribute(NAMESPACE);
switch(getType()) { switch(getType()) {
case set: case set:
if (getSessionID() != null) { xml.optAttribute("sid", getSessionID());
xml.attribute("sid", getSessionID()); xml.optAttribute("mode", getMode());
}
if (getMode() != null) {
xml.attribute("mode", getMode());
}
xml.rightAngelBracket(); xml.rightAngelBracket();
if (getToActivate() == null) { if (getToActivate() == null) {
for (StreamHost streamHost : getStreamHosts()) { for (StreamHost streamHost : getStreamHosts()) {
@ -256,11 +252,13 @@ public class Bytestream extends IQ {
break; break;
case get: case get:
xml.closeEmptyElement(); xml.closeEmptyElement();
// Return here so that we don't run into the
// closeElement(QUERY_ELEMNT) section
return xml; return xml;
default: default:
throw new IllegalStateException(); throw new IllegalStateException();
} }
xml.closeElement(IQ.QUERY_ELEMENT); xml.closeElement(QUERY_ELEMENT);
return xml; return xml;
} }