From 726a2de273f242c2bc246808ae6a9097d29fcfdf Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 2 Jun 2019 10:44:50 +0200 Subject: [PATCH] Deprecate ParserUtils.getQName() --- .../jivesoftware/smack/util/ParserUtils.java | 18 ++++++++++-------- .../smackx/pubsub/SimplePayload.java | 3 +-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/ParserUtils.java b/smack-core/src/main/java/org/jivesoftware/smack/util/ParserUtils.java index 61a56e0f3..e69d65b3c 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/ParserUtils.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/ParserUtils.java @@ -23,7 +23,6 @@ import java.text.ParseException; import java.util.Date; import java.util.Locale; -import javax.xml.XMLConstants; import javax.xml.namespace.QName; import org.jivesoftware.smack.parsing.SmackParsingException; @@ -323,13 +322,16 @@ public class ParserUtils { return parser.getAttributeValue("http://www.w3.org/XML/1998/namespace", "lang"); } + /** + * Get the QName of the current element. + * + * @param parser the parser. + * @return the Qname. + * @deprecated use {@link XmlPullParser#getQName()} instead. + */ + @Deprecated + // TODO: Remove in Smack 4.5 public static QName getQName(XmlPullParser parser) { - String elementName = parser.getName(); - String prefix = parser.getPrefix(); - if (prefix == null) { - prefix = XMLConstants.DEFAULT_NS_PREFIX; - } - String namespace = parser.getNamespace(); - return new QName(namespace, elementName, prefix); + return parser.getQName(); } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SimplePayload.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SimplePayload.java index 5459a91d1..4d1089ed5 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SimplePayload.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SimplePayload.java @@ -22,7 +22,6 @@ import javax.xml.namespace.QName; import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.util.PacketParserUtils; -import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.xml.XmlPullParser; import org.jivesoftware.smack.xml.XmlPullParserException; @@ -52,7 +51,7 @@ public class SimplePayload implements ExtensionElement { catch (XmlPullParserException | IOException e) { throw new AssertionError(e); } - QName qname = ParserUtils.getQName(parser); + QName qname = parser.getQName(); payload = xmlPayload;