From 6a5637c2e465dda69ec0d310e2514902d55feeba Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 25 Mar 2015 10:25:59 +0100 Subject: [PATCH] Add JivePropertiesExtension.from(Message) --- .../packet/JivePropertiesExtension.java | 11 +++++++++++ .../jiveproperties/JivePropertiesExtensionTest.java | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/packet/JivePropertiesExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/packet/JivePropertiesExtension.java index de9b1005f..843626de3 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/packet/JivePropertiesExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/packet/JivePropertiesExtension.java @@ -28,6 +28,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.jivesoftware.smack.packet.ExtensionElement; +import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.util.XmlStringBuilder; import org.jivesoftware.smack.util.stringencoder.Base64; @@ -219,4 +220,14 @@ public class JivePropertiesExtension implements ExtensionElement { return xml; } + /** + * Return a Jive properties extensions of the given message. + * + * @param message the message to return the extension from. + * @return a Jive properties extension or null. + * @since 4.2 + */ + public static JivePropertiesExtension from(Message message) { + return message.getExtension(ELEMENT, NAMESPACE); + } } diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/jiveproperties/JivePropertiesExtensionTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/jiveproperties/JivePropertiesExtensionTest.java index 74d7a0b5e..179165af9 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/jiveproperties/JivePropertiesExtensionTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/jiveproperties/JivePropertiesExtensionTest.java @@ -54,7 +54,7 @@ public class JivePropertiesExtensionTest extends InitExtensions { // @formatter:on Message message = (Message) PacketParserUtils.parseStanza(properties); - JivePropertiesExtension jpe = (JivePropertiesExtension) message.getExtension(JivePropertiesExtension.NAMESPACE); + JivePropertiesExtension jpe = JivePropertiesExtension.from(message); assertNotNull(jpe); Integer integer = (Integer) jpe.getProperty("FooBar");