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:
parent
e1cb837489
commit
6a5637c2e4
2 changed files with 12 additions and 1 deletions
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
||||||
|
|
Loading…
Reference in a new issue