Class PayloadItem<E extends org.jivesoftware.smack.packet.ExtensionElement>

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

    public class PayloadItem<E extends org.jivesoftware.smack.packet.ExtensionElement>
    extends Item
    This class represents an item that has been, or will be published to a pubsub node. An Item has several properties that are dependent on the configuration of the node to which it has been or will be published.

    An Item received from a node (via LeafNode.getItems() or Node.addItemEventListener(org.jivesoftware.smackx.pubsub.listener.ItemEventListener)

    An Item created to send to a node (via LeafNode.publish()

    • The id is optional, since the server will generate one if necessary, but should be used if it is meaningful in the context of the node. This value must be unique within the node that it is sent to, since resending an item with the same id will overwrite the one that already exists if the items are persisted.
    • Will require payload if the node configuration has ConfigureFormReader.isDeliverPayloads() set to true.

    To customise the payload object being returned from the getPayload() method, you can add a custom parser as explained in ItemProvider.

    • Nested Class Summary

    • Constructor Summary

      Constructors 
      Constructor Description
      PayloadItem​(E payloadExt)
      Create an Item with no id and a payload The id will be set by the server.
      PayloadItem​(java.lang.String itemId, E payloadExt)
      Create an Item with an id and payload.
      PayloadItem​(java.lang.String itemId, java.lang.String nodeId, E payloadExt)
      Create an Item with an id, node id and payload.
      PayloadItem​(Item.ItemNamespace itemNamespace, java.lang.String itemId, java.lang.String nodeId, E payloadExt)
      Create an Item with an id, node id and payload.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addXml​(org.jivesoftware.smack.util.XmlStringBuilder xml)  
      E getPayload()
      Get the payload associated with this Item.
      java.lang.String toString()  
      • Methods inherited from class org.jivesoftware.smackx.pubsub.Item

        getId
      • Methods inherited from class java.lang.Object

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

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

        getLanguage, getQName
    • Constructor Detail

      • PayloadItem

        public PayloadItem​(E payloadExt)
        Create an Item with no id and a payload The id will be set by the server.
        Parameters:
        payloadExt - A ExtensionElement which represents the payload data.
      • PayloadItem

        public PayloadItem​(java.lang.String itemId,
                           E payloadExt)
        Create an Item with an id and payload.
        Parameters:
        itemId - The id of this item. It can be null if we want the server to set the id.
        payloadExt - A ExtensionElement which represents the payload data.
      • PayloadItem

        public PayloadItem​(java.lang.String itemId,
                           java.lang.String nodeId,
                           E payloadExt)
        Create an Item with an id, node id and payload.

        Note: This is not valid for publishing an item to a node, only receiving from one as part of Message. If used to create an Item to publish (via LeafNode.publish(Item), the server may return an error for an invalid packet.

        Parameters:
        itemId - The id of this item.
        nodeId - The id of the node the item was published to.
        payloadExt - A ExtensionElement which represents the payload data.
      • PayloadItem

        public PayloadItem​(Item.ItemNamespace itemNamespace,
                           java.lang.String itemId,
                           java.lang.String nodeId,
                           E payloadExt)
        Create an Item with an id, node id and payload.

        Note: This is not valid for publishing an item to a node, only receiving from one as part of Message. If used to create an Item to publish (via LeafNode.publish(Item), the server may return an error for an invalid packet.

        Parameters:
        itemNamespace - the namespace of the item.
        itemId - The id of this item.
        nodeId - The id of the node the item was published to.
        payloadExt - A ExtensionElement which represents the payload data.
    • Method Detail

      • getPayload

        public E getPayload()
        Get the payload associated with this Item. Customising the payload parsing from the server can be accomplished as described in ItemProvider.
        Returns:
        The payload as a ExtensionElement.
      • addXml

        protected void addXml​(org.jivesoftware.smack.util.XmlStringBuilder xml)
        Overrides:
        addXml in class Item
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class Item