1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-10-31 22:15:59 +01:00

Make ExtensionElement marker interface wrt. QNAME field

ExtensionElement is now a marker interface that requires all
implementation non-abstract classes to carry a static final QNAME
field (of type QName). This is verified by a new unit test.

Also FullyQualifiedElement is renamed to simply XmlElement. XmlElement
is used over ExtensionElement when implementing classes do not
statically know the qualified name of the XML elements they
represent. In general, XmlElement should be used sparingly, and every
XML element should be modeled by its own Java class (implementing
ExtensionElement).
This commit is contained in:
Florian Schmaus 2021-04-18 18:58:50 +02:00
parent 5493a22e44
commit 3d4e7938a7
146 changed files with 600 additions and 344 deletions

View file

@ -153,6 +153,7 @@ allprojects {
bouncyCastleVersion = '1.68'
guavaVersion = '30.1-jre'
mockitoVersion = '3.7.7'
orgReflectionsVersion = '0.9.11'
if (project.hasProperty("useSonatype")) {
useSonatype = project.getProperty("useSonatype").toBoolean()

View file

@ -74,7 +74,6 @@ import org.jivesoftware.smack.packet.AbstractStreamOpen;
import org.jivesoftware.smack.packet.Bind;
import org.jivesoftware.smack.packet.ErrorIQ;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.FullyQualifiedElement;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Mechanisms;
import org.jivesoftware.smack.packet.Message;
@ -92,6 +91,7 @@ import org.jivesoftware.smack.packet.StartTls;
import org.jivesoftware.smack.packet.StreamError;
import org.jivesoftware.smack.packet.StreamOpen;
import org.jivesoftware.smack.packet.TopLevelStreamElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.packet.id.StanzaIdSource;
import org.jivesoftware.smack.parsing.ParsingExceptionCallback;
@ -239,7 +239,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
protected final Lock connectionLock = new ReentrantLock();
protected final Map<QName, FullyQualifiedElement> streamFeatures = new HashMap<>();
protected final Map<QName, XmlElement> streamFeatures = new HashMap<>();
/**
* The full JID of the authenticated user, as returned by the resource binding response of the server.
@ -1859,7 +1859,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
XmlPullParser.Event eventType = parser.next();
if (eventType == XmlPullParser.Event.START_ELEMENT && parser.getDepth() == initialDepth + 1) {
FullyQualifiedElement streamFeature = null;
XmlElement streamFeature = null;
String name = parser.getName();
String namespace = parser.getNamespace();
switch (name) {
@ -1928,7 +1928,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
@SuppressWarnings("unchecked")
@Override
public <F extends FullyQualifiedElement> F getFeature(QName qname) {
public <F extends XmlElement> F getFeature(QName qname) {
return (F) streamFeatures.get(qname);
}
@ -1937,7 +1937,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
return streamFeatures.containsKey(qname);
}
protected void addStreamFeature(FullyQualifiedElement feature) {
protected void addStreamFeature(XmlElement feature) {
QName key = feature.getQName();
streamFeatures.put(key, feature);
}

View file

@ -27,7 +27,6 @@ import org.jivesoftware.smack.filter.IQReplyFilter;
import org.jivesoftware.smack.filter.StanzaFilter;
import org.jivesoftware.smack.iqrequest.IQRequestHandler;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.FullyQualifiedElement;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.MessageBuilder;
@ -36,6 +35,7 @@ import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.PresenceBuilder;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.StanzaFactory;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.util.Consumer;
import org.jivesoftware.smack.util.Predicate;
import org.jivesoftware.smack.util.XmppElementUtil;
@ -583,7 +583,7 @@ public interface XMPPConnection {
*/
// TODO: Remove in Smack 4.5.
@Deprecated
default <F extends FullyQualifiedElement> F getFeature(String element, String namespace) {
default <F extends XmlElement> F getFeature(String element, String namespace) {
QName qname = new QName(namespace, element);
return getFeature(qname);
}
@ -597,7 +597,7 @@ public interface XMPPConnection {
* @return a stanza extensions of the feature or <code>null</code>
* @since 4.4
*/
<F extends FullyQualifiedElement> F getFeature(QName qname);
<F extends XmlElement> F getFeature(QName qname);
/**
* Get the feature stanza extensions for a given stream feature of the
@ -608,7 +608,7 @@ public interface XMPPConnection {
* @return a stanza extensions of the feature or <code>null</code>
* @since 4.4
*/
default <F extends FullyQualifiedElement> F getFeature(Class<F> featureClass) {
default <F extends XmlElement> F getFeature(Class<F> featureClass) {
QName qname = XmppElementUtil.getQNameFor(featureClass);
return getFeature(qname);
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2020 Florian Schmaus
* Copyright 2020-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,6 +20,7 @@ import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.util.XmppElementUtil;
public class ExtensionElementFilter<E extends ExtensionElement> implements StanzaFilter {
@ -34,7 +35,7 @@ public class ExtensionElementFilter<E extends ExtensionElement> implements Stanz
@Override
public final boolean accept(Stanza stanza) {
ExtensionElement extensionElement = stanza.getExtension(extensionElementQName);
XmlElement extensionElement = stanza.getExtension(extensionElementQName);
if (extensionElement == null) {
return false;
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2014-2015 Florian Schmaus
* Copyright 2014-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -32,18 +32,18 @@ public class AbstractError {
protected final String textNamespace;
protected final Map<String, String> descriptiveTexts;
protected final List<ExtensionElement> extensions;
protected final List<XmlElement> extensions;
protected AbstractError(Map<String, String> descriptiveTexts) {
this(descriptiveTexts, null);
}
protected AbstractError(Map<String, String> descriptiveTexts, List<ExtensionElement> extensions) {
protected AbstractError(Map<String, String> descriptiveTexts, List<XmlElement> extensions) {
this(descriptiveTexts, null, extensions);
}
protected AbstractError(Map<String, String> descriptiveTexts, String textNamespace, List<ExtensionElement> extensions) {
protected AbstractError(Map<String, String> descriptiveTexts, String textNamespace, List<XmlElement> extensions) {
if (descriptiveTexts != null) {
this.descriptiveTexts = descriptiveTexts;
} else {
@ -108,7 +108,7 @@ public class AbstractError {
* @param <PE> type of the ExtensionElement.
* @return the extension, or <code>null</code> if it doesn't exist.
*/
public <PE extends ExtensionElement> PE getExtension(String elementName, String namespace) {
public <PE extends XmlElement> PE getExtension(String elementName, String namespace) {
return PacketUtil.extensionElementFrom(extensions, elementName, namespace);
}
@ -128,7 +128,7 @@ public class AbstractError {
public abstract static class Builder<B extends Builder<B>> {
protected String textNamespace;
protected Map<String, String> descriptiveTexts;
protected List<ExtensionElement> extensions;
protected List<XmlElement> extensions;
public B setDescriptiveTexts(Map<String, String> descriptiveTexts) {
if (descriptiveTexts == null) {
@ -173,7 +173,7 @@ public class AbstractError {
return getThis();
}
public B setExtensions(List<ExtensionElement> extensions) {
public B setExtensions(List<XmlElement> extensions) {
if (this.extensions == null) {
this.extensions = extensions;
}
@ -183,7 +183,7 @@ public class AbstractError {
return getThis();
}
public B addExtension(ExtensionElement extension) {
public B addExtension(XmlElement extension) {
if (extensions == null) {
extensions = new ArrayList<>();
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2003-2007 Jive Software, 2018 Florian Schmaus.
* Copyright 2003-2007 Jive Software, 2018-2021 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,21 +17,16 @@
package org.jivesoftware.smack.packet;
/**
* Interface to represent extension elements.
* Interface to represent XMPP extension elements. Unlike {@link XmlElement}, every non-abstract class that implements
* {@link ExtensionElement} must have a static final QNAME member of the type {@link javax.xml.namespace.QName}. This
* allows type-safe functions like {@link StanzaView#getExtension(Class)}. Hence this is a marker interface.
* <p>
* An extension element is an XML subdocument
* with a root element name and namespace. Extension elements are used to provide
* extended functionality beyond what is in the base XMPP specification. Examples of
* extensions elements include message events, message properties, and extra presence data.
* IQ stanzas have limited support for extension elements.
* <p>
* This class is used primarily for extended content in XMPP Stanzas, to act as so called "extension elements". For more
* information see <a href="https://tools.ietf.org/html/rfc6120#section-8.4">RFC 6120 § 8.4 Extended Content</a>.
* Use this class when implementing new extension elements when possible. This means that every instance of your
* implemented class must represent an XML element of the same qualified name.
* </p>
*
* @see org.jivesoftware.smack.provider.ExtensionElementProvider
* @author Matt Tucker
* @see <a href="https://tools.ietf.org/html/rfc6120#section-8.4">RFC 6120 § 8.4 Extended Content</a>
*/
public interface ExtensionElement extends FullyQualifiedElement {
public interface ExtensionElement extends XmlElement {
}

View file

@ -211,7 +211,7 @@ public abstract class IQ extends Stanza implements IqView {
xml.append(iqChildElement);
List<ExtensionElement> extensionsXml = getExtensions();
List<XmlElement> extensionsXml = getExtensions();
if (iqChildElement.isEmptyElement) {
if (extensionsXml.isEmpty()) {
xml.closeEmptyElement();

View file

@ -344,7 +344,7 @@ public final class Message extends MessageOrPresence<MessageBuilder>
@Deprecated
// TODO: Remove when stanza builder is ready.
public boolean removeBody(Body body) {
ExtensionElement removedElement = removeExtension(body);
XmlElement removedElement = removeExtension(body);
return removedElement != null;
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2003-2007 Jive Software, 2019-2020 Florian Schmaus
* Copyright 2003-2007 Jive Software, 2019-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -150,9 +150,9 @@ public interface MessageView extends StanzaView {
* @since 3.0.2
*/
default Set<Message.Body> getBodies() {
List<ExtensionElement> bodiesList = getExtensions(Message.Body.QNAME);
List<XmlElement> bodiesList = getExtensions(Message.Body.QNAME);
Set<Message.Body> resultSet = new HashSet<>(bodiesList.size());
for (ExtensionElement extensionElement : bodiesList) {
for (XmlElement extensionElement : bodiesList) {
Message.Body body = (Message.Body) extensionElement;
resultSet.add(body);
}

View file

@ -23,7 +23,7 @@ package org.jivesoftware.smack.packet;
* <p>
* Please note that usage of this interface is <b>discouraged</b>. The reason is that every XML element is fully
* qualified, i.e., it is qualified by a namespace. The namespace may not be explicitly given, but instead, is inherited
* from an outer element. Use {@link FullyQualifiedElement} instead when possible.
* from an outer element. Use {@link XmlElement} instead when possible.
* </p>
*/
public interface NamedElement extends Element {

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2003-2007 Jive Software, 2020 Florian Schmaus.
* Copyright 2003-2007 Jive Software, 2020-2021 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -319,7 +319,7 @@ public final class Presence extends MessageOrPresence<PresenceBuilder>
buf.attribute("type", type);
}
List<ExtensionElement> extensions = getExtensions();
List<XmlElement> extensions = getExtensions();
if (status == null
&& priority == null
&& (mode == null || mode == Mode.available)

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2015-2020 Florian Schmaus.
* Copyright 2015-2021 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -41,7 +41,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
* @since 4.2
* @author Florian Schmaus
*/
public final class StandardExtensionElement implements ExtensionElement {
public final class StandardExtensionElement implements XmlElement {
private final String name;
private final String namespace;

View file

@ -64,7 +64,7 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
protected static final String DEFAULT_LANGUAGE =
java.util.Locale.getDefault().getLanguage().toLowerCase(Locale.US);
private final MultiMap<QName, ExtensionElement> extensionElements;
private final MultiMap<QName, XmlElement> extensionElements;
// Assume that all stanzas Smack handles are in the client namespace, since Smack is an XMPP client library. We can
// change this behavior later if it is required.
@ -284,18 +284,18 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
}
@Override
public final List<ExtensionElement> getExtensions() {
public final List<XmlElement> getExtensions() {
synchronized (extensionElements) {
// No need to create a new list, values() will already create a new one for us
return extensionElements.values();
}
}
public final MultiMap<QName, ExtensionElement> getExtensionsMap() {
public final MultiMap<QName, XmlElement> getExtensionsMap() {
return cloneExtensionsMap();
}
final MultiMap<QName, ExtensionElement> cloneExtensionsMap() {
final MultiMap<QName, XmlElement> cloneExtensionsMap() {
synchronized (extensionElements) {
return extensionElements.clone();
}
@ -312,7 +312,7 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
* @return a set of all matching extensions.
* @since 4.1
*/
public final List<ExtensionElement> getExtensions(String elementName, String namespace) {
public final List<XmlElement> getExtensions(String elementName, String namespace) {
requireNotNullNorEmpty(elementName, "elementName must not be null nor empty");
requireNotNullNorEmpty(namespace, "namespace must not be null nor empty");
QName key = new QName(namespace, elementName);
@ -320,8 +320,8 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
}
@Override
public final List<ExtensionElement> getExtensions(QName qname) {
List<ExtensionElement> res;
public final List<XmlElement> getExtensions(QName qname) {
List<XmlElement> res;
synchronized (extensionElements) {
res = extensionElements.getAll(qname);
}
@ -344,7 +344,8 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
* @param namespace the namespace of the extension that is desired.
* @return the stanza extension with the given namespace.
*/
public final ExtensionElement getExtension(String namespace) {
// TODO: Mark this method as deprecated in favor of getExtension(QName).
public final XmlElement getExtension(String namespace) {
return PacketUtil.extensionElementFrom(getExtensions(), null, namespace);
}
@ -361,12 +362,12 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
* @param namespace the XML element namespace of the extension.
* @return the extension, or <code>null</code> if it doesn't exist.
*/
public final ExtensionElement getExtensionElement(String elementName, String namespace) {
public final XmlElement getExtensionElement(String elementName, String namespace) {
if (namespace == null) {
return null;
}
QName key = new QName(namespace, elementName);
ExtensionElement packetExtension = getExtension(key);
XmlElement packetExtension = getExtension(key);
if (packetExtension == null) {
return null;
}
@ -390,7 +391,7 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
}
@Override
public final ExtensionElement getExtension(QName qname) {
public final XmlElement getExtension(QName qname) {
synchronized (extensionElements) {
return extensionElements.getFirst(qname);
}
@ -400,13 +401,13 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
* Adds a stanza extension to the packet. Does nothing if extension is null.
* <p>
* Please note that although this method is not yet marked as deprecated, it is recommended to use
* {@link StanzaBuilder#addExtension(ExtensionElement)} instead.
* {@link StanzaBuilder#addExtension(XmlElement)} instead.
* </p>
*
* @param extension a stanza extension.
*/
// TODO: Mark this as deprecated once StanzaBuilder is ready and all call sites are gone.
public final void addExtension(ExtensionElement extension) {
public final void addExtension(XmlElement extension) {
if (extension == null) return;
QName key = extension.getQName();
synchronized (extensionElements) {
@ -419,7 +420,7 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
* namespace.
* <p>
* Please note that although this method is not yet marked as deprecated, it is recommended to use
* {@link StanzaBuilder#overrideExtension(ExtensionElement)} instead.
* {@link StanzaBuilder#overrideExtension(XmlElement)} instead.
* </p>
*
* @param extension the extension element to add.
@ -427,13 +428,13 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
* @since 4.1.2
*/
// TODO: Mark this as deprecated once StanzaBuilder is ready and all call sites are gone.
public final ExtensionElement overrideExtension(ExtensionElement extension) {
public final XmlElement overrideExtension(XmlElement extension) {
if (extension == null) return null;
synchronized (extensionElements) {
// Note that we need to use removeExtension(String, String) here. If would use
// removeExtension(ExtensionElement) then we would remove based on the equality of ExtensionElement, which
// is not what we want in this case.
ExtensionElement removedExtension = removeExtension(extension.getElementName(), extension.getNamespace());
XmlElement removedExtension = removeExtension(extension.getElementName(), extension.getNamespace());
addExtension(extension);
return removedExtension;
}
@ -445,9 +446,9 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
* @param extensions a collection of stanza extensions
*/
// TODO: Mark this as deprecated once StanzaBuilder is ready and all call sites are gone.
public final void addExtensions(Collection<? extends ExtensionElement> extensions) {
public final void addExtensions(Collection<? extends XmlElement> extensions) {
if (extensions == null) return;
for (ExtensionElement packetExtension : extensions) {
for (XmlElement packetExtension : extensions) {
addExtension(packetExtension);
}
}
@ -476,7 +477,7 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
@Override
public final boolean hasExtension(String namespace) {
synchronized (extensionElements) {
for (ExtensionElement packetExtension : extensionElements.values()) {
for (XmlElement packetExtension : extensionElements.values()) {
if (packetExtension.getNamespace().equals(namespace)) {
return true;
}
@ -493,7 +494,7 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
* @return the removed stanza extension or null.
*/
// TODO: Mark this as deprecated once StanzaBuilder is ready and all call sites are gone.
public final ExtensionElement removeExtension(String elementName, String namespace) {
public final XmlElement removeExtension(String elementName, String namespace) {
QName key = new QName(namespace, elementName);
synchronized (extensionElements) {
return extensionElements.remove(key);
@ -509,10 +510,10 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
*/
@Deprecated
// TODO: Remove in Smack 4.5.
public final ExtensionElement removeExtension(ExtensionElement extension) {
public final XmlElement removeExtension(XmlElement extension) {
QName key = extension.getQName();
synchronized (extensionElements) {
List<ExtensionElement> list = extensionElements.getAll(key);
List<XmlElement> list = extensionElements.getAll(key);
boolean removed = list.remove(extension);
if (removed) {
return extension;

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2019-2020 Florian Schmaus
* Copyright 2019-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -44,7 +44,7 @@ public abstract class StanzaBuilder<B extends StanzaBuilder<B>> implements Stanz
String language;
MultiMap<QName, ExtensionElement> extensionElements = new MultiMap<>();
MultiMap<QName, XmlElement> extensionElements = new MultiMap<>();
protected StanzaBuilder(StanzaBuilder<?> other) {
stanzaIdSource = other.stanzaIdSource;
@ -156,13 +156,13 @@ public abstract class StanzaBuilder<B extends StanzaBuilder<B>> implements Stanz
return getThis();
}
public final B addExtension(ExtensionElement extensionElement) {
public final B addExtension(XmlElement extensionElement) {
QName key = extensionElement.getQName();
extensionElements.put(key, extensionElement);
return getThis();
}
public final B addOptExtensions(Collection<? extends ExtensionElement> extensionElements) {
public final B addOptExtensions(Collection<? extends XmlElement> extensionElements) {
if (extensionElements == null) {
return getThis();
}
@ -170,14 +170,14 @@ public abstract class StanzaBuilder<B extends StanzaBuilder<B>> implements Stanz
return addExtensions(extensionElements);
}
public final B addExtensions(Collection<? extends ExtensionElement> extensionElements) {
for (ExtensionElement extensionElement : extensionElements) {
public final B addExtensions(Collection<? extends XmlElement> extensionElements) {
for (XmlElement extensionElement : extensionElements) {
addExtension(extensionElement);
}
return getThis();
}
public final B overrideExtension(ExtensionElement extensionElement) {
public final B overrideExtension(XmlElement extensionElement) {
QName key = extensionElement.getQName();
extensionElements.remove(key);
extensionElements.put(key, extensionElement);
@ -214,17 +214,17 @@ public abstract class StanzaBuilder<B extends StanzaBuilder<B>> implements Stanz
}
@Override
public final ExtensionElement getExtension(QName qname) {
public final XmlElement getExtension(QName qname) {
return extensionElements.getFirst(qname);
}
@Override
public final List<ExtensionElement> getExtensions() {
public final List<XmlElement> getExtensions() {
return extensionElements.values();
}
@Override
public final List<ExtensionElement> getExtensions(QName qname) {
public final List<XmlElement> getExtensions(QName qname) {
return extensionElements.getAll(qname);
}

View file

@ -125,7 +125,7 @@ public class StanzaError extends AbstractError implements ExtensionElement {
* @param extensions list of stanza extensions
*/
public StanzaError(Condition condition, String conditionText, String errorGenerator, Type type, Map<String, String> descriptiveTexts,
List<ExtensionElement> extensions) {
List<XmlElement> extensions) {
super(descriptiveTexts, ERROR_CONDITION_AND_TEXT_NAMESPACE, extensions);
this.condition = Objects.requireNonNull(condition, "condition must not be null");
// Some implementations may send the condition as non-empty element containing the empty string, that is

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2019-2020 Florian Schmaus
* Copyright 2019-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -61,7 +61,7 @@ public interface StanzaView extends XmlLangElement {
*/
StanzaError getError();
ExtensionElement getExtension(QName qname);
XmlElement getExtension(QName qname);
default boolean hasExtension(QName qname) {
return getExtension(qname) != null;
@ -78,7 +78,7 @@ public interface StanzaView extends XmlLangElement {
* @return true if a stanza extension exists, false otherwise.
*/
default boolean hasExtension(String namespace) {
for (ExtensionElement packetExtension : getExtensions()) {
for (XmlElement packetExtension : getExtensions()) {
if (packetExtension.getNamespace().equals(namespace)) {
return true;
}
@ -89,7 +89,7 @@ public interface StanzaView extends XmlLangElement {
default <E extends ExtensionElement> E getExtension(Class<E> extensionElementClass) {
QName qname = XmppElementUtil.getQNameFor(extensionElementClass);
ExtensionElement extensionElement = getExtension(qname);
XmlElement extensionElement = getExtension(qname);
if (extensionElement == null) {
return null;
@ -103,9 +103,9 @@ public interface StanzaView extends XmlLangElement {
*
* @return a list of all extension elements of this stanza.
*/
List<ExtensionElement> getExtensions();
List<XmlElement> getExtensions();
List<ExtensionElement> getExtensions(QName qname);
List<XmlElement> getExtensions(QName qname);
/**
* Return all extension elements of the given type. Returns the empty list if there a none.

View file

@ -105,7 +105,7 @@ public class StreamError extends AbstractError implements Nonza {
private final Condition condition;
private final String conditionText;
public StreamError(Condition condition, String conditionText, Map<String, String> descriptiveTexts, List<ExtensionElement> extensions) {
public StreamError(Condition condition, String conditionText, Map<String, String> descriptiveTexts, List<XmlElement> extensions) {
super(descriptiveTexts, extensions);
// Some implementations may send the condition as non-empty element containing the empty string, that is
// <condition xmlns='foo'></condition>, in this case the parser may calls this constructor with the empty string

View file

@ -20,6 +20,6 @@ package org.jivesoftware.smack.packet;
* A XMPP top level stream element. This is either a stanza ({@link Stanza}) or
* just a plain stream element ({@link Nonza}).
*/
public interface TopLevelStreamElement extends FullyQualifiedElement {
public interface TopLevelStreamElement extends XmlElement {
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2018-2019 Florian Schmaus
* Copyright 2018-2021 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,7 +18,23 @@ package org.jivesoftware.smack.packet;
import javax.xml.namespace.QName;
public interface FullyQualifiedElement extends NamedElement, XmlLangElement {
/**
* Interface to represent XML elements. Every XML element in XMPP has a qualified XML name ({@link QName}). This name
* can be obtained via {@link #getQName()}.
* <p>
* XMPP uses "extension elements", i.e. XML elements, to provide extended functionality beyond what is in the base XMPP
* specification. Examples of extensions elements include message events, message properties, and extra presence data.
* IQ stanzas have limited support for extension elements. See {@link ExtensionElement} for more information about XMPP
* extension elements.
* </p>
* <p>
* It is recommend to use {@link ExtensionElement} over this class when creating new extension elements.
* </p>
*
* @see org.jivesoftware.smack.provider.ExtensionElementProvider
* @since 4.5
*/
public interface XmlElement extends NamedElement, XmlLangElement {
/**
* Returns the root element XML namespace.

View file

@ -22,7 +22,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.util.PacketParserUtils;
@ -82,7 +82,7 @@ import org.jivesoftware.smack.xml.XmlPullParserException;
*
* @author Robin Collier
*/
public abstract class EmbeddedExtensionProvider<PE extends ExtensionElement> extends ExtensionElementProvider<PE> {
public abstract class EmbeddedExtensionProvider<PE extends XmlElement> extends ExtensionElementProvider<PE> {
@Override
public final PE parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
@ -95,7 +95,7 @@ public abstract class EmbeddedExtensionProvider<PE extends ExtensionElement> ext
attMap.put(parser.getAttributeName(i), parser.getAttributeValue(i));
}
List<ExtensionElement> extensions = new ArrayList<>();
List<XmlElement> extensions = new ArrayList<>();
XmlPullParser.Event event;
do {
event = parser.next();
@ -109,5 +109,5 @@ public abstract class EmbeddedExtensionProvider<PE extends ExtensionElement> ext
}
protected abstract PE createReturnExtension(String currentElement, String currentNamespace,
Map<String, String> attributeMap, List<? extends ExtensionElement> content);
Map<String, String> attributeMap, List<? extends XmlElement> content);
}

View file

@ -17,7 +17,7 @@
package org.jivesoftware.smack.provider;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlElement;
/**
* An abstract class for parsing custom extensions elements. Each ExtensionElementProvider must
@ -26,6 +26,6 @@ import org.jivesoftware.smack.packet.ExtensionElement;
*
* @author Matt Tucker
*/
public abstract class ExtensionElementProvider<EE extends ExtensionElement> extends Provider<EE> {
public abstract class ExtensionElementProvider<E extends XmlElement> extends Provider<E> {
}

View file

@ -48,6 +48,7 @@ import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.packet.StartTls;
import org.jivesoftware.smack.packet.StreamError;
import org.jivesoftware.smack.packet.UnparsedIQ;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.parsing.StandardExtensionElementProvider;
@ -183,7 +184,7 @@ public class PacketParserUtils {
message.setError(parseError(parser, messageXmlEnvironment));
break;
default:
ExtensionElement extensionElement = parseExtensionElement(elementName, namespace, parser, messageXmlEnvironment);
XmlElement extensionElement = parseExtensionElement(elementName, namespace, parser, messageXmlEnvironment);
message.addExtension(extensionElement);
break;
}
@ -474,7 +475,7 @@ public class PacketParserUtils {
// Be extra robust: Skip PacketExtensions that cause Exceptions, instead of
// failing completely here. See SMACK-390 for more information.
try {
ExtensionElement extensionElement = parseExtensionElement(elementName, namespace, parser, presenceXmlEnvironment);
XmlElement extensionElement = parseExtensionElement(elementName, namespace, parser, presenceXmlEnvironment);
presence.addExtension(extensionElement);
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Failed to parse extension element in Presence stanza: " + presence, e);
@ -701,7 +702,7 @@ public class PacketParserUtils {
*/
public static StreamError parseStreamError(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
final int initialDepth = parser.getDepth();
List<ExtensionElement> extensions = new ArrayList<>();
List<XmlElement> extensions = new ArrayList<>();
Map<String, String> descriptiveTexts = null;
StreamError.Condition condition = null;
String conditionText = null;
@ -765,7 +766,7 @@ public class PacketParserUtils {
final int initialDepth = parser.getDepth();
Map<String, String> descriptiveTexts = null;
XmlEnvironment stanzaErrorXmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
List<ExtensionElement> extensions = new ArrayList<>();
List<XmlElement> extensions = new ArrayList<>();
StanzaError.Builder builder = StanzaError.getBuilder();
// Parse the error header
@ -825,7 +826,7 @@ public class PacketParserUtils {
* @throws IOException if an I/O error occurred.
* @throws SmackParsingException if the Smack parser (provider) encountered invalid input.
*/
public static ExtensionElement parseExtensionElement(String elementName, String namespace,
public static XmlElement parseExtensionElement(String elementName, String namespace,
XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
ParserUtils.assertAtStartTag(parser);
// See if a provider is registered to handle the extension.
@ -907,7 +908,7 @@ public class PacketParserUtils {
public static void addExtensionElement(StanzaBuilder<?> stanzaBuilder, XmlPullParser parser, String elementName,
String namespace, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
ExtensionElement extensionElement = parseExtensionElement(elementName, namespace, parser, outerXmlEnvironment);
XmlElement extensionElement = parseExtensionElement(elementName, namespace, parser, outerXmlEnvironment);
stanzaBuilder.addExtension(extensionElement);
}
@ -919,18 +920,18 @@ public class PacketParserUtils {
public static void addExtensionElement(Stanza packet, XmlPullParser parser, String elementName,
String namespace, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
ExtensionElement packetExtension = parseExtensionElement(elementName, namespace, parser, outerXmlEnvironment);
XmlElement packetExtension = parseExtensionElement(elementName, namespace, parser, outerXmlEnvironment);
packet.addExtension(packetExtension);
}
public static void addExtensionElement(Collection<ExtensionElement> collection, XmlPullParser parser, XmlEnvironment outerXmlEnvironment)
public static void addExtensionElement(Collection<XmlElement> collection, XmlPullParser parser, XmlEnvironment outerXmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException {
addExtensionElement(collection, parser, parser.getName(), parser.getNamespace(), outerXmlEnvironment);
}
public static void addExtensionElement(Collection<ExtensionElement> collection, XmlPullParser parser,
public static void addExtensionElement(Collection<XmlElement> collection, XmlPullParser parser,
String elementName, String namespace, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
ExtensionElement packetExtension = parseExtensionElement(elementName, namespace, parser, outerXmlEnvironment);
XmlElement packetExtension = parseExtensionElement(elementName, namespace, parser, outerXmlEnvironment);
collection.add(packetExtension);
}
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014-2020 Florian Schmaus
* Copyright © 2014-2021 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,7 +18,7 @@ package org.jivesoftware.smack.util;
import java.util.Collection;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlElement;
public class PacketUtil {
@ -33,9 +33,9 @@ public class PacketUtil {
* @return the extension element
*/
@SuppressWarnings("unchecked")
public static <PE extends ExtensionElement> PE extensionElementFrom(Collection<ExtensionElement> collection,
public static <PE extends XmlElement> PE extensionElementFrom(Collection<XmlElement> collection,
String element, String namespace) {
for (ExtensionElement packetExtension : collection) {
for (XmlElement packetExtension : collection) {
if ((element == null || packetExtension.getElementName().equals(
element))
&& packetExtension.getNamespace().equals(namespace)) {

View file

@ -24,8 +24,8 @@ import java.util.Date;
import java.util.List;
import org.jivesoftware.smack.packet.Element;
import org.jivesoftware.smack.packet.FullyQualifiedElement;
import org.jivesoftware.smack.packet.NamedElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jxmpp.util.XmppDateTime;
@ -42,7 +42,7 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
effectiveXmlEnvironment = null;
}
public XmlStringBuilder(FullyQualifiedElement pe) {
public XmlStringBuilder(XmlElement pe) {
this(pe, null);
}
@ -51,7 +51,7 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
halfOpenElement(e.getElementName());
}
public XmlStringBuilder(FullyQualifiedElement element, XmlEnvironment enclosingXmlEnvironment) {
public XmlStringBuilder(XmlElement element, XmlEnvironment enclosingXmlEnvironment) {
sb = new LazyStringBuilder();
halfOpenElement(element);
@ -516,7 +516,7 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
return escape(text.toString());
}
protected XmlStringBuilder prelude(FullyQualifiedElement pe) {
protected XmlStringBuilder prelude(XmlElement pe) {
return prelude(pe.getElementName(), pe.getNamespace());
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2018-2020 Florian Schmaus
* Copyright 2018-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -24,19 +24,19 @@ import java.util.logging.Logger;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.FullyQualifiedElement;
import org.jivesoftware.smack.packet.StandardExtensionElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.provider.ProviderManager;
import org.jxmpp.util.cache.LruCache;
public class XmppElementUtil {
private static final LruCache<Class<? extends FullyQualifiedElement>, QName> CLASS_TO_QNAME_CACHE = new LruCache<>(512);
private static final LruCache<Class<? extends XmlElement>, QName> CLASS_TO_QNAME_CACHE = new LruCache<>(512);
public static final Logger LOGGER = Logger.getLogger(XmppElementUtil.class.getName());
public static QName getQNameFor(Class<? extends FullyQualifiedElement> fullyQualifiedElement) {
public static QName getQNameFor(Class<? extends XmlElement> fullyQualifiedElement) {
QName qname = CLASS_TO_QNAME_CACHE.get(fullyQualifiedElement);
if (qname != null) {
return qname;
@ -72,24 +72,24 @@ public class XmppElementUtil {
}
public static <E extends ExtensionElement> List<E> getElementsFrom(
MultiMap<QName, ExtensionElement> elementMap, Class<E> extensionElementClass) {
MultiMap<QName, XmlElement> elementMap, Class<E> extensionElementClass) {
QName qname = XmppElementUtil.getQNameFor(extensionElementClass);
List<ExtensionElement> extensionElements = elementMap.getAll(qname);
List<XmlElement> extensionElements = elementMap.getAll(qname);
if (extensionElements.isEmpty()) {
return Collections.emptyList();
}
List<E> res = new ArrayList<>(extensionElements.size());
for (ExtensionElement extensionElement : extensionElements) {
for (XmlElement extensionElement : extensionElements) {
E e = castOrThrow(extensionElement, extensionElementClass);
res.add(e);
}
return res;
}
public static <E extends ExtensionElement> E castOrThrow(ExtensionElement extensionElement, Class<E> extensionElementClass) {
public static <E extends ExtensionElement> E castOrThrow(XmlElement extensionElement, Class<E> extensionElementClass) {
if (!extensionElementClass.isInstance(extensionElement)) {
final QName qname = getQNameFor(extensionElementClass);

View file

@ -101,7 +101,7 @@ public class StreamErrorTest {
assertNotNull(error);
assertEquals(Condition.conflict, error.getCondition());
assertEquals("Replaced by new connection", error.getDescriptiveText());
ExtensionElement appSpecificElement = error.getExtension("appSpecificElement", "myns");
XmlElement appSpecificElement = error.getExtension("appSpecificElement", "myns");
assertNotNull(appSpecificElement);
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2013-2014 Georg Lukas, 2020 Florian Schmaus
* Copyright 2013-2014 Georg Lukas, 2020-2021 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,9 +16,12 @@
*/
package org.jivesoftware.smackx.carbons.packet;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.MessageBuilder;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.forward.packet.Forwarded;
@ -34,7 +37,7 @@ import org.jivesoftware.smackx.forward.packet.Forwarded;
*
* @author Georg Lukas
*/
public class CarbonExtension implements ExtensionElement {
public class CarbonExtension implements XmlElement {
public static final String NAMESPACE = Carbon.NAMESPACE;
private final Direction dir;
@ -136,6 +139,7 @@ public class CarbonExtension implements ExtensionElement {
public static final class Private implements ExtensionElement {
public static final Private INSTANCE = new Private();
public static final String ELEMENT = "private";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
private Private() {
}

View file

@ -17,8 +17,8 @@
package org.jivesoftware.smackx.chat_markers.filter;
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smackx.chatstates.ChatState;
import org.jivesoftware.smackx.chatstates.ChatStateManager;
@ -56,7 +56,7 @@ public final class EligibleForChatMarkerFilter extends StanzaExtensionFilter {
}
if (super.accept(message)) {
ExtensionElement extension = message.getExtension(ChatStateManager.NAMESPACE);
XmlElement extension = message.getExtension(ChatStateManager.NAMESPACE);
String chatStateElementName = extension.getElementName();
ChatState state;

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014-2015 Florian Schmaus
* Copyright © 2014-2021 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.csi.packet;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.Nonza;
@ -77,12 +79,19 @@ public class ClientStateIndication {
public static final Feature INSTANCE = new Feature();
public static final String ELEMENT = "csi";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
private Feature() {
}
@Override
public String getElementName() {
return ELEMENT;
return QNAME.getLocalPart();
}
@Override
public String getNamespace() {
return QNAME.getNamespaceURI();
}
@Override
@ -90,9 +99,5 @@ public class ClientStateIndication {
return '<' + ELEMENT + " xmlns='" + NAMESPACE + "'/>";
}
@Override
public String getNamespace() {
return NAMESPACE;
}
}
}

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.fallback_indication;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smackx.fallback_indication.element.FallbackIndicationElement;
public interface FallbackIndicationListener {

View file

@ -35,6 +35,7 @@ import org.jivesoftware.smack.filter.StanzaTypeFilter;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.MessageBuilder;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.fallback_indication.element.FallbackIndicationElement;

View file

@ -23,6 +23,7 @@ import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.fallback_indication.element.FallbackIndicationElement;
public class FallbackIndicationElementProvider extends ExtensionElementProvider<FallbackIndicationElement> {

View file

@ -16,6 +16,8 @@
*/
package org.jivesoftware.smackx.hoxt.packet;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.NamedElement;
@ -161,6 +163,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
public static class Data extends HoxExtensionElement {
public static final String ELEMENT = "data";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
private final NamedElement child;
@ -210,6 +213,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
public static class Text extends HoxExtensionElement {
public static final String ELEMENT = "text";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
private final String text;
@ -252,6 +256,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
public static class Base64 extends HoxExtensionElement {
public static final String ELEMENT = "base64";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
private final String text;
@ -294,6 +299,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
public static class Xml extends HoxExtensionElement {
public static final String ELEMENT = "xml";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
private final String text;
@ -336,6 +342,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
public static class ChunkedBase64 extends HoxExtensionElement {
public static final String ELEMENT = "chunkedBase64";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
private final String streamId;
@ -379,6 +386,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
public static class Ibb extends HoxExtensionElement {
public static final String ELEMENT = "ibb";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
private final String sid;

View file

@ -45,8 +45,8 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.proxy.ProxyInfo;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
import org.jivesoftware.smackx.httpfileupload.UploadService.Version;

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2016-2019 Florian Schmaus
* Copyright © 2016-2021 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,10 +18,10 @@ package org.jivesoftware.smackx.iot.control.element;
import java.util.Locale;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.util.XmlStringBuilder;
public abstract class SetData implements ExtensionElement {
public abstract class SetData implements XmlElement {
public enum Type {
BOOL,

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2019 Florian Schmaus
* Copyright 2019-2021 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,9 +16,9 @@
*/
package org.jivesoftware.smackx.iot.data.element;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlElement;
public abstract class IoTDataExtensionElement implements ExtensionElement {
public abstract class IoTDataExtensionElement implements XmlElement {
@Override
public final String getNamespace() {

View file

@ -16,6 +16,8 @@
*/
package org.jivesoftware.smackx.jingle_filetransfer.element;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.XmlStringBuilder;
@ -27,6 +29,8 @@ import org.jivesoftware.smackx.jingle.element.JingleContent;
*/
public class Checksum implements ExtensionElement {
public static final String ELEMENT = "checksum";
public static final QName QNAME = new QName(JingleFileTransfer.NAMESPACE_V5, ELEMENT);
public static final String ATTR_CREATOR = "creator";
public static final String ATTR_NAME = "name";
@ -43,7 +47,7 @@ public class Checksum implements ExtensionElement {
@Override
public String getElementName() {
return ELEMENT;
return QNAME.getLocalPart();
}
@Override
@ -59,6 +63,6 @@ public class Checksum implements ExtensionElement {
@Override
public String getNamespace() {
return JingleFileTransfer.NAMESPACE_V5;
return QNAME.getNamespaceURI();
}
}

View file

@ -18,14 +18,19 @@ package org.jivesoftware.smackx.jingle_filetransfer.element;
import java.util.List;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smackx.jingle.element.JingleContentDescription;
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement;
/**
* File element.
*/
public class JingleFileTransfer extends JingleContentDescription {
public class JingleFileTransfer extends JingleContentDescription implements ExtensionElement {
public static final String NAMESPACE_V5 = "urn:xmpp:jingle:apps:file-transfer:5";
public static final QName QNAME = new QName(NAMESPACE_V5, ELEMENT);
public JingleFileTransfer(List<JingleContentDescriptionChildElement> payloads) {
super(payloads);

View file

@ -16,7 +16,7 @@
*/
package org.jivesoftware.smackx.jingle_filetransfer.element;
import org.jivesoftware.smack.packet.FullyQualifiedElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.hashes.element.HashElement;
@ -24,7 +24,7 @@ import org.jivesoftware.smackx.hashes.element.HashElement;
/**
* RangeElement which specifies, which range of a file shall be transferred.
*/
public class Range implements FullyQualifiedElement {
public class Range implements XmlElement {
public static final String ELEMENT = "range";
public static final String NAMESPACE = JingleFileTransferChild.NAMESPACE;

View file

@ -49,6 +49,7 @@ import org.jivesoftware.smackx.commands.RemoteCommand;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
import org.jivesoftware.smackx.forward.packet.Forwarded;
import org.jivesoftware.smackx.mam.MamManager.MamQueryArgs;
import org.jivesoftware.smackx.mam.element.MamElements;
import org.jivesoftware.smackx.mam.element.MamElements.MamResultExtension;
import org.jivesoftware.smackx.mam.element.MamFinIQ;

View file

@ -24,6 +24,7 @@ import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.packet.MessageBuilder;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.message_fastening.element.FasteningElement;

View file

@ -24,9 +24,11 @@ import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.MessageBuilder;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.message_fastening.MessageFasteningManager;
import org.jivesoftware.smackx.sid.element.OriginIdElement;
@ -43,12 +45,12 @@ public final class FasteningElement implements ExtensionElement {
private final OriginIdElement referencedStanzasOriginId;
private final List<ExternalElement> externalPayloads = new ArrayList<>();
private final List<ExtensionElement> wrappedPayloads = new ArrayList<>();
private final List<XmlElement> wrappedPayloads = new ArrayList<>();
private final boolean clear;
private final boolean shell;
private FasteningElement(OriginIdElement originId,
List<ExtensionElement> wrappedPayloads,
List<XmlElement> wrappedPayloads,
List<ExternalElement> externalPayloads,
boolean clear,
boolean shell) {
@ -76,7 +78,7 @@ public final class FasteningElement implements ExtensionElement {
*
* @return wrapped payloads.
*/
public List<ExtensionElement> getWrappedPayloads() {
public List<XmlElement> getWrappedPayloads() {
return Collections.unmodifiableList(wrappedPayloads);
}
@ -162,7 +164,7 @@ public final class FasteningElement implements ExtensionElement {
for (ExternalElement external : externalPayloads) {
xml.append(external);
}
for (ExtensionElement wrapped : wrappedPayloads) {
for (XmlElement wrapped : wrappedPayloads) {
xml.append(wrapped);
}
}
@ -204,7 +206,7 @@ public final class FasteningElement implements ExtensionElement {
public static class Builder {
private OriginIdElement originId;
private final List<ExtensionElement> wrappedPayloads = new ArrayList<>();
private final List<XmlElement> wrappedPayloads = new ArrayList<>();
private final List<ExternalElement> externalPayloads = new ArrayList<>();
private boolean isClear = false;
private boolean isShell = false;
@ -236,7 +238,7 @@ public final class FasteningElement implements ExtensionElement {
* @param wrappedPayload wrapped payload
* @return builder instance
*/
public Builder addWrappedPayload(ExtensionElement wrappedPayload) {
public Builder addWrappedPayload(XmlElement wrappedPayload) {
return addWrappedPayloads(Collections.singletonList(wrappedPayload));
}
@ -246,7 +248,7 @@ public final class FasteningElement implements ExtensionElement {
* @param wrappedPayloads list of wrapped payloads
* @return builder instance
*/
public Builder addWrappedPayloads(List<ExtensionElement> wrappedPayloads) {
public Builder addWrappedPayloads(List<XmlElement> wrappedPayloads) {
this.wrappedPayloads.addAll(wrappedPayloads);
return this;
}

View file

@ -18,7 +18,7 @@ package org.jivesoftware.smackx.message_fastening.provider;
import java.io.IOException;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
@ -26,6 +26,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.message_fastening.MessageFasteningManager;
import org.jivesoftware.smackx.message_fastening.element.ExternalElement;
import org.jivesoftware.smackx.message_fastening.element.FasteningElement;
@ -62,7 +63,7 @@ public class FasteningElementProvider extends ExtensionElementProvider<Fastening
}
// Parse wrapped payload
ExtensionElement wrappedPayload = PacketParserUtils.parseExtensionElement(name, namespace, parser, xmlEnvironment);
XmlElement wrappedPayload = PacketParserUtils.parseExtensionElement(name, namespace, parser, xmlEnvironment);
builder.addWrappedPayload(wrappedPayload);
break;

View file

@ -21,7 +21,7 @@ import javax.xml.namespace.QName;
public class BlockQuoteElement extends MarkupElement.BlockLevelMarkupElement {
public static final String ELEMENT = "bquote";
public static final QName QNAME = new QName(MarkupElement.NAMESPACE, ELEMENT);
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
/**
* Create a new Block Quote element.

View file

@ -16,9 +16,12 @@
*/
package org.jivesoftware.smackx.message_markup.element;
import javax.xml.namespace.QName;
public class CodeBlockElement extends MarkupElement.BlockLevelMarkupElement {
public static final String ELEMENT = "bcode";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
/**
* Create a new Code Block element.

View file

@ -19,13 +19,15 @@ package org.jivesoftware.smackx.message_markup.element;
import java.util.Collections;
import java.util.List;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.util.XmlStringBuilder;
public class ListElement extends MarkupElement.NonEmptyChildElement {
public static final String ELEMENT = "list";
public static final String ELEM_LI = "li";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
private final List<ListEntryElement> entries;
@ -52,7 +54,7 @@ public class ListElement extends MarkupElement.NonEmptyChildElement {
@Override
public String getElementName() {
return ELEMENT;
return QNAME.getLocalPart();
}
@Override
@ -62,6 +64,10 @@ public class ListElement extends MarkupElement.NonEmptyChildElement {
public static class ListEntryElement implements ExtensionElement {
public static final String ELEMENT = "li";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
private final int start;
/**
@ -83,12 +89,12 @@ public class ListElement extends MarkupElement.NonEmptyChildElement {
@Override
public String getElementName() {
return ELEM_LI;
return QNAME.getLocalPart();
}
@Override
public String getNamespace() {
return MarkupElement.NAMESPACE;
return QNAME.getNamespaceURI();
}
@Override

View file

@ -271,6 +271,8 @@ public class MarkupElement implements ExtensionElement {
*/
public abstract static class MarkupChildElement implements ExtensionElement {
public static final String NAMESPACE = MarkupElement.NAMESPACE;
public static final String ATTR_START = "start";
public static final String ATTR_END = "end";

View file

@ -19,11 +19,14 @@ package org.jivesoftware.smackx.message_markup.element;
import java.util.Collections;
import java.util.Set;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.util.XmlStringBuilder;
public class SpanElement extends MarkupElement.NonEmptyChildElement {
public static final String ELEMENT = "span";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
private final Set<SpanStyle> styles;
@ -60,7 +63,7 @@ public class SpanElement extends MarkupElement.NonEmptyChildElement {
@Override
public String getElementName() {
return ELEMENT;
return QNAME.getLocalPart();
}
@Override

View file

@ -99,7 +99,7 @@ public class MarkupElementProvider extends ExtensionElementProvider<MarkupElemen
"Message Markup ListElement MUST contain a 'end' attribute.");
break;
case ListElement.ELEM_LI:
case ListElement.ListEntryElement.ELEMENT:
start = ParserUtils.getIntegerAttributeOrThrow(parser, MarkupChildElement.ATTR_START,
"Message Markup ListElement 'li' MUST contain a 'start' attribute.");
lis.add(new ListElement.ListEntryElement(start));

View file

@ -25,6 +25,7 @@ import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.packet.MessageBuilder;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.message_fastening.element.FasteningElement;
import org.jivesoftware.smackx.message_retraction.element.RetractElement;

View file

@ -18,14 +18,18 @@ package org.jivesoftware.smackx.message_retraction.element;
import java.util.Date;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.sid.element.OriginIdElement;
public class RetractedElement implements ExtensionElement {
public static final String ELEMENT = "retracted";
public static final QName QNAME = new QName(RetractElement.NAMESPACE, ELEMENT);
public static final String ATTR_STAMP = "stamp";
private final Date stamp;
@ -46,12 +50,12 @@ public class RetractedElement implements ExtensionElement {
@Override
public String getNamespace() {
return RetractElement.NAMESPACE;
return QNAME.getNamespaceURI();
}
@Override
public String getElementName() {
return ELEMENT;
return QNAME.getLocalPart();
}
@Override

View file

@ -23,6 +23,7 @@ import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.message_retraction.element.RetractElement;
public class RetractElementProvider extends ExtensionElementProvider<RetractElement> {

View file

@ -26,6 +26,7 @@ import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.message_retraction.element.RetractedElement;
import org.jivesoftware.smackx.sid.StableUniqueStanzaIdManager;
import org.jivesoftware.smackx.sid.element.OriginIdElement;

View file

@ -21,8 +21,11 @@ import java.net.URISyntaxException;
import java.util.ArrayList;
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.packet.XmlElement;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.XmlStringBuilder;
@ -33,6 +36,9 @@ import org.jxmpp.jid.BareJid;
public class ReferenceElement implements ExtensionElement {
public static final String ELEMENT = "reference";
public static final String NAMESPACE = ReferenceManager.NAMESPACE;
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
public static final String ATTR_BEGIN = "begin";
public static final String ATTR_END = "end";
public static final String ATTR_TYPE = "type";
@ -51,7 +57,7 @@ public class ReferenceElement implements ExtensionElement {
private final URI uri;
// Non-XEP-compliant, but needed for SIMS
private final ExtensionElement child;
private final XmlElement child;
/**
* XEP-incompliant (v0.2) constructor. This is needed for SIMS.
@ -63,7 +69,7 @@ public class ReferenceElement implements ExtensionElement {
* @param uri TODO javadoc me please
* @param child TODO javadoc me please
*/
public ReferenceElement(Integer begin, Integer end, Type type, String anchor, URI uri, ExtensionElement child) {
public ReferenceElement(Integer begin, Integer end, Type type, String anchor, URI uri, XmlElement child) {
if (begin != null && begin < 0) {
throw new IllegalArgumentException("Attribute 'begin' MUST NOT be smaller than 0.");
}
@ -147,9 +153,9 @@ public class ReferenceElement implements ExtensionElement {
*/
public static List<ReferenceElement> getReferencesFromStanza(Stanza stanza) {
List<ReferenceElement> references = new ArrayList<>();
List<ExtensionElement> extensions = stanza.getExtensions(ReferenceElement.ELEMENT, ReferenceManager.NAMESPACE);
for (ExtensionElement e : extensions) {
references.add((ReferenceElement) e);
List<ReferenceElement> extensions = stanza.getExtensions(ReferenceElement.class);
for (ReferenceElement e : extensions) {
references.add(e);
}
return references;
}
@ -166,12 +172,12 @@ public class ReferenceElement implements ExtensionElement {
@Override
public String getNamespace() {
return ReferenceManager.NAMESPACE;
return QNAME.getNamespaceURI();
}
@Override
public String getElementName() {
return ELEMENT;
return QNAME.getLocalPart();
}
@Override

View file

@ -20,7 +20,7 @@ import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
@ -51,7 +51,7 @@ public class ReferenceProvider extends ExtensionElementProvider<ReferenceElement
// TODO: Should be SmackParseException and probably be factored into ParserUtils.
throw new IOException(e);
}
ExtensionElement child = null;
XmlElement child = null;
outerloop: while (true) {
XmlPullParser.Event eventType = parser.next();
if (eventType == XmlPullParser.Event.START_ELEMENT) {

View file

@ -21,6 +21,8 @@ import java.util.HashMap;
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.util.StringUtils;
@ -32,6 +34,7 @@ public class SpoilerElement implements ExtensionElement {
public static final String ELEMENT = "spoiler";
public static final String NAMESPACE = SpoilerManager.NAMESPACE_0;
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
public static final SpoilerElement EMPTY = new SpoilerElement(null, null);
@ -116,11 +119,10 @@ public class SpoilerElement implements ExtensionElement {
return Collections.emptyMap();
}
List<ExtensionElement> spoilers = message.getExtensions(SpoilerElement.ELEMENT, NAMESPACE);
List<SpoilerElement> spoilers = message.getExtensions(SpoilerElement.class);
Map<String, String> map = new HashMap<>();
for (ExtensionElement e : spoilers) {
SpoilerElement s = (SpoilerElement) e;
for (SpoilerElement s : spoilers) {
if (s.getLanguage() == null || s.getLanguage().equals("")) {
map.put("", s.getHint());
} else {

View file

@ -23,12 +23,15 @@ import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.address.packet.MultipleAddresses;
import org.jivesoftware.smackx.hints.element.MessageProcessingHint;
import org.jivesoftware.smackx.sid.element.StanzaIdElement;
@ -120,7 +123,7 @@ public class ContentElement implements ExtensionElement {
private RandomPaddingAffixElement rpad = null;
private final List<AffixElement> otherAffixElements = new ArrayList<>();
private final List<ExtensionElement> payloadItems = new ArrayList<>();
private final List<XmlElement> payloadItems = new ArrayList<>();
private Builder() {
@ -246,7 +249,7 @@ public class ContentElement implements ExtensionElement {
* @return builder
* @throws IllegalArgumentException in case an extension element from the blacklist is added.
*/
public Builder addPayloadItem(ExtensionElement payloadItem) {
public Builder addPayloadItem(XmlElement payloadItem) {
Objects.requireNonNull(payloadItem, "Payload item MUST NOT be null.");
this.payloadItems.add(checkForIllegalPayloadsAndPossiblyThrow(payloadItem));
return this;
@ -263,7 +266,7 @@ public class ContentElement implements ExtensionElement {
return new ContentElement(payloadElement, allAffixElements);
}
private static ExtensionElement checkForIllegalPayloadsAndPossiblyThrow(ExtensionElement payloadItem) {
private static XmlElement checkForIllegalPayloadsAndPossiblyThrow(XmlElement payloadItem) {
QName qName = payloadItem.getQName();
if (BLACKLISTED_QNAMES.contains(qName)) {
throw new IllegalArgumentException("Element identified by " + qName +

View file

@ -19,8 +19,8 @@ package org.jivesoftware.smackx.stanza_content_encryption.element;
import java.util.Collections;
import java.util.List;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.NamedElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.util.XmlStringBuilder;
@ -28,13 +28,13 @@ public class PayloadElement implements NamedElement {
public static final String ELEMENT = "payload";
private final List<ExtensionElement> payloadElements;
private final List<XmlElement> payloadElements;
public PayloadElement(List<ExtensionElement> payloadElements) {
public PayloadElement(List<XmlElement> payloadElements) {
this.payloadElements = Collections.unmodifiableList(payloadElements);
}
public List<ExtensionElement> getItems() {
public List<XmlElement> getItems() {
return payloadElements;
}

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.stanza_content_encryption.provider;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.stanza_content_encryption.element.AffixExtensionElement;
/**

View file

@ -20,7 +20,7 @@ import java.io.IOException;
import java.text.ParseException;
import java.util.Date;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
@ -28,6 +28,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.stanza_content_encryption.element.AffixElement;
import org.jivesoftware.smackx.stanza_content_encryption.element.ContentElement;
import org.jivesoftware.smackx.stanza_content_encryption.element.FromAffixElement;
@ -102,7 +103,7 @@ public class ContentElementProvider extends ExtensionElementProvider<ContentElem
if (tag == XmlPullParser.Event.START_ELEMENT) {
String name = parser.getName();
String namespace = parser.getNamespace();
ExtensionElement element = PacketParserUtils.parseExtensionElement(name, namespace, parser, outerXmlEnvironment);
XmlElement element = PacketParserUtils.parseExtensionElement(name, namespace, parser, outerXmlEnvironment);
builder.addPayloadItem(element);
}

View file

@ -23,10 +23,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.MessageBuilder;
import org.jivesoftware.smack.packet.StanzaBuilder;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smackx.eme.element.ExplicitMessageEncryptionElement;
@ -44,7 +44,7 @@ public class ExplicitMessageEncryptionElementTest extends SmackTestSuite {
assertFalse(ExplicitMessageEncryptionElement.hasProtocol(message,
ExplicitMessageEncryptionElement.ExplicitMessageEncryptionProtocol.omemoVAxolotl));
List<ExtensionElement> extensions = message.getExtensions();
List<XmlElement> extensions = message.getExtensions();
assertEquals(0, extensions.size());
MessageBuilder messageBuilder = StanzaBuilder.buildMessage();

View file

@ -36,6 +36,7 @@ import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.test.util.SmackTestUtil;
import org.jivesoftware.smack.test.util.TestUtils;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.message_fastening.element.ExternalElement;
import org.jivesoftware.smackx.message_fastening.element.FasteningElement;
import org.jivesoftware.smackx.message_fastening.provider.FasteningElementProvider;

View file

@ -24,6 +24,7 @@ import java.io.IOException;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.test.util.SmackTestUtil;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.message_retraction.provider.RetractElementProvider;
import org.junit.jupiter.api.Test;

View file

@ -26,6 +26,7 @@ import java.util.Date;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.test.util.SmackTestUtil;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.message_retraction.provider.RetractedElementProvider;
import org.jivesoftware.smackx.sid.element.OriginIdElement;

View file

@ -25,6 +25,7 @@ import java.text.ParseException;
import java.util.Collections;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smackx.hints.element.StoreHint;
import org.jivesoftware.smackx.sid.element.StanzaIdElement;

View file

@ -29,6 +29,7 @@ import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.test.util.TestUtils;
import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.stanza_content_encryption.element.ContentElement;
import org.jivesoftware.smackx.stanza_content_encryption.element.FromAffixElement;
import org.jivesoftware.smackx.stanza_content_encryption.element.RandomPaddingAffixElement;

View file

@ -134,6 +134,7 @@ public class MultipleAddresses implements ExtensionElement {
public static final class Address implements ExtensionElement {
public static final String ELEMENT = "address";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
private final Type type;
private Jid jid;
@ -192,12 +193,12 @@ public class MultipleAddresses implements ExtensionElement {
@Override
public String getElementName() {
return ELEMENT;
return QNAME.getLocalPart();
}
@Override
public String getNamespace() {
return NAMESPACE;
return QNAME.getNamespaceURI();
}
@Override

View file

@ -16,6 +16,8 @@
*/
package org.jivesoftware.smackx.attention.packet;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
@ -44,6 +46,8 @@ public class AttentionExtension implements ExtensionElement {
*/
public static final String NAMESPACE = "urn:xmpp:attention:0";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT_NAME);
/*
* (non-Javadoc)
*
@ -51,7 +55,7 @@ public class AttentionExtension implements ExtensionElement {
*/
@Override
public String getElementName() {
return ELEMENT_NAME;
return QNAME.getLocalPart();
}
/*
@ -61,7 +65,7 @@ public class AttentionExtension implements ExtensionElement {
*/
@Override
public String getNamespace() {
return NAMESPACE;
return QNAME.getNamespaceURI();
}
/*

View file

@ -20,6 +20,7 @@ import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.StanzaView;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.bob.BoBData;
import org.jivesoftware.smackx.bob.BoBManager;
import org.jivesoftware.smackx.bob.ContentId;

View file

@ -23,6 +23,7 @@ import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.util.Pair;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.bob.BoBData;
import org.jivesoftware.smackx.bob.ContentId;
import org.jivesoftware.smackx.bob.element.BoBDataExtension;

View file

@ -23,6 +23,7 @@ import org.jivesoftware.smack.util.Pair;
import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.bob.BoBData;
import org.jivesoftware.smackx.bob.ContentId;

View file

@ -21,6 +21,8 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.util.InternetAddress;
@ -275,7 +277,8 @@ public class Bytestream extends IQ {
*/
public static class StreamHost extends BytestreamExtensionElement {
public static String ELEMENTNAME = "streamhost";
public static final String ELEMENT = "streamhost";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
private final Jid jid;
@ -344,7 +347,7 @@ public class Bytestream extends IQ {
@Override
public String getElementName() {
return ELEMENTNAME;
return QNAME.getLocalPart();
}
@Override
@ -375,7 +378,8 @@ public class Bytestream extends IQ {
*/
public static class StreamHostUsed extends BytestreamExtensionElement {
public static String ELEMENTNAME = "streamhost-used";
public static final String ELEMENT = "streamhost-used";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
private final Jid jid;
@ -399,7 +403,7 @@ public class Bytestream extends IQ {
@Override
public String getElementName() {
return ELEMENTNAME;
return QNAME.getLocalPart();
}
@Override
@ -418,7 +422,8 @@ public class Bytestream extends IQ {
*/
public static class Activate extends BytestreamExtensionElement {
public static String ELEMENTNAME = "activate";
public static final String ELEMENT = "activate";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
private final Jid target;
@ -442,7 +447,7 @@ public class Bytestream extends IQ {
@Override
public String getElementName() {
return ELEMENTNAME;
return QNAME.getLocalPart();
}
@Override

View file

@ -57,15 +57,15 @@ public class BytestreamsProvider extends IQProvider<Bytestream> {
eventType = parser.next();
elementName = parser.getName();
if (eventType == XmlPullParser.Event.START_ELEMENT) {
if (elementName.equals(Bytestream.StreamHost.ELEMENTNAME)) {
if (elementName.equals(Bytestream.StreamHost.ELEMENT)) {
JID = ParserUtils.getJidAttribute(parser);
host = parser.getAttributeValue("", "host");
port = parser.getAttributeValue("", "port");
}
else if (elementName.equals(Bytestream.StreamHostUsed.ELEMENTNAME)) {
else if (elementName.equals(Bytestream.StreamHostUsed.ELEMENT)) {
toReturn.setUsedHost(ParserUtils.getJidAttribute(parser));
}
else if (elementName.equals(Bytestream.Activate.ELEMENTNAME)) {
else if (elementName.equals(Bytestream.Activate.ELEMENT)) {
toReturn.setToActivate(ParserUtils.getJidAttribute(parser));
}
}

View file

@ -39,11 +39,11 @@ import org.jivesoftware.smack.filter.FromTypeFilter;
import org.jivesoftware.smack.filter.MessageTypeFilter;
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
import org.jivesoftware.smack.filter.StanzaFilter;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.MessageBuilder;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.StanzaBuilder;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smackx.chatstates.packet.ChatStateExtension;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
@ -142,7 +142,7 @@ public final class ChatStateManager extends Manager {
EntityBareJid bareFrom = fullFrom.asEntityBareJid();
final Chat chat = ChatManager.getInstanceFor(connection()).chatWith(bareFrom);
ExtensionElement extension = message.getExtension(NAMESPACE);
XmlElement extension = message.getExtension(NAMESPACE);
String chatStateElementName = extension.getElementName();
ChatState state;

View file

@ -17,7 +17,7 @@
package org.jivesoftware.smackx.chatstates.packet;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.chatstates.ChatState;
@ -29,7 +29,7 @@ import org.jivesoftware.smackx.chatstates.ChatState;
* @author Alexander Wenckus
* @see org.jivesoftware.smackx.chatstates.ChatState
*/
public class ChatStateExtension implements ExtensionElement {
public class ChatStateExtension implements XmlElement {
public static final String NAMESPACE = "http://jabber.org/protocol/chatstates";

View file

@ -20,8 +20,8 @@ package org.jivesoftware.smackx.commands.packet;
import java.util.ArrayList;
import java.util.List;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smackx.commands.AdHocCommand;
import org.jivesoftware.smackx.commands.AdHocCommand.Action;
@ -240,7 +240,7 @@ public class AdHocCommandData extends IQ {
return sessionID;
}
public static class SpecificError implements ExtensionElement {
public static class SpecificError implements XmlElement {
public static final String namespace = "http://jabber.org/protocol/commands";

View file

@ -24,6 +24,7 @@ import java.util.logging.Logger;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.XmlUtil;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.TextSingleFormField;
import org.jivesoftware.smackx.xdata.packet.DataForm;

View file

@ -22,8 +22,8 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.IQProvider;
@ -39,7 +39,7 @@ public class RegistrationProvider extends IQProvider<Registration> {
public Registration parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
String instruction = null;
Map<String, String> fields = new HashMap<>();
List<ExtensionElement> packetExtensions = new LinkedList<>();
List<XmlElement> packetExtensions = new LinkedList<>();
outerloop:
while (true) {
XmlPullParser.Event eventType = parser.next();

View file

@ -16,7 +16,7 @@
*/
package org.jivesoftware.smackx.jingle.element;
import org.jivesoftware.smack.packet.FullyQualifiedElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.StringUtils;
@ -25,7 +25,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
/**
* Jingle content element.
*/
public final class JingleContent implements FullyQualifiedElement {
public final class JingleContent implements XmlElement {
public static final String ELEMENT = "content";
public static final String NAMESPACE = Jingle.NAMESPACE;

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2017 Florian Schmaus.
* Copyright 2017-2021 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,15 +19,15 @@ package org.jivesoftware.smackx.jingle.element;
import java.util.Collections;
import java.util.List;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.NamedElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.util.XmlStringBuilder;
/**
* Jingle content description.
*
*/
public abstract class JingleContentDescription implements ExtensionElement {
public abstract class JingleContentDescription implements XmlElement {
public static final String ELEMENT = "description";

View file

@ -16,12 +16,12 @@
*/
package org.jivesoftware.smackx.jingle.element;
import org.jivesoftware.smack.packet.FullyQualifiedElement;
import org.jivesoftware.smack.packet.XmlElement;
/**
* An element found usually in 'description' elements.
*
*/
public interface JingleContentDescriptionChildElement extends FullyQualifiedElement {
public interface JingleContentDescriptionChildElement extends XmlElement {
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2017-2019 Florian Schmaus
* Copyright 2017-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.jingle.element;
import java.util.Collections;
import java.util.List;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.util.XmlStringBuilder;
@ -27,7 +27,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
* A jingle transport extension.
*
*/
public abstract class JingleContentTransport implements ExtensionElement {
public abstract class JingleContentTransport implements XmlElement {
public static final String ELEMENT = "transport";

View file

@ -16,13 +16,13 @@
*/
package org.jivesoftware.smackx.jingle.element;
import org.jivesoftware.smack.packet.FullyQualifiedElement;
import org.jivesoftware.smack.packet.XmlElement;
/**
* An element found usually in Jingle 'transport' elements.
*
*/
public abstract class JingleContentTransportCandidate implements FullyQualifiedElement {
public abstract class JingleContentTransportCandidate implements XmlElement {
public static final String ELEMENT = "candidate";

View file

@ -16,11 +16,11 @@
*/
package org.jivesoftware.smackx.jingle.element;
import org.jivesoftware.smack.packet.FullyQualifiedElement;
import org.jivesoftware.smack.packet.XmlElement;
/**
* Abstract JingleContentTransportInfo element.
*/
public interface JingleContentTransportInfo extends FullyQualifiedElement {
public interface JingleContentTransportInfo extends XmlElement {
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2003-2005 Jive Software, 2017 Florian Schmaus.
* Copyright 2003-2005 Jive Software, 2017-2021 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,10 +19,10 @@ package org.jivesoftware.smackx.jingle.element;
import java.util.Locale;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.util.XmlStringBuilder;
public final class JingleError implements ExtensionElement {
public final class JingleError implements XmlElement {
public static String NAMESPACE = "urn:xmpp:jingle:errors:1";

View file

@ -19,7 +19,7 @@ package org.jivesoftware.smackx.jingle.element;
import java.util.HashMap;
import java.util.Map;
import org.jivesoftware.smack.packet.FullyQualifiedElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.XmlStringBuilder;
@ -30,7 +30,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
* @see <a href="https://xmpp.org/extensions/xep-0166.html#def-reason">XEP-0166 § 7.4</a>
*
*/
public class JingleReason implements FullyQualifiedElement {
public class JingleReason implements XmlElement {
public static final String ELEMENT = "reason";
public static final String NAMESPACE = Jingle.NAMESPACE;

View file

@ -16,6 +16,9 @@
*/
package org.jivesoftware.smackx.jingle.transports.jingle_ibb.element;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.XmlStringBuilder;
@ -24,8 +27,10 @@ import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
/**
* Transport Element for JingleInBandBytestream transports.
*/
public class JingleIBBTransport extends JingleContentTransport {
public class JingleIBBTransport extends JingleContentTransport implements ExtensionElement {
public static final String NAMESPACE_V1 = "urn:xmpp:jingle:transports:ibb:1";
public static final QName QNAME = new QName(NAMESPACE_V1, ELEMENT);
public static final String ATTR_BLOCK_SIZE = "block-size";
public static final String ATTR_SID = "sid";
@ -72,7 +77,7 @@ public class JingleIBBTransport extends JingleContentTransport {
@Override
public String getNamespace() {
return NAMESPACE_V1;
return QNAME.getNamespaceURI();
}
@Override

View file

@ -19,6 +19,9 @@ package org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements;
import java.util.ArrayList;
import java.util.List;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.XmlStringBuilder;
@ -30,12 +33,14 @@ import org.jivesoftware.smackx.jingle.element.JingleContentTransportInfo;
/**
* Socks5Bytestream transport element.
*/
public class JingleS5BTransport extends JingleContentTransport {
public class JingleS5BTransport extends JingleContentTransport implements ExtensionElement {
public static final String NAMESPACE_V1 = "urn:xmpp:jingle:transports:s5b:1";
public static final String ATTR_DSTADDR = "dstaddr";
public static final String ATTR_MODE = "mode";
public static final String ATTR_SID = "sid";
public static final QName QNAME = new QName(NAMESPACE_V1, ELEMENT);
private final String streamId;
private final String dstAddr;
private final Bytestream.Mode mode;
@ -62,7 +67,7 @@ public class JingleS5BTransport extends JingleContentTransport {
@Override
public String getNamespace() {
return NAMESPACE_V1;
return QNAME.getNamespaceURI();
}
@Override

View file

@ -24,7 +24,7 @@ import java.util.List;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.datatypes.UInt16;
import org.jivesoftware.smack.packet.FullyQualifiedElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.StringUtils;
@ -130,7 +130,7 @@ public class MediaElement implements FormFieldChildElement {
}
}
public static final class Uri implements FullyQualifiedElement {
public static final class Uri implements XmlElement {
public static final String ELEMENT = "uri";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);

View file

@ -19,9 +19,9 @@ 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;
import org.jivesoftware.smack.packet.NamedElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.XmlStringBuilder;
@ -158,7 +158,7 @@ public class MoodElement implements ExtensionElement {
* {@link NamedElement} which represents the mood.
* This element has the element name of the mood selected from {@link Mood}.
*/
public static class MoodSubjectElement implements FullyQualifiedElement {
public static class MoodSubjectElement implements XmlElement {
private final Mood mood;
private final MoodConcretisation concretisation;

View file

@ -26,6 +26,7 @@ import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.offline.OfflineMessageManager;
/**

View file

@ -27,6 +27,7 @@ import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.offline.OfflineMessageManager;
/**

View file

@ -17,7 +17,7 @@
package org.jivesoftware.smackx.pubsub;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.XmlStringBuilder;
@ -36,7 +36,7 @@ import org.jxmpp.jid.BareJid;
*
* @author Robin Collier
*/
public class Affiliation implements ExtensionElement {
public class Affiliation implements XmlElement {
public static final String ELEMENT = "affiliation";
public enum AffiliationNamespace {

View file

@ -20,7 +20,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smackx.pubsub.form.FilledConfigureForm;
@ -48,10 +48,10 @@ public class ConfigurationEvent extends NodeExtension implements EmbeddedPacketE
}
@Override
public List<ExtensionElement> getExtensions() {
public List<XmlElement> getExtensions() {
if (getConfiguration() == null)
return Collections.emptyList();
else
return Arrays.asList((ExtensionElement) getConfiguration().getDataForm());
return Arrays.asList((XmlElement) getConfiguration().getDataForm());
}
}

View file

@ -20,6 +20,7 @@ import java.util.List;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.util.PacketParserUtils;
/**
@ -37,11 +38,11 @@ import org.jivesoftware.smack.util.PacketParserUtils;
*
* @author Robin Collier
*/
public interface EmbeddedPacketExtension extends ExtensionElement {
public interface EmbeddedPacketExtension extends XmlElement {
/**
* Get the list of embedded {@link ExtensionElement} objects.
*
* @return List of embedded {@link ExtensionElement}
*/
List<ExtensionElement> getExtensions();
List<XmlElement> getExtensions();
}

View file

@ -23,6 +23,7 @@ import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
@ -35,7 +36,7 @@ import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
*
* @author Robin Collier
*/
public class EventElement implements EmbeddedPacketExtension {
public class EventElement implements EmbeddedPacketExtension, ExtensionElement {
/**
* The constant String "event".
*/
@ -61,8 +62,8 @@ public class EventElement implements EmbeddedPacketExtension {
}
@Override
public List<ExtensionElement> getExtensions() {
return Arrays.asList(new ExtensionElement[] {getEvent()});
public List<XmlElement> getExtensions() {
return Arrays.asList(new XmlElement[] {getEvent()});
}
public NodeExtension getEvent() {
@ -71,12 +72,12 @@ public class EventElement implements EmbeddedPacketExtension {
@Override
public String getElementName() {
return "event";
return QNAME.getLocalPart();
}
@Override
public String getNamespace() {
return PubSubNamespace.event.getXmlns();
return QNAME.getNamespaceURI();
}
@Override

View file

@ -20,6 +20,7 @@ import java.util.List;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.NamedElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.util.XmlStringBuilder;
/**
@ -127,8 +128,8 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
@Override
@SuppressWarnings("unchecked")
public List<ExtensionElement> getExtensions() {
return (List<ExtensionElement>) getItems();
public List<XmlElement> getExtensions() {
return (List<XmlElement>) getItems();
}
/**

View file

@ -23,8 +23,8 @@ import java.util.List;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
import org.jivesoftware.smackx.pubsub.form.ConfigureForm;
@ -71,7 +71,7 @@ public class LeafNode extends Node {
* @throws InterruptedException if the calling thread was interrupted.
*/
public <T extends Item> List<T> getItems() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
return getItems((List<ExtensionElement>) null, null);
return getItems((List<XmlElement>) null, null);
}
/**
@ -177,8 +177,8 @@ public class LeafNode extends Node {
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
public <T extends Item> List<T> getItems(List<ExtensionElement> additionalExtensions,
List<ExtensionElement> returnedExtensions) throws NoResponseException,
public <T extends Item> List<T> getItems(List<XmlElement> additionalExtensions,
List<XmlElement> returnedExtensions) throws NoResponseException,
XMPPErrorException, NotConnectedException, InterruptedException {
PubSub request = createPubsubPacket(IQ.Type.get, new GetItemsRequest(getId()));
request.addExtensions(additionalExtensions);
@ -192,7 +192,7 @@ public class LeafNode extends Node {
@SuppressWarnings("unchecked")
private <T extends Item> List<T> getItems(PubSub request,
List<ExtensionElement> returnedExtensions) throws NoResponseException,
List<XmlElement> returnedExtensions) throws NoResponseException,
XMPPErrorException, NotConnectedException, InterruptedException {
PubSub result = pubSubManager.getConnection().createStanzaCollectorAndSend(request).nextResultOrThrow();
ItemsExtension itemsElem = result.getExtension(PubSubElementType.ITEMS);

View file

@ -28,10 +28,10 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.FlexibleStanzaTypeFilter;
import org.jivesoftware.smack.filter.OrFilter;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smackx.delay.DelayInformationManager;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
@ -163,7 +163,7 @@ public abstract class Node {
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
public List<Subscription> getSubscriptions(List<ExtensionElement> additionalExtensions, Collection<ExtensionElement> returnedExtensions)
public List<Subscription> getSubscriptions(List<XmlElement> additionalExtensions, Collection<XmlElement> returnedExtensions)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
return getSubscriptions(SubscriptionsNamespace.basic, additionalExtensions, returnedExtensions);
}
@ -207,20 +207,20 @@ public abstract class Node {
* Retrieve Subscriptions List</a>
* @since 4.1
*/
public List<Subscription> getSubscriptionsAsOwner(List<ExtensionElement> additionalExtensions,
Collection<ExtensionElement> returnedExtensions) throws NoResponseException, XMPPErrorException,
public List<Subscription> getSubscriptionsAsOwner(List<XmlElement> additionalExtensions,
Collection<XmlElement> returnedExtensions) throws NoResponseException, XMPPErrorException,
NotConnectedException, InterruptedException {
return getSubscriptions(SubscriptionsNamespace.owner, additionalExtensions, returnedExtensions);
}
private List<Subscription> getSubscriptions(SubscriptionsNamespace subscriptionsNamespace, List<ExtensionElement> additionalExtensions,
Collection<ExtensionElement> returnedExtensions)
private List<Subscription> getSubscriptions(SubscriptionsNamespace subscriptionsNamespace, List<XmlElement> additionalExtensions,
Collection<XmlElement> returnedExtensions)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSubElementType pubSubElementType = subscriptionsNamespace.type;
PubSub pubSub = createPubsubPacket(IQ.Type.get, new NodeExtension(pubSubElementType, getId()));
if (additionalExtensions != null) {
for (ExtensionElement pe : additionalExtensions) {
for (XmlElement pe : additionalExtensions) {
pubSub.addExtension(pe);
}
}
@ -286,7 +286,7 @@ public abstract class Node {
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
public List<Affiliation> getAffiliations(List<ExtensionElement> additionalExtensions, Collection<ExtensionElement> returnedExtensions)
public List<Affiliation> getAffiliations(List<XmlElement> additionalExtensions, Collection<XmlElement> returnedExtensions)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
return getAffiliations(AffiliationNamespace.basic, additionalExtensions, returnedExtensions);
@ -326,20 +326,20 @@ public abstract class Node {
* @see <a href="http://www.xmpp.org/extensions/xep-0060.html#owner-affiliations-retrieve">XEP-60 § 8.9.1 Retrieve Affiliations List</a>
* @since 4.2
*/
public List<Affiliation> getAffiliationsAsOwner(List<ExtensionElement> additionalExtensions, Collection<ExtensionElement> returnedExtensions)
public List<Affiliation> getAffiliationsAsOwner(List<XmlElement> additionalExtensions, Collection<XmlElement> returnedExtensions)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
return getAffiliations(AffiliationNamespace.owner, additionalExtensions, returnedExtensions);
}
private List<Affiliation> getAffiliations(AffiliationNamespace affiliationsNamespace, List<ExtensionElement> additionalExtensions,
Collection<ExtensionElement> returnedExtensions) throws NoResponseException, XMPPErrorException,
private List<Affiliation> getAffiliations(AffiliationNamespace affiliationsNamespace, List<XmlElement> additionalExtensions,
Collection<XmlElement> returnedExtensions) throws NoResponseException, XMPPErrorException,
NotConnectedException, InterruptedException {
PubSubElementType pubSubElementType = affiliationsNamespace.type;
PubSub pubSub = createPubsubPacket(IQ.Type.get, new NodeExtension(pubSubElementType, getId()));
if (additionalExtensions != null) {
for (ExtensionElement pe : additionalExtensions) {
for (XmlElement pe : additionalExtensions) {
pubSub.addExtension(pe);
}
}
@ -717,7 +717,7 @@ public abstract class Node {
// CHECKSTYLE:OFF
EventElement event = (EventElement) packet.getExtensionElement("event", PubSubNamespace.event.getXmlns());
List<ExtensionElement> extList = event.getExtensions();
List<XmlElement> extList = event.getExtensions();
if (extList.get(0).getElementName().equals(PubSubElementType.PURGE_EVENT.getElementName())) {
listener.handlePurge();
@ -804,7 +804,7 @@ public abstract class Node {
return true;
if (embedEvent instanceof EmbeddedPacketExtension) {
List<ExtensionElement> secondLevelList = ((EmbeddedPacketExtension) embedEvent).getExtensions();
List<XmlElement> secondLevelList = ((EmbeddedPacketExtension) embedEvent).getExtensions();
// XEP-0060 allows no elements on second level for notifications. See schema or
// for example § 4.3:

View file

@ -16,7 +16,7 @@
*/
package org.jivesoftware.smackx.pubsub;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.util.XmlStringBuilder;
@ -30,7 +30,7 @@ import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
*
* @author Robin Collier
*/
public class NodeExtension implements ExtensionElement {
public class NodeExtension implements XmlElement {
private final PubSubElementType element;
private final String node;

Some files were not shown because too many files have changed in this diff Show more