mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-09 10:19:41 +02:00
Do not have Stanza.getExtension(String, String) return a generic type
Returning a generic would allow for List<ExtensionElement> list = stanza.getExtension("foo", "bar"); to compile (Note the we are calling getExtension(), not getExtension*s*()). Users are encouraged to use the type safe getExtension(Class<? extends ExtensionElement) variant instead. Fixes SMACK-825.
This commit is contained in:
parent
62916b8490
commit
07da9ffb48
65 changed files with 207 additions and 121 deletions
|
@ -203,7 +203,7 @@ public class MultipleRecipientManager {
|
|||
* if none was found.
|
||||
*/
|
||||
public static MultipleRecipientInfo getMultipleRecipientInfo(Stanza packet) {
|
||||
MultipleAddresses extension = packet.getExtension(MultipleAddresses.ELEMENT, MultipleAddresses.NAMESPACE);
|
||||
MultipleAddresses extension = packet.getExtension(MultipleAddresses.class);
|
||||
return extension == null ? null : new MultipleRecipientInfo(extension);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ package org.jivesoftware.smackx.address.packet;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
|
@ -34,6 +36,7 @@ public class MultipleAddresses implements ExtensionElement {
|
|||
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/address";
|
||||
public static final String ELEMENT = "addresses";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
public enum Type {
|
||||
bcc,
|
||||
|
|
|
@ -91,7 +91,7 @@ public class BoBExtension extends XHTMLExtension {
|
|||
}
|
||||
|
||||
public static BoBExtension from(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
return (BoBExtension) message.getExtension(ELEMENT, NAMESPACE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -535,8 +535,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
public void processStanza(Stanza packet) {
|
||||
// get data packet extension
|
||||
DataPacketExtension data = packet.getExtension(
|
||||
DataPacketExtension.ELEMENT,
|
||||
DataPacketExtension.NAMESPACE);
|
||||
DataPacketExtension.class);
|
||||
|
||||
// check if encoded data is valid
|
||||
if (data.getDecodedData() == null) {
|
||||
|
@ -590,8 +589,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
} else {
|
||||
// stanza contains data packet extension
|
||||
data = packet.getExtension(
|
||||
DataPacketExtension.ELEMENT,
|
||||
DataPacketExtension.NAMESPACE);
|
||||
DataPacketExtension.class);
|
||||
if (data == null) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.ibb.packet;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.IQ.IQChildElementXmlStringBuilder;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
@ -39,6 +41,8 @@ public class DataPacketExtension implements ExtensionElement {
|
|||
*/
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/ibb";
|
||||
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
/* unique session ID identifying this In-Band Bytestream */
|
||||
private final String sessionID;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2009 Jonas Ådahl, 2011-2014 Florian Schmaus
|
||||
* Copyright © 2009 Jonas Ådahl, 2011-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.caps.packet;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
@ -26,6 +28,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
|
|||
public class CapsExtension implements ExtensionElement {
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/caps";
|
||||
public static final String ELEMENT = "c";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final String node, ver, hash;
|
||||
|
||||
|
@ -77,6 +80,6 @@ public class CapsExtension implements ExtensionElement {
|
|||
}
|
||||
|
||||
public static CapsExtension from(Stanza stanza) {
|
||||
return stanza.getExtension(ELEMENT, NAMESPACE);
|
||||
return stanza.getExtension(CapsExtension.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014 Florian Schmaus
|
||||
* Copyright © 2014-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -18,6 +18,8 @@ package org.jivesoftware.smackx.delay;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
||||
|
@ -34,6 +36,7 @@ public class DelayInformationManager {
|
|||
|
||||
public static final String LEGACY_DELAYED_DELIVERY_NAMESPACE = "jabber:x:delay";
|
||||
public static final String LEGACY_DELAYED_DELIVERY_ELEMENT = "x";
|
||||
public static final QName QNAME = new QName(LEGACY_DELAYED_DELIVERY_NAMESPACE, LEGACY_DELAYED_DELIVERY_ELEMENT);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -57,7 +60,7 @@ public class DelayInformationManager {
|
|||
* @return the Delayed Delivery information or <code>null</code>
|
||||
*/
|
||||
public static DelayInformation getLegacyDelayInformation(Stanza packet) {
|
||||
return packet.getExtension(LEGACY_DELAYED_DELIVERY_ELEMENT, LEGACY_DELAYED_DELIVERY_NAMESPACE);
|
||||
return packet.getExtension(DelayInformation.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,8 @@ package org.jivesoftware.smackx.delay.packet;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
@ -39,6 +41,7 @@ import org.jxmpp.util.XmppDateTime;
|
|||
public class DelayInformation implements ExtensionElement {
|
||||
public static final String ELEMENT = "delay";
|
||||
public static final String NAMESPACE = "urn:xmpp:delay";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final Date stamp;
|
||||
private final String from;
|
||||
|
@ -129,6 +132,6 @@ public class DelayInformation implements ExtensionElement {
|
|||
* @return the DelayInformation or null
|
||||
*/
|
||||
public static DelayInformation from(Stanza packet) {
|
||||
return packet.getExtension(ELEMENT, NAMESPACE);
|
||||
return packet.getExtension(DelayInformation.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
@ -36,6 +38,7 @@ import org.jivesoftware.smackx.delay.packet.DelayInformation;
|
|||
public class Forwarded implements ExtensionElement {
|
||||
public static final String NAMESPACE = "urn:xmpp:forward:0";
|
||||
public static final String ELEMENT = "forwarded";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final DelayInformation delay;
|
||||
private final Stanza forwardedPacket;
|
||||
|
@ -115,7 +118,7 @@ public class Forwarded implements ExtensionElement {
|
|||
* @return the Forwarded extension or null
|
||||
*/
|
||||
public static Forwarded from(Stanza packet) {
|
||||
return packet.getExtension(ELEMENT, NAMESPACE);
|
||||
return packet.getExtension(Forwarded.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -274,7 +274,7 @@ public final class GeoLocation implements Serializable, ExtensionElement, FormFi
|
|||
}
|
||||
|
||||
public static GeoLocation from(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
return message.getExtension(GeoLocation.class);
|
||||
}
|
||||
|
||||
public static GeoLocation from(FormField formField) {
|
||||
|
|
|
@ -95,7 +95,7 @@ public class JivePropertiesManager {
|
|||
*/
|
||||
public static Object getProperty(StanzaView packet, String name) {
|
||||
Object res = null;
|
||||
JivePropertiesExtension jpe = (JivePropertiesExtension) packet.getExtension(JivePropertiesExtension.QNAME);
|
||||
JivePropertiesExtension jpe = packet.getExtension(JivePropertiesExtension.class);
|
||||
if (jpe != null) {
|
||||
res = jpe.getProperty(name);
|
||||
}
|
||||
|
|
|
@ -213,6 +213,6 @@ public class JivePropertiesExtension implements ExtensionElement {
|
|||
* @since 4.2
|
||||
*/
|
||||
public static JivePropertiesExtension from(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
return message.getExtension(JivePropertiesExtension.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ package org.jivesoftware.smackx.last_interaction.element;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.util.Objects;
|
||||
|
@ -27,6 +29,7 @@ public class IdleElement implements ExtensionElement {
|
|||
|
||||
public static final String NAMESPACE = "urn:xmpp:idle:1";
|
||||
public static final String ELEMENT = "idle";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
public static final String ATTR_SINCE = "since";
|
||||
|
||||
private final Date since;
|
||||
|
@ -70,7 +73,7 @@ public class IdleElement implements ExtensionElement {
|
|||
* @return idleElement from presence or null
|
||||
*/
|
||||
public static IdleElement fromPresence(Presence presence) {
|
||||
return presence.getExtension(ELEMENT, NAMESPACE);
|
||||
return presence.getExtension(IdleElement.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.message_correct.element;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
@ -44,6 +46,8 @@ public class MessageCorrectExtension implements ExtensionElement {
|
|||
*/
|
||||
public static final String NAMESPACE = "urn:xmpp:message-correct:0";
|
||||
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
/**
|
||||
* The id tag of a 'message correct' extension.
|
||||
*/
|
||||
|
@ -81,7 +85,7 @@ public class MessageCorrectExtension implements ExtensionElement {
|
|||
}
|
||||
|
||||
public static MessageCorrectExtension from(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
return message.getExtension(MessageCorrectExtension.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.mood.element;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.FullyQualifiedElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
|
@ -36,6 +38,8 @@ public class MoodElement implements ExtensionElement {
|
|||
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/mood";
|
||||
public static final String ELEMENT = "mood";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
public static final String ELEM_TEXT = "text";
|
||||
|
||||
private final MoodSubjectElement mood;
|
||||
|
@ -136,7 +140,7 @@ public class MoodElement implements ExtensionElement {
|
|||
* @return {@link MoodElement} or null.
|
||||
*/
|
||||
public static MoodElement fromMessage(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
return message.getExtension(MoodElement.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.jivesoftware.smackx.muc.packet;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
|
@ -68,6 +70,8 @@ public class GroupChatInvitation implements ExtensionElement {
|
|||
*/
|
||||
public static final String NAMESPACE = "jabber:x:conference";
|
||||
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final String roomAddress;
|
||||
|
||||
/**
|
||||
|
@ -128,7 +132,7 @@ public class GroupChatInvitation implements ExtensionElement {
|
|||
* @return the GroupChatInvitation or null
|
||||
*/
|
||||
public static GroupChatInvitation from(Stanza packet) {
|
||||
return packet.getExtension(ELEMENT, NAMESPACE);
|
||||
return packet.getExtension(GroupChatInvitation.class);
|
||||
}
|
||||
|
||||
public static class Provider extends ExtensionElementProvider<GroupChatInvitation> {
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.jivesoftware.smackx.muc.packet;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
@ -42,6 +44,7 @@ public class MUCInitialPresence implements ExtensionElement {
|
|||
|
||||
public static final String ELEMENT = "x";
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/muc";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
// TODO make those fields final once deprecated setter methods have been removed.
|
||||
private String password;
|
||||
|
@ -156,7 +159,7 @@ public class MUCInitialPresence implements ExtensionElement {
|
|||
* @return the MUCInitialPresence PacketExtension or {@code null}
|
||||
*/
|
||||
public static MUCInitialPresence from(Stanza packet) {
|
||||
return packet.getExtension(ELEMENT, NAMESPACE);
|
||||
return packet.getExtension(MUCInitialPresence.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,6 +22,8 @@ import java.util.HashSet;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
@ -41,6 +43,7 @@ public class MUCUser implements ExtensionElement {
|
|||
|
||||
public static final String ELEMENT = "x";
|
||||
public static final String NAMESPACE = MUCInitialPresence.NAMESPACE + "#user";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final Set<Status> statusCodes = new HashSet<>(4);
|
||||
|
||||
|
@ -236,7 +239,7 @@ public class MUCUser implements ExtensionElement {
|
|||
* @return the MUCUser PacketExtension or {@code null}
|
||||
*/
|
||||
public static MUCUser from(Stanza packet) {
|
||||
return packet.getExtension(ELEMENT, NAMESPACE);
|
||||
return packet.getExtension(MUCUser.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -159,8 +159,7 @@ public class OfflineMessageManager {
|
|||
StanzaFilter messageFilter = new AndFilter(PACKET_FILTER, new StanzaFilter() {
|
||||
@Override
|
||||
public boolean accept(Stanza packet) {
|
||||
OfflineMessageInfo info = packet.getExtension("offline",
|
||||
namespace);
|
||||
OfflineMessageInfo info = packet.getExtension(OfflineMessageInfo.class);
|
||||
return nodes.contains(info.getNode());
|
||||
}
|
||||
});
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.jivesoftware.smackx.pubsub;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
@ -44,6 +46,8 @@ public class EventElement implements EmbeddedPacketExtension {
|
|||
*/
|
||||
public static final String NAMESPACE = PubSubNamespace.event.getXmlns();
|
||||
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final EventElementType type;
|
||||
private final NodeExtension ext;
|
||||
|
||||
|
@ -85,6 +89,6 @@ public class EventElement implements EmbeddedPacketExtension {
|
|||
}
|
||||
|
||||
public static EventElement from(Stanza stanza) {
|
||||
return stanza.getExtension(ELEMENT, NAMESPACE);
|
||||
return stanza.getExtension(EventElement.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -656,7 +656,7 @@ public abstract class Node {
|
|||
|
||||
|
||||
private static List<String> getSubscriptionIds(Stanza packet) {
|
||||
HeadersExtension headers = packet.getExtension("headers", "http://jabber.org/protocol/shim");
|
||||
HeadersExtension headers = packet.getExtension(HeadersExtension.class);
|
||||
List<String> values = null;
|
||||
|
||||
if (headers != null) {
|
||||
|
@ -686,7 +686,7 @@ public abstract class Node {
|
|||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void processStanza(Stanza packet) {
|
||||
EventElement event = packet.getExtension("event", PubSubNamespace.event.getXmlns());
|
||||
EventElement event = (EventElement) packet.getExtension("event", PubSubNamespace.event.getXmlns());
|
||||
ItemsExtension itemsElem = (ItemsExtension) event.getEvent();
|
||||
ItemPublishEvent eventItems = new ItemPublishEvent(itemsElem.getNode(), itemsElem.getItems(), getSubscriptionIds(packet), DelayInformationManager.getDelayTimestamp(packet));
|
||||
// TODO: Use AsyncButOrdered (with Node as Key?)
|
||||
|
@ -710,7 +710,7 @@ public abstract class Node {
|
|||
@Override
|
||||
public void processStanza(Stanza packet) {
|
||||
// CHECKSTYLE:OFF
|
||||
EventElement event = packet.getExtension("event", PubSubNamespace.event.getXmlns());
|
||||
EventElement event = (EventElement) packet.getExtension("event", PubSubNamespace.event.getXmlns());
|
||||
|
||||
List<ExtensionElement> extList = event.getExtensions();
|
||||
|
||||
|
@ -749,7 +749,7 @@ public abstract class Node {
|
|||
|
||||
@Override
|
||||
public void processStanza(Stanza packet) {
|
||||
EventElement event = packet.getExtension("event", PubSubNamespace.event.getXmlns());
|
||||
EventElement event = (EventElement) packet.getExtension("event", PubSubNamespace.event.getXmlns());
|
||||
ConfigurationEvent config = (ConfigurationEvent) event.getEvent();
|
||||
|
||||
// TODO: Use AsyncButOrdered (with Node as Key?)
|
||||
|
|
|
@ -25,6 +25,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.Manager;
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
|
@ -213,7 +215,8 @@ public final class PubSubManager extends Manager {
|
|||
*/
|
||||
public LeafNode createNode() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
PubSub reply = sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.CREATE), null);
|
||||
NodeExtension elem = reply.getExtension("create", PubSubNamespace.basic.getXmlns());
|
||||
QName qname = new QName(PubSubNamespace.basic.getXmlns(), "create");
|
||||
NodeExtension elem = (NodeExtension) reply.getExtension(qname);
|
||||
|
||||
LeafNode newNode = new LeafNode(this, elem.getNode());
|
||||
nodeMap.put(newNode.getId(), newNode);
|
||||
|
@ -500,7 +503,7 @@ public final class PubSubManager extends Manager {
|
|||
*/
|
||||
public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
Stanza reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS), null);
|
||||
SubscriptionsExtension subElem = reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
|
||||
SubscriptionsExtension subElem = (SubscriptionsExtension) reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
|
||||
return subElem.getSubscriptions();
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public class NodeUtils {
|
|||
* @return The configuration form
|
||||
*/
|
||||
public static ConfigureForm getFormFromPacket(Stanza packet, PubSubElementType elem) {
|
||||
FormNode config = packet.getExtension(elem.getElementName(), elem.getNamespace().getXmlns());
|
||||
FormNode config = (FormNode) packet.getExtension(elem.getElementName(), elem.getNamespace().getXmlns());
|
||||
Form formReply = config.getForm();
|
||||
return new ConfigureForm(formReply);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.jivesoftware.smackx.receipts;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.provider.EmbeddedExtensionProvider;
|
||||
|
@ -33,6 +35,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
|
|||
public class DeliveryReceipt implements ExtensionElement {
|
||||
public static final String NAMESPACE = "urn:xmpp:receipts";
|
||||
public static final String ELEMENT = "received";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
/**
|
||||
* original ID of the delivered message
|
||||
|
@ -89,7 +92,7 @@ public class DeliveryReceipt implements ExtensionElement {
|
|||
* @return the {@link DeliveryReceipt} extension or {@code null}
|
||||
*/
|
||||
public static DeliveryReceipt from(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
return message.getExtension(DeliveryReceipt.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,8 @@ package org.jivesoftware.smackx.receipts;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.MessageBuilder;
|
||||
|
@ -35,6 +37,8 @@ import org.jivesoftware.smack.xml.XmlPullParserException;
|
|||
*/
|
||||
public class DeliveryReceiptRequest implements ExtensionElement {
|
||||
public static final String ELEMENT = "request";
|
||||
public static final String NAMESPACE = DeliveryReceipt.NAMESPACE;
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
|
@ -70,7 +74,7 @@ public class DeliveryReceiptRequest implements ExtensionElement {
|
|||
* @return the {@link DeliveryReceiptRequest} extension or {@code null}
|
||||
*/
|
||||
public static DeliveryReceiptRequest from(Stanza packet) {
|
||||
return packet.getExtension(ELEMENT, DeliveryReceipt.NAMESPACE);
|
||||
return packet.getExtension(DeliveryReceiptRequest.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014 Florian Schmaus
|
||||
* Copyright © 2014-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.rsm.packet;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
@ -24,6 +26,7 @@ public class RSMSet implements ExtensionElement {
|
|||
|
||||
public static final String ELEMENT = "set";
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/rsm";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final String after;
|
||||
private final String before;
|
||||
|
|
|
@ -204,7 +204,7 @@ public class UserSearch extends SimpleIQ {
|
|||
done = true;
|
||||
}
|
||||
}
|
||||
if (search.getExtension("x", "jabber:x:data") == null) {
|
||||
if (search.getExtension(DataForm.class) == null) {
|
||||
search.addExtension(dataForm);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.jivesoftware.smackx.shim.packet;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
@ -33,6 +35,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
|
|||
public class HeadersExtension implements ExtensionElement {
|
||||
public static final String ELEMENT = "headers";
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/shim";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final List<Header> headers;
|
||||
|
||||
|
@ -74,6 +77,6 @@ public class HeadersExtension implements ExtensionElement {
|
|||
* @return the headers extension or null.
|
||||
*/
|
||||
public static HeadersExtension from(Stanza packet) {
|
||||
return packet.getExtension(ELEMENT, NAMESPACE);
|
||||
return packet.getExtension(HeadersExtension.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ package org.jivesoftware.smackx.usertune.element;
|
|||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.datatypes.UInt16;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
|
@ -35,6 +37,7 @@ public final class UserTuneElement implements ExtensionElement {
|
|||
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/tune";
|
||||
public static final String ELEMENT = "tune";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final String artist;
|
||||
private final UInt16 length;
|
||||
|
@ -116,11 +119,11 @@ public final class UserTuneElement implements ExtensionElement {
|
|||
}
|
||||
|
||||
public static boolean hasUserTuneElement(Message message) {
|
||||
return message.hasExtension(ELEMENT, NAMESPACE);
|
||||
return message.hasExtension(UserTuneElement.class);
|
||||
}
|
||||
|
||||
public static UserTuneElement from(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
return message.getExtension(UserTuneElement.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -361,7 +361,7 @@ public class DataForm implements ExtensionElement {
|
|||
* @return the DataForm or null
|
||||
*/
|
||||
public static DataForm from(StanzaView stanzaView) {
|
||||
return (DataForm) stanzaView.getExtension(QNAME);
|
||||
return stanzaView.getExtension(DataForm.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -130,6 +130,6 @@ public class XHTMLExtension implements ExtensionElement {
|
|||
}
|
||||
|
||||
public static XHTMLExtension from(MessageView message) {
|
||||
return message.getExtension(QNAME);
|
||||
return message.getExtension(XHTMLExtension.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ public class InBandBytestreamSessionMessageTest extends InitExtensions {
|
|||
@Override
|
||||
public void verify(Message request, IQ response) {
|
||||
DataPacketExtension dpe = request.getExtension(
|
||||
DataPacketExtension.ELEMENT, DataPacketExtension.NAMESPACE);
|
||||
DataPacketExtension.class);
|
||||
assertEquals(lastSeq++, dpe.getSeq());
|
||||
}
|
||||
|
||||
|
|
|
@ -117,8 +117,7 @@ public class GeoLocationTest extends InitExtensions {
|
|||
Message messageWithGeoLocation = PacketParserUtils.parseStanza(geoLocationMessageString);
|
||||
assertNotNull(messageWithGeoLocation);
|
||||
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation.NAMESPACE);
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.class);
|
||||
assertNotNull(geoLocation);
|
||||
assertNotNull(geoLocation.toXML());
|
||||
|
||||
|
|
|
@ -69,8 +69,7 @@ public class GeoLocationProviderTest extends InitExtensions {
|
|||
Message messageWithGeoLocation = PacketParserUtils.parseStanza(geoLocationString);
|
||||
assertNotNull(messageWithGeoLocation);
|
||||
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation.NAMESPACE);
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.class);
|
||||
assertNotNull(geoLocation);
|
||||
|
||||
assertEquals((Double) 23d, geoLocation.getAccuracy());
|
||||
|
@ -138,8 +137,7 @@ public class GeoLocationProviderTest extends InitExtensions {
|
|||
Message messageWithGeoLocation = PacketParserUtils.parseStanza(geoLocationString);
|
||||
assertNotNull(messageWithGeoLocation);
|
||||
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation.NAMESPACE);
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.class);
|
||||
assertNotNull(geoLocation);
|
||||
|
||||
assertEquals((Double) 23d, geoLocation.getAccuracy());
|
||||
|
@ -183,8 +181,7 @@ public class GeoLocationProviderTest extends InitExtensions {
|
|||
|
||||
Message messageWithGeoLocation = PacketParserUtils.parseStanza(geoLocationString);
|
||||
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation.NAMESPACE);
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.class);
|
||||
|
||||
assertEquals((Double) 90d, geoLocation.getError());
|
||||
}
|
||||
|
@ -203,8 +200,7 @@ public class GeoLocationProviderTest extends InitExtensions {
|
|||
|
||||
Message messageWithGeoLocation = PacketParserUtils.parseStanza(geoLocationString);
|
||||
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation.NAMESPACE);
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.class);
|
||||
|
||||
assertEquals((Double) 90d, geoLocation.getAccuracy());
|
||||
}
|
||||
|
@ -224,8 +220,7 @@ public class GeoLocationProviderTest extends InitExtensions {
|
|||
|
||||
Message messageWithGeoLocation = PacketParserUtils.parseStanza(geoLocationString);
|
||||
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation.NAMESPACE);
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.class);
|
||||
|
||||
assertEquals((Double) 90d, geoLocation.getAccuracy());
|
||||
assertNull(geoLocation.getError());
|
||||
|
|
|
@ -62,7 +62,7 @@ public class DeliveryReceiptTest extends InitExtensions {
|
|||
parser = PacketParserUtils.getParserFor(control);
|
||||
Message p = PacketParserUtils.parseMessage(parser);
|
||||
|
||||
DeliveryReceiptRequest drr = p.getExtension(DeliveryReceiptRequest.ELEMENT, DeliveryReceipt.NAMESPACE);
|
||||
DeliveryReceiptRequest drr = p.getExtension(DeliveryReceiptRequest.class);
|
||||
assertNotNull(drr);
|
||||
|
||||
assertTrue(DeliveryReceiptManager.hasDeliveryReceiptRequest(p));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014 Florian Schmaus
|
||||
* Copyright © 2014-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -49,7 +49,7 @@ public class RSMSetProviderTest extends InitExtensions {
|
|||
// @formatter:on
|
||||
|
||||
IQ iqWithRsm = PacketParserUtils.parseStanza(rsmset);
|
||||
RSMSet rsm = iqWithRsm.getExtension(RSMSet.ELEMENT, RSMSet.NAMESPACE);
|
||||
RSMSet rsm = iqWithRsm.getExtension(RSMSet.class);
|
||||
assertNotNull(rsm);
|
||||
assertEquals("aftervalue", rsm.getAfter());
|
||||
assertEquals("beforevalue", rsm.getBefore());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue