From fda9408cf39ca59765c6813ea42115a2ce96cc30 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 5 Jul 2019 11:31:12 +0200 Subject: [PATCH] Use XmlStringBuilder in PubSub's SubscribeExtension --- .../smackx/pubsub/SubscribeExtension.java | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeExtension.java index b17db0af0..9c4a55b10 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeExtension.java @@ -16,6 +16,9 @@ */ package org.jivesoftware.smackx.pubsub; +import org.jivesoftware.smack.packet.XmlEnvironment; +import org.jivesoftware.smack.util.XmlStringBuilder; + import org.jxmpp.jid.Jid; /** @@ -41,19 +44,11 @@ public class SubscribeExtension extends NodeExtension { } @Override - public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) { - StringBuilder builder = new StringBuilder("<"); - builder.append(getElementName()); - - if (getNode() != null) { - builder.append(" node='"); - builder.append(getNode()); - builder.append('\''); - } - builder.append(" jid='"); - builder.append(getJid()); - builder.append("'/>"); - - return builder.toString(); + public XmlStringBuilder toXML(XmlEnvironment xmlEnvironment) { + XmlStringBuilder xml = new XmlStringBuilder(this, xmlEnvironment); + xml.optAttribute("node", getNode()); + xml.attribute("jid", getJid()); + xml.closeEmptyElement(); + return xml; } }