Example #1
0
 /**
  * Adds a stanza(/packet) extension to the packet. Does nothing if extension is null.
  *
  * @param extension a stanza(/packet) extension.
  */
 public void addExtension(ExtensionElement extension) {
   if (extension == null) return;
   String key = XmppStringUtils.generateKey(extension.getElementName(), extension.getNamespace());
   synchronized (packetExtensions) {
     packetExtensions.put(key, extension);
   }
 }
Example #2
0
 /**
  * Returns the extension sub-packets (including properties data) as an XML String, or the Empty
  * String if there are no stanza(/packet) extensions.
  *
  * @return the extension sub-packets as XML or the Empty String if there are no stanza(/packet)
  *     extensions.
  */
 protected final XmlStringBuilder getExtensionsXML() {
   XmlStringBuilder xml = new XmlStringBuilder();
   // Add in all standard extension sub-packets.
   for (ExtensionElement extension : getExtensions()) {
     xml.append(extension.toXML());
   }
   return xml;
 }
Example #3
0
 /**
  * Check if a stanza(/packet) extension with the given namespace exists.
  *
  * @param namespace
  * @return true if a stanza(/packet) extension exists, false otherwise.
  */
 public boolean hasExtension(String namespace) {
   synchronized (packetExtensions) {
     for (ExtensionElement packetExtension : packetExtensions.values()) {
       if (packetExtension.getNamespace().equals(namespace)) {
         return true;
       }
     }
   }
   return false;
 }
Example #4
0
 /**
  * Removes a stanza(/packet) extension from the packet.
  *
  * @param extension the stanza(/packet) extension to remove.
  * @return the removed stanza(/packet) extension or null.
  */
 public ExtensionElement removeExtension(ExtensionElement extension) {
   return removeExtension(extension.getElementName(), extension.getNamespace());
 }