本文整理了Java中org.jivesoftware.smack.packet.Message.getExtensions()
方法的一些代码示例,展示了Message.getExtensions()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getExtensions()
方法的具体详情如下:
包路径:org.jivesoftware.smack.packet.Message
类名称:Message
方法名:getExtensions
暂无
代码示例来源:origin: igniterealtime/Smack
/**
* Returns a set of all bodies in this Message, including the default message body accessible
* from {@link #getBody()}.
*
* @return a collection of all bodies in this Message.
* @since 3.0.2
*/
public Set<Body> getBodies() {
List<ExtensionElement> bodiesList = getExtensions(Body.ELEMENT, Body.NAMESPACE);
Set<Body> resultSet = new HashSet<>(bodiesList.size());
for (ExtensionElement extensionElement : bodiesList) {
Body body = (Body) extensionElement;
resultSet.add(body);
}
return resultSet;
}
代码示例来源:origin: igniterealtime/Smack
/**
* Return true, if the {@code message} already contains an EME element with the specified {@code protocolNamespace}.
*
* @param message message
* @param protocolNamespace namespace
* @return true if message has EME element for that namespace, otherwise false
*/
public static boolean hasProtocol(Message message, String protocolNamespace) {
List<ExtensionElement> extensionElements = message.getExtensions(
ExplicitMessageEncryptionElement.ELEMENT,
ExplicitMessageEncryptionElement.NAMESPACE);
for (ExtensionElement extensionElement : extensionElements) {
ExplicitMessageEncryptionElement e = (ExplicitMessageEncryptionElement) extensionElement;
if (e.getEncryptionNamespace().equals(protocolNamespace)) {
return true;
}
}
return false;
}
代码示例来源:origin: igniterealtime/Smack
/**
* Return a map of all spoilers contained in a message.
* The map uses the language of a spoiler as key.
* If a spoiler has no language attribute, its key will be an empty String.
*
* @param message message
* @return map of spoilers
*/
public static Map<String, String> getSpoilers(Message message) {
if (!containsSpoiler(message)) {
return Collections.emptyMap();
}
List<ExtensionElement> spoilers = message.getExtensions(SpoilerElement.ELEMENT, NAMESPACE);
Map<String, String> map = new HashMap<>();
for (ExtensionElement e : spoilers) {
SpoilerElement s = (SpoilerElement) e;
if (s.getLanguage() == null || s.getLanguage().equals("")) {
map.put("", s.getHint());
} else {
map.put(s.getLanguage(), s.getHint());
}
}
return map;
}
代码示例来源:origin: igniterealtime/Smack
ExplicitMessageEncryptionElement.ExplicitMessageEncryptionProtocol.omemoVAxolotl));
List<ExtensionElement> extensions = message.getExtensions();
assertEquals(0, extensions.size());
extensions = message.getExtensions();
assertEquals(1, extensions.size());
assertTrue(ExplicitMessageEncryptionElement.hasProtocol(message,
extensions = message.getExtensions();
assertEquals(2, extensions.size());
assertTrue(ExplicitMessageEncryptionElement.hasProtocol(message,
ExplicitMessageEncryptionElement.ExplicitMessageEncryptionProtocol.omemoVAxolotl);
extensions = message.getExtensions();
assertEquals(2, extensions.size());
代码示例来源:origin: igniterealtime/Smack
@Override
public XmlStringBuilder toXML(String enclosingNamespace) {
XmlStringBuilder buf = new XmlStringBuilder(enclosingNamespace);
buf.halfOpenElement(ELEMENT);
enclosingNamespace = addCommonAttributes(buf, enclosingNamespace);
buf.optAttribute("type", type);
buf.rightAngleBracket();
// Add the subject in the default language
Subject defaultSubject = getMessageSubject(null);
if (defaultSubject != null) {
buf.element("subject", defaultSubject.subject);
}
// Add the subject in other languages
for (Subject subject : getSubjects()) {
// Skip the default language
if (subject.equals(defaultSubject))
continue;
buf.append(subject.toXML(null));
}
buf.optElement("thread", thread);
// Append the error subpacket if the message type is an error.
if (type == Type.error) {
appendErrorIfExists(buf, enclosingNamespace);
}
// Add extension elements, if any are defined.
buf.append(getExtensions(), enclosingNamespace);
buf.closeElement(ELEMENT);
return buf;
}
代码示例来源:origin: spring-projects/spring-integration
EvaluationContext evaluationContextToUse = ChatMessageListeningEndpoint.this.evaluationContext;
List<ExtensionElement> extensions = xmppMessage.getExtensions();
if (extensions.size() == 1) {
ExtensionElement extension = extensions.get(0);
代码示例来源:origin: org.igniterealtime.smack/smack-core
/**
* Returns a set of all bodies in this Message, including the default message body accessible
* from {@link #getBody()}.
*
* @return a collection of all bodies in this Message.
* @since 3.0.2
*/
public Set<Body> getBodies() {
List<ExtensionElement> bodiesList = getExtensions(Body.ELEMENT, Body.NAMESPACE);
Set<Body> resultSet = new HashSet<>(bodiesList.size());
for (ExtensionElement extensionElement : bodiesList) {
Body body = (Body) extensionElement;
resultSet.add(body);
}
return resultSet;
}
代码示例来源:origin: org.igniterealtime.smack/smack-experimental
/**
* Return a map of all spoilers contained in a message.
* The map uses the language of a spoiler as key.
* If a spoiler has no language attribute, its key will be an empty String.
*
* @param message message
* @return map of spoilers
*/
public static Map<String, String> getSpoilers(Message message) {
if (!containsSpoiler(message)) {
return Collections.emptyMap();
}
List<ExtensionElement> spoilers = message.getExtensions(SpoilerElement.ELEMENT, NAMESPACE);
Map<String, String> map = new HashMap<>();
for (ExtensionElement e : spoilers) {
SpoilerElement s = (SpoilerElement) e;
if (s.getLanguage() == null || s.getLanguage().equals("")) {
map.put("", s.getHint());
} else {
map.put(s.getLanguage(), s.getHint());
}
}
return map;
}
代码示例来源:origin: org.igniterealtime.smack/smack-core
@Override
public XmlStringBuilder toXML(String enclosingNamespace) {
XmlStringBuilder buf = new XmlStringBuilder(enclosingNamespace);
buf.halfOpenElement(ELEMENT);
enclosingNamespace = addCommonAttributes(buf, enclosingNamespace);
buf.optAttribute("type", type);
buf.rightAngleBracket();
// Add the subject in the default language
Subject defaultSubject = getMessageSubject(null);
if (defaultSubject != null) {
buf.element("subject", defaultSubject.subject);
}
// Add the subject in other languages
for (Subject subject : getSubjects()) {
// Skip the default language
if (subject.equals(defaultSubject))
continue;
buf.append(subject.toXML(null));
}
buf.optElement("thread", thread);
// Append the error subpacket if the message type is an error.
if (type == Type.error) {
appendErrorIfExists(buf, enclosingNamespace);
}
// Add extension elements, if any are defined.
buf.append(getExtensions(), enclosingNamespace);
buf.closeElement(ELEMENT);
return buf;
}
内容来源于网络,如有侵权,请联系作者删除!