1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-26 14:02:06 +01:00

Use XmlStringBuilder for pubsub.Subscription

This commit is contained in:
Florian Schmaus 2018-03-21 14:46:53 +01:00
parent 2e4ce965cd
commit ffaca31178

View file

@ -16,6 +16,8 @@
*/ */
package org.jivesoftware.smackx.pubsub; package org.jivesoftware.smackx.pubsub;
import org.jivesoftware.smack.util.XmlStringBuilder;
/** /**
* Represents a subscription to node for both requests and replies. * Represents a subscription to node for both requests and replies.
* *
@ -134,22 +136,17 @@ public class Subscription extends NodeExtension
} }
@Override @Override
public String toXML() public XmlStringBuilder toXML()
{ {
StringBuilder builder = new StringBuilder("<subscription"); XmlStringBuilder builder = new XmlStringBuilder(this);
appendAttribute(builder, "jid", jid); builder.attribute("jid", jid);
if (getNode() != null) builder.optAttribute("node", getNode());
appendAttribute(builder, "node", getNode()); builder.optAttribute("subid", id);
builder.optAttribute("subscription", state.toString());
if (id != null) builder.closeEmptyElement();
appendAttribute(builder, "subid", id); return builder;
if (state != null)
appendAttribute(builder, "subscription", state.toString());
builder.append("/>");
return builder.toString();
} }
private static void appendAttribute(StringBuilder builder, String att, String value) private static void appendAttribute(StringBuilder builder, String att, String value)