Class XHTMLExtension

  • All Implemented Interfaces:
    org.jivesoftware.smack.packet.Element, org.jivesoftware.smack.packet.ExtensionElement, org.jivesoftware.smack.packet.NamedElement, org.jivesoftware.smack.packet.XmlElement, org.jivesoftware.smack.packet.XmlLangElement

    public final class XHTMLExtension
    extends java.lang.Object
    implements org.jivesoftware.smack.packet.ExtensionElement
    An XHTML sub-packet, which is used by XMPP clients to exchange formatted text. The XHTML extension is only a subset of XHTML 1.0.

    The following link summarizes the requirements of XHTML IM: XEP-0071: XHTML-IM.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ELEMENT  
      static java.lang.String NAMESPACE  
      static javax.xml.namespace.QName QNAME  
    • Constructor Summary

      Constructors 
      Constructor Description
      XHTMLExtension()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addBody​(java.lang.CharSequence body)
      Adds a body to the packet.
      static XHTMLExtension from​(org.jivesoftware.smack.packet.MessageView message)  
      java.util.List<java.lang.CharSequence> getBodies()
      Returns a List of the bodies in the packet.
      int getBodiesCount()
      Returns a count of the bodies in the XHTML packet.
      java.lang.String getElementName()
      Returns the XML element name of the extension sub-packet root element.
      java.lang.String getNamespace()
      Returns the XML namespace of the extension sub-packet root element.
      org.jivesoftware.smack.util.XmlStringBuilder toXML​(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace)
      Returns the XML representation of a XHTML extension according the specification.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.jivesoftware.smack.packet.Element

        toXML, toXML
      • Methods inherited from interface org.jivesoftware.smack.packet.XmlElement

        getLanguage, getQName
    • Field Detail

      • QNAME

        public static final javax.xml.namespace.QName QNAME
    • Constructor Detail

      • XHTMLExtension

        public XHTMLExtension()
    • Method Detail

      • getElementName

        public java.lang.String getElementName()
        Returns the XML element name of the extension sub-packet root element. Always returns "html"
        Specified by:
        getElementName in interface org.jivesoftware.smack.packet.NamedElement
        Returns:
        the XML element name of the stanza extension.
      • getNamespace

        public java.lang.String getNamespace()
        Returns the XML namespace of the extension sub-packet root element. According the specification the namespace is always "http://jabber.org/protocol/xhtml-im"
        Specified by:
        getNamespace in interface org.jivesoftware.smack.packet.XmlElement
        Returns:
        the XML namespace of the stanza extension.
      • toXML

        public org.jivesoftware.smack.util.XmlStringBuilder toXML​(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace)
        Returns the XML representation of a XHTML extension according the specification. Usually the XML representation will be inside of a Message XML representation like in the following example:
         <message id="MlIpV-4" to="[email protected]" from="[email protected]/Smack">
             <subject>Any subject you want</subject>
             <body>This message contains something interesting.</body>
             <html xmlns="http://jabber.org/protocol/xhtml-im">
                 <body><p style='font-size:large'>This message contains something <em>interesting</em>.</p></body>
             </html>
         </message>
         
        Specified by:
        toXML in interface org.jivesoftware.smack.packet.Element
      • getBodies

        public java.util.List<java.lang.CharSequence> getBodies()
        Returns a List of the bodies in the packet.
        Returns:
        a List of the bodies in the packet.
      • addBody

        public void addBody​(java.lang.CharSequence body)
        Adds a body to the packet.
        Parameters:
        body - the body to add.
      • getBodiesCount

        public int getBodiesCount()
        Returns a count of the bodies in the XHTML packet.
        Returns:
        the number of bodies in the XHTML packet.
      • from

        public static XHTMLExtension from​(org.jivesoftware.smack.packet.MessageView message)