Class Item

All Implemented Interfaces:
Element, NamedElement, XmlElement, XmlLangElement
Direct Known Subclasses:
PayloadItem

public class Item extends NodeExtension
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() or 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 PayloadItem.getPayload() method, you can add a custom parser as explained in ItemProvider.

  • Constructor Details

    • Item

      public Item()
      Create an empty Item with no id. This is a valid item for nodes which are configured so that ConfigureFormReader.isDeliverPayloads() is false. In most cases an id will be generated by the server. For nodes configured with ConfigureFormReader.isDeliverPayloads() and ConfigureFormReader.isPersistItems() set to false, no Item is sent to the node, you have to use the LeafNode.publish() method in this case.
    • Item

      public Item(String itemId)
      Create an Item with an id but no payload. This is a valid item for nodes which are configured so that ConfigureFormReader.isDeliverPayloads() is false.
      Parameters:
      itemId - The id if the item. It must be unique within the node unless overwriting and existing item. Passing null is the equivalent of calling Item().
    • Item

      public Item(Item.ItemNamespace itemNamespace, String itemId)
      Create an Item with an id but no payload. This is a valid item for nodes which are configured so that ConfigureFormReader.isDeliverPayloads() is false.
      Parameters:
      itemNamespace - the namespace of the item.
      itemId - The id if the item. It must be unique within the node unless overwriting and existing item. Passing null is the equivalent of calling Item().
    • Item

      public Item(String itemId, String nodeId)
      Create an Item with an id and a node id.

      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 the item.
      nodeId - The id of the node which the item was published to.
    • Item

      public Item(Item.ItemNamespace itemNamespace, String itemId, String nodeId)
      Create an Item with an id and a node id.

      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 the item.
      nodeId - The id of the node which the item was published to.
  • Method Details