Class Item
- All Implemented Interfaces:
Element
,NamedElement
,XmlElement
,XmlLangElement
- Direct Known Subclasses:
PayloadItem
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)
- Will always have an id (either user or server generated) unless node configuration has both
ConfigureFormReader.isPersistItems()
andConfigureFormReader.isDeliverPayloads()
set to false. - Will have a payload if the node configuration has
ConfigureFormReader.isDeliverPayloads()
set to true, otherwise it will be null.
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
.
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionItem()
Create an emptyItem
with no id.Create anItem
with an id but no payload.Create anItem
with an id and a node id.Item
(Item.ItemNamespace itemNamespace, String itemId) Create anItem
with an id but no payload.Item
(Item.ItemNamespace itemNamespace, String itemId, String nodeId) Create anItem
with an id and a node id. -
Method Summary
Methods inherited from class org.jivesoftware.smackx.pubsub.NodeExtension
getElementName, getNamespace, getNode, getPubSubNamespace, toXML
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.XmlElement
getLanguage, getQName
-
Constructor Details
-
Item
public Item()Create an emptyItem
with no id. This is a valid item for nodes which are configured so thatConfigureFormReader.isDeliverPayloads()
is false. In most cases an id will be generated by the server. For nodes configured withConfigureFormReader.isDeliverPayloads()
andConfigureFormReader.isPersistItems()
set to false, noItem
is sent to the node, you have to use theLeafNode.publish()
method in this case. -
Item
Create anItem
with an id but no payload. This is a valid item for nodes which are configured so thatConfigureFormReader.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 callingItem()
.
-
Item
Create anItem
with an id but no payload. This is a valid item for nodes which are configured so thatConfigureFormReader.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 callingItem()
.
-
Item
Create anItem
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 (viaLeafNode.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
Create anItem
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 (viaLeafNode.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
-
getId
Get the item id. Unique to the node it is associated with.- Returns:
- The id
-
addXml
- Overrides:
addXml
in classNodeExtension
-
toString
- Overrides:
toString
in classNodeExtension
-