Smack

org.jivesoftware.smackx.pubsub
Class LeafNode

java.lang.Object
  extended by org.jivesoftware.smackx.pubsub.Node
      extended by org.jivesoftware.smackx.pubsub.LeafNode

public class LeafNode
extends Node

The main class for the majority of pubsub functionality. In general almost all pubsub capabilities are related to the concept of a node. All items are published to a node, and typically subscribed to by other users. These users then retrieve events based on this subscription.

Author:
Robin Collier

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jivesoftware.smackx.pubsub.Node
Node.ItemDeleteTranslator, Node.ItemEventTranslator, Node.NodeConfigTranslator
 
Field Summary
 
Fields inherited from class org.jivesoftware.smackx.pubsub.Node
con, configEventToListenerMap, id, itemDeleteToListenerMap, itemEventToListenerMap, to
 
Method Summary
 void deleteAllItems()
          Purges the node of all items.
 void deleteItem(Collection<String> itemIds)
          Delete the items with the specified id's from the node.
 void deleteItem(String itemId)
          Delete the item with the specified id from the node.
 DiscoverItems discoverItems()
          Get information on the items in the node in standard DiscoverItems format.
<T extends Item>
List<T>
getItems()
          Get the current items stored in the node.
<T extends Item>
List<T>
getItems(Collection<String> ids)
          Get the items specified from the node.
<T extends Item>
List<T>
getItems(int maxItems)
          Get items persisted on the node, limited to the specified number.
<T extends Item>
List<T>
getItems(int maxItems, String subscriptionId)
          Get items persisted on the node, limited to the specified number based on the subscription associated with the provided subscriptionId.
<T extends Item>
List<T>
getItems(String subscriptionId)
          Get the current items stored in the node based on the subscription associated with the provided subscription id.
 void publish()
          Publishes an event to the node.
<T extends Item>
void
publish(Collection<T> items)
          Publishes multiple events to the node.
<T extends Item>
void
publish(T item)
          Publishes an event to the node.
 void send()
          Publishes an event to the node.
<T extends Item>
void
send(Collection<T> items)
          Publishes multiple events to the node.
<T extends Item>
void
send(T item)
          Publishes an event to the node.
 
Methods inherited from class org.jivesoftware.smackx.pubsub.Node
addConfigurationListener, addItemDeleteListener, addItemEventListener, createPubsubPacket, createPubsubPacket, discoverInfo, getId, getNodeConfiguration, getSubscriptionOptions, getSubscriptionOptions, getSubscriptions, removeConfigurationListener, removeItemDeleteListener, removeItemEventListener, sendConfigurationForm, sendPubsubPacket, sendPubsubPacket, subscribe, subscribe, toString, unsubscribe, unsubscribe
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

discoverItems

public DiscoverItems discoverItems()
                            throws XMPPException
Get information on the items in the node in standard DiscoverItems format.

Returns:
The item details in DiscoverItems format
Throws:
XMPPException

getItems

public <T extends Item> List<T> getItems()
                              throws XMPPException
Get the current items stored in the node.

Returns:
List of Item in the node
Throws:
XMPPException

getItems

public <T extends Item> List<T> getItems(String subscriptionId)
                              throws XMPPException
Get the current items stored in the node based on the subscription associated with the provided subscription id.

Parameters:
subscriptionId - - The subscription id for the associated subscription.
Returns:
List of Item in the node
Throws:
XMPPException

getItems

public <T extends Item> List<T> getItems(Collection<String> ids)
                              throws XMPPException
Get the items specified from the node. This would typically be used when the server does not return the payload due to size constraints. The user would be required to retrieve the payload after the items have been retrieved via getItems() or an event, that did not include the payload.

Parameters:
ids - Item ids of the items to retrieve
Returns:
The list of Item with payload
Throws:
XMPPException

getItems

public <T extends Item> List<T> getItems(int maxItems)
                              throws XMPPException
Get items persisted on the node, limited to the specified number.

Parameters:
maxItems - Maximum number of items to return
Returns:
List of Item
Throws:
XMPPException

getItems

public <T extends Item> List<T> getItems(int maxItems,
                                         String subscriptionId)
                              throws XMPPException
Get items persisted on the node, limited to the specified number based on the subscription associated with the provided subscriptionId.

Parameters:
maxItems - Maximum number of items to return
subscriptionId - The subscription which the retrieval is based on.
Returns:
List of Item
Throws:
XMPPException

publish

public void publish()
Publishes an event to the node. This is an empty event with no item. This is only acceptable for nodes with ConfigureForm.isPersistItems()=false and ConfigureForm.isDeliverPayloads()=false. This is an asynchronous call which returns as soon as the packet has been sent. For synchronous calls use send().


publish

public <T extends Item> void publish(T item)
Publishes an event to the node. This is a simple item with no payload. If the id is null, an empty item (one without an id) will be sent. Please note that this is not the same as send(), which publishes an event with NO item. This is an asynchronous call which returns as soon as the packet has been sent. For synchronous calls use send(Item)).

Parameters:
item - - The item being sent

publish

public <T extends Item> void publish(Collection<T> items)
Publishes multiple events to the node. Same rules apply as in publish(Item). In addition, if ConfigureForm.isPersistItems()=false, only the last item in the input list will get stored on the node, assuming it stores the last sent item. This is an asynchronous call which returns as soon as the packet has been sent. For synchronous calls use send(Collection)).

Parameters:
items - - The collection of items being sent

send

public void send()
          throws XMPPException
Publishes an event to the node. This is an empty event with no item. This is only acceptable for nodes with ConfigureForm.isPersistItems()=false and ConfigureForm.isDeliverPayloads()=false. This is a synchronous call which will throw an exception on failure. For asynchronous calls, use publish().

Throws:
XMPPException

send

public <T extends Item> void send(T item)
          throws XMPPException
Publishes an event to the node. This can be either a simple item with no payload, or one with it. This is determined by the Node configuration. If the node has deliver_payload=false, the Item must not have a payload. If the id is null, an empty item (one without an id) will be sent. Please note that this is not the same as send(), which publishes an event with NO item. This is a synchronous call which will throw an exception on failure. For asynchronous calls, use publish(Item).

Parameters:
item - - The item being sent
Throws:
XMPPException

send

public <T extends Item> void send(Collection<T> items)
          throws XMPPException
Publishes multiple events to the node. Same rules apply as in send(Item). In addition, if ConfigureForm.isPersistItems()=false, only the last item in the input list will get stored on the node, assuming it stores the last sent item. This is a synchronous call which will throw an exception on failure. For asynchronous calls, use publish(Collection)).

Parameters:
items - - The collection of Item objects being sent
Throws:
XMPPException

deleteAllItems

public void deleteAllItems()
                    throws XMPPException
Purges the node of all items.

Note: Some implementations may keep the last item sent.

Throws:
XMPPException

deleteItem

public void deleteItem(String itemId)
                throws XMPPException
Delete the item with the specified id from the node.

Parameters:
itemId - The id of the item
Throws:
XMPPException

deleteItem

public void deleteItem(Collection<String> itemIds)
                throws XMPPException
Delete the items with the specified id's from the node.

Parameters:
itemIds - The list of id's of items to delete
Throws:
XMPPException

Smack

Copyright © 2003-2007 Jive Software.