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 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);
}
}

View File

@ -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");