1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-22 12:02:05 +01:00

Add JivePropertiesExtension.from(Message)

This commit is contained in:
Florian Schmaus 2015-03-25 10:25:59 +01:00
parent e1cb837489
commit 6a5637c2e4
2 changed files with 12 additions and 1 deletions

View file

@ -28,6 +28,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.util.XmlStringBuilder; import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smack.util.stringencoder.Base64; import org.jivesoftware.smack.util.stringencoder.Base64;
@ -219,4 +220,14 @@ public class JivePropertiesExtension implements ExtensionElement {
return xml; 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);
}
} }

View file

@ -54,7 +54,7 @@ public class JivePropertiesExtensionTest extends InitExtensions {
// @formatter:on // @formatter:on
Message message = (Message) PacketParserUtils.parseStanza(properties); Message message = (Message) PacketParserUtils.parseStanza(properties);
JivePropertiesExtension jpe = (JivePropertiesExtension) message.getExtension(JivePropertiesExtension.NAMESPACE); JivePropertiesExtension jpe = JivePropertiesExtension.from(message);
assertNotNull(jpe); assertNotNull(jpe);
Integer integer = (Integer) jpe.getProperty("FooBar"); Integer integer = (Integer) jpe.getProperty("FooBar");