1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-22 10:37:59 +01:00

Rename Stanza.getExtension(String, String) to getExtensionElement()

This commit is contained in:
Florian Schmaus 2020-04-12 12:09:04 +02:00
parent 9879dea0bf
commit 7a57bb7c09
23 changed files with 39 additions and 39 deletions

View file

@ -338,7 +338,7 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
/**
* Returns the first extension of this stanza that has the given namespace.
* <p>
* When possible, use {@link #getExtension(String, String)} instead.
* When possible, use {@link #getExtensionElement(String, String)} instead.
* </p>
*
* @param namespace the namespace of the extension that is desired.
@ -358,7 +358,7 @@ 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 getExtension(String elementName, String namespace) {
public final ExtensionElement getExtensionElement(String elementName, String namespace) {
if (namespace == null) {
return null;
}

View file

@ -114,9 +114,9 @@ public class CarbonExtension implements ExtensionElement {
* @return a Carbon if available, null otherwise.
*/
public static CarbonExtension from(Message msg) {
CarbonExtension cc = (CarbonExtension) msg.getExtension(Direction.received.name(), NAMESPACE);
CarbonExtension cc = (CarbonExtension) msg.getExtensionElement(Direction.received.name(), NAMESPACE);
if (cc == null)
cc = (CarbonExtension) msg.getExtension(Direction.sent.name(), NAMESPACE);
cc = (CarbonExtension) msg.getExtensionElement(Direction.sent.name(), NAMESPACE);
return cc;
}

View file

@ -48,7 +48,7 @@ public final class NoCopyHint extends MessageProcessingHint {
}
public static NoCopyHint from(Message message) {
return (NoCopyHint) message.getExtension(ELEMENT, NAMESPACE);
return (NoCopyHint) message.getExtensionElement(ELEMENT, NAMESPACE);
}
public static boolean hasHint(Message message) {

View file

@ -48,7 +48,7 @@ public final class NoPermanentStoreHint extends MessageProcessingHint {
}
public static NoPermanentStoreHint from(Message message) {
return (NoPermanentStoreHint) message.getExtension(ELEMENT, NAMESPACE);
return (NoPermanentStoreHint) message.getExtensionElement(ELEMENT, NAMESPACE);
}
public static boolean hasHint(Message message) {

View file

@ -48,7 +48,7 @@ public final class NoStoreHint extends MessageProcessingHint {
}
public static NoStoreHint from(Message message) {
return (NoStoreHint) message.getExtension(ELEMENT, NAMESPACE);
return (NoStoreHint) message.getExtensionElement(ELEMENT, NAMESPACE);
}
public static boolean hasHint(Message message) {

View file

@ -140,7 +140,7 @@ public class MamElements {
}
public static MamResultExtension from(Message message) {
return (MamResultExtension) message.getExtension(ELEMENT, NAMESPACE);
return (MamResultExtension) message.getExtensionElement(ELEMENT, NAMESPACE);
}
}

View file

@ -233,7 +233,7 @@ public abstract class MUCLightElements {
}
public static ConfigurationsChangeExtension from(Message message) {
return (ConfigurationsChangeExtension) message.getExtension(ConfigurationsChangeExtension.ELEMENT, ConfigurationsChangeExtension.NAMESPACE);
return (ConfigurationsChangeExtension) message.getExtensionElement(ConfigurationsChangeExtension.ELEMENT, ConfigurationsChangeExtension.NAMESPACE);
}
}

View file

@ -82,7 +82,7 @@ public class OriginIdElement extends StableAndUniqueIdElement {
* @return origin-id element
*/
public static OriginIdElement getOriginId(Message message) {
return (OriginIdElement) message.getExtension(OriginIdElement.ELEMENT, StableUniqueStanzaIdManager.NAMESPACE);
return (OriginIdElement) message.getExtensionElement(OriginIdElement.ELEMENT, StableUniqueStanzaIdManager.NAMESPACE);
}
@Override

View file

@ -44,7 +44,7 @@ public class SpoilerTest extends SmackTestSuite {
Message message = StanzaBuilder.buildMessage().build();
SpoilerElement.addSpoiler(message);
SpoilerElement empty = (SpoilerElement) message.getExtension(SpoilerElement.ELEMENT, SpoilerManager.NAMESPACE_0);
SpoilerElement empty = (SpoilerElement) message.getExtensionElement(SpoilerElement.ELEMENT, SpoilerManager.NAMESPACE_0);
assertNull(empty.getHint());
assertNull(empty.getLanguage());
@ -63,7 +63,7 @@ public class SpoilerTest extends SmackTestSuite {
Message message = StanzaBuilder.buildMessage().build();
SpoilerElement.addSpoiler(message, "Love story end");
SpoilerElement withHint = (SpoilerElement) message.getExtension(SpoilerElement.ELEMENT, SpoilerManager.NAMESPACE_0);
SpoilerElement withHint = (SpoilerElement) message.getExtensionElement(SpoilerElement.ELEMENT, SpoilerManager.NAMESPACE_0);
assertEquals("Love story end", withHint.getHint());
assertNull(withHint.getLanguage());
@ -83,7 +83,7 @@ public class SpoilerTest extends SmackTestSuite {
Message message = StanzaBuilder.buildMessage().build();
SpoilerElement.addSpoiler(message, "de", "Der Kuchen ist eine Lüge!");
SpoilerElement i18nHint = (SpoilerElement) message.getExtension(SpoilerElement.ELEMENT, SpoilerManager.NAMESPACE_0);
SpoilerElement i18nHint = (SpoilerElement) message.getExtensionElement(SpoilerElement.ELEMENT, SpoilerManager.NAMESPACE_0);
assertEquals("Der Kuchen ist eine Lüge!", i18nHint.getHint());
assertEquals("de", i18nHint.getLanguage());

View file

@ -91,7 +91,7 @@ public class BoBExtension extends XHTMLExtension {
}
public static BoBExtension from(Message message) {
return (BoBExtension) message.getExtension(ELEMENT, NAMESPACE);
return (BoBExtension) message.getExtensionElement(ELEMENT, NAMESPACE);
}
}

View file

@ -53,7 +53,7 @@ public class Occupant {
}
Occupant(Presence presence) {
MUCUser mucUser = (MUCUser) presence.getExtension("x",
MUCUser mucUser = (MUCUser) presence.getExtensionElement("x",
"http://jabber.org/protocol/muc#user");
MUCItem item = mucUser.getItem();
this.jid = item.getJid();

View file

@ -686,7 +686,7 @@ public abstract class Node {
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void processStanza(Stanza packet) {
EventElement event = (EventElement) packet.getExtension("event", PubSubNamespace.event.getXmlns());
EventElement event = (EventElement) packet.getExtensionElement("event", PubSubNamespace.event.getXmlns());
ItemsExtension itemsElem = (ItemsExtension) event.getEvent();
ItemPublishEvent eventItems = new ItemPublishEvent(itemsElem.getNode(), itemsElem.getItems(), getSubscriptionIds(packet), DelayInformationManager.getDelayTimestamp(packet));
// TODO: Use AsyncButOrdered (with Node as Key?)
@ -710,7 +710,7 @@ public abstract class Node {
@Override
public void processStanza(Stanza packet) {
// CHECKSTYLE:OFF
EventElement event = (EventElement) packet.getExtension("event", PubSubNamespace.event.getXmlns());
EventElement event = (EventElement) packet.getExtensionElement("event", PubSubNamespace.event.getXmlns());
List<ExtensionElement> extList = event.getExtensions();
@ -749,7 +749,7 @@ public abstract class Node {
@Override
public void processStanza(Stanza packet) {
EventElement event = (EventElement) packet.getExtension("event", PubSubNamespace.event.getXmlns());
EventElement event = (EventElement) packet.getExtensionElement("event", PubSubNamespace.event.getXmlns());
ConfigurationEvent config = (ConfigurationEvent) event.getEvent();
// TODO: Use AsyncButOrdered (with Node as Key?)

View file

@ -503,7 +503,7 @@ public final class PubSubManager extends Manager {
*/
public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Stanza reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS), null);
SubscriptionsExtension subElem = (SubscriptionsExtension) reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
SubscriptionsExtension subElem = (SubscriptionsExtension) reply.getExtensionElement(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
return subElem.getSubscriptions();
}

View file

@ -51,7 +51,7 @@ public class PubSub extends IQ {
@SuppressWarnings("unchecked")
public <PE extends ExtensionElement> PE getExtension(PubSubElementType elem) {
return (PE) getExtension(elem.getElementName(), elem.getNamespace().getXmlns());
return (PE) getExtensionElement(elem.getElementName(), elem.getNamespace().getXmlns());
}
/**

View file

@ -37,7 +37,7 @@ public class NodeUtils {
* @return The configuration form
*/
public static ConfigureForm getFormFromPacket(Stanza packet, PubSubElementType elem) {
FormNode config = (FormNode) packet.getExtension(elem.getElementName(), elem.getNamespace().getXmlns());
FormNode config = (FormNode) packet.getExtensionElement(elem.getElementName(), elem.getNamespace().getXmlns());
Form formReply = config.getForm();
return new ConfigureForm(formReply);
}

View file

@ -151,7 +151,7 @@ public class RSMSet implements ExtensionElement {
}
public static RSMSet from(Stanza packet) {
return (RSMSet) packet.getExtension(ELEMENT, NAMESPACE);
return (RSMSet) packet.getExtensionElement(ELEMENT, NAMESPACE);
}
public static RSMSet newAfter(String after) {

View file

@ -89,7 +89,7 @@ public class XHTMLManager {
* @return a boolean indicating whether the message is an XHTML message
*/
public static boolean isXHTMLMessage(Message message) {
return message.getExtension(XHTMLExtension.ELEMENT, XHTMLExtension.NAMESPACE) != null;
return message.getExtensionElement(XHTMLExtension.ELEMENT, XHTMLExtension.NAMESPACE) != null;
}
/**

View file

@ -317,7 +317,7 @@ public class AgentRoster {
// for a particular user a map with the presence packets saved for each resource.
if (presence.getType() == Presence.Type.available) {
// Ignore the presence packet unless it has an agent status extension.
AgentStatus agentStatus = (AgentStatus) presence.getExtension(
AgentStatus agentStatus = (AgentStatus) presence.getExtensionElement(
AgentStatus.ELEMENT_NAME, AgentStatus.NAMESPACE);
if (agentStatus == null) {
return;

View file

@ -784,7 +784,7 @@ public class AgentSession {
}
// QueueOverview packet extensions contain basic information about a queue.
QueueOverview queueOverview = (QueueOverview) presence.getExtension(QueueOverview.ELEMENT_NAME, QueueOverview.NAMESPACE);
QueueOverview queueOverview = (QueueOverview) presence.getExtensionElement(QueueOverview.ELEMENT_NAME, QueueOverview.NAMESPACE);
if (queueOverview != null) {
if (queueOverview.getStatus() == null) {
queue.setStatus(WorkgroupQueue.Status.CLOSED);
@ -803,7 +803,7 @@ public class AgentSession {
// QueueDetails packet extensions contain information about the users in
// a queue.
QueueDetails queueDetails = (QueueDetails) packet.getExtension(QueueDetails.ELEMENT_NAME, QueueDetails.NAMESPACE);
QueueDetails queueDetails = (QueueDetails) packet.getExtensionElement(QueueDetails.ELEMENT_NAME, QueueDetails.NAMESPACE);
if (queueDetails != null) {
queue.setUsers(queueDetails.getUsers());
// Fire event.
@ -812,7 +812,7 @@ public class AgentSession {
}
// Notify agent packets gives an overview of agent activity in a queue.
StandardExtensionElement notifyAgents = (StandardExtensionElement) presence.getExtension("notify-agents", "http://jabber.org/protocol/workgroup");
StandardExtensionElement notifyAgents = (StandardExtensionElement) presence.getExtensionElement("notify-agents", "http://jabber.org/protocol/workgroup");
if (notifyAgents != null) {
int currentChats = Integer.parseInt(notifyAgents.getFirstElement("current-chats", "http://jabber.org/protocol/workgroup").getText());
int maxChats = Integer.parseInt(notifyAgents.getFirstElement("max-chats", "http://jabber.org/protocol/workgroup").getText());
@ -833,13 +833,13 @@ public class AgentSession {
String sessionID = null;
Map<String, List<String>> metaData = null;
SessionID sessionIDExt = (SessionID) message.getExtension(SessionID.ELEMENT_NAME,
SessionID sessionIDExt = (SessionID) message.getExtensionElement(SessionID.ELEMENT_NAME,
SessionID.NAMESPACE);
if (sessionIDExt != null) {
sessionID = sessionIDExt.getSessionID();
}
MetaData metaDataExt = (MetaData) message.getExtension(MetaData.ELEMENT_NAME,
MetaData metaDataExt = (MetaData) message.getExtensionElement(MetaData.ELEMENT_NAME,
MetaData.NAMESPACE);
if (metaDataExt != null) {
metaData = metaDataExt.getMetaData();

View file

@ -515,8 +515,8 @@ public class Workgroup {
if (packet instanceof Message) {
Message msg = (Message) packet;
// Check to see if the user left the queue.
ExtensionElement pe = msg.getExtension("depart-queue", "http://jabber.org/protocol/workgroup");
ExtensionElement queueStatus = msg.getExtension("queue-status", "http://jabber.org/protocol/workgroup");
ExtensionElement pe = msg.getExtensionElement("depart-queue", "http://jabber.org/protocol/workgroup");
ExtensionElement queueStatus = msg.getExtensionElement("queue-status", "http://jabber.org/protocol/workgroup");
if (pe != null) {
fireQueueDepartedEvent();
@ -539,13 +539,13 @@ public class Workgroup {
String sessionID = null;
Map<String, List<String>> metaData = null;
pe = msg.getExtension(SessionID.ELEMENT_NAME,
pe = msg.getExtensionElement(SessionID.ELEMENT_NAME,
SessionID.NAMESPACE);
if (pe != null) {
sessionID = ((SessionID) pe).getSessionID();
}
pe = msg.getExtension(MetaData.ELEMENT_NAME,
pe = msg.getExtensionElement(MetaData.ELEMENT_NAME,
MetaData.NAMESPACE);
if (pe != null) {
metaData = ((MetaData) pe).getMetaData();

View file

@ -82,7 +82,7 @@ public final class MessageEventManager extends Manager {
@Override
public void processStanza(Stanza packet) {
Message message = (Message) packet;
MessageEvent messageEvent = (MessageEvent) message.getExtension("x", "jabber:x:event");
MessageEvent messageEvent = (MessageEvent) message.getExtensionElement("x", "jabber:x:event");
if (messageEvent.isMessageEventRequest()) {
// Fire event for requests of message events
for (String eventType : messageEvent.getEventTypes())

View file

@ -84,7 +84,7 @@ public class RosterExchangeManager {
@Override
public void processStanza(Stanza packet) {
Message message = (Message) packet;
RosterExchange rosterExchange = (RosterExchange) message.getExtension(ELEMENT, NAMESPACE);
RosterExchange rosterExchange = (RosterExchange) message.getExtensionElement(ELEMENT, NAMESPACE);
// Fire event for roster exchange listeners
fireRosterExchangeListeners(message.getFrom(), rosterExchange.getRosterEntries());
}

View file

@ -1051,7 +1051,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
for (Message message : mamQuery.getMessages()) {
if (OmemoManager.stanzaContainsOmemoElement(message)) {
OmemoElement element =
(OmemoElement) message.getExtension(OmemoElement.NAME_ENCRYPTED, OmemoConstants.OMEMO_NAMESPACE_V_AXOLOTL);
(OmemoElement) message.getExtensionElement(OmemoElement.NAME_ENCRYPTED, OmemoConstants.OMEMO_NAMESPACE_V_AXOLOTL);
// Decrypt OMEMO messages
try {
OmemoMessage.Received omemoMessage = decryptMessage(managerGuard, message.getFrom().asBareJid(), element);
@ -1080,7 +1080,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
// Avoid the ratchet being manipulated and the bundle being published multiple times simultaneously
synchronized (manager) {
OmemoDevice userDevice = manager.getOwnDevice();
OmemoElement element = (OmemoElement) carbonCopy.getExtension(OmemoElement.NAME_ENCRYPTED, OmemoElement_VAxolotl.NAMESPACE);
OmemoElement element = (OmemoElement) carbonCopy.getExtensionElement(OmemoElement.NAME_ENCRYPTED, OmemoElement_VAxolotl.NAMESPACE);
if (element == null) {
return;
}
@ -1137,7 +1137,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
// Avoid the ratchet being manipulated and the bundle being published multiple times simultaneously
synchronized (manager) {
OmemoDevice userDevice = manager.getOwnDevice();
OmemoElement element = (OmemoElement) stanza.getExtension(OmemoElement.NAME_ENCRYPTED, OmemoElement_VAxolotl.NAMESPACE);
OmemoElement element = (OmemoElement) stanza.getExtensionElement(OmemoElement.NAME_ENCRYPTED, OmemoElement_VAxolotl.NAMESPACE);
if (element == null) {
return;
}
@ -1228,7 +1228,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
// Avoid the ratchet being manipulated and the bundle being published multiple times simultaneously
synchronized (manager) {
OmemoDevice userDevice = manager.getOwnDevice();
OmemoElement element = (OmemoElement) stanza.getExtension(OmemoElement.NAME_ENCRYPTED, OmemoElement_VAxolotl.NAMESPACE);
OmemoElement element = (OmemoElement) stanza.getExtensionElement(OmemoElement.NAME_ENCRYPTED, OmemoElement_VAxolotl.NAMESPACE);
if (element == null) {
return null;
}