Smack

org.jivesoftware.smackx.pubsub
Class Node

java.lang.Object
  extended by org.jivesoftware.smackx.pubsub.Node
Direct Known Subclasses:
CollectionNode, LeafNode

public abstract class Node
extends Object


Nested Class Summary
 class Node.ItemDeleteTranslator
          This class translates low level item deletion events into api level objects for user consumption.
 class Node.ItemEventTranslator
          This class translates low level item publication events into api level objects for user consumption.
 class Node.NodeConfigTranslator
          This class translates low level node configuration events into api level objects for user consumption.
 
Field Summary
protected  Connection con
           
protected  java.util.concurrent.ConcurrentHashMap<NodeConfigListener,PacketListener> configEventToListenerMap
           
protected  String id
           
protected  java.util.concurrent.ConcurrentHashMap<ItemDeleteListener,PacketListener> itemDeleteToListenerMap
           
protected  java.util.concurrent.ConcurrentHashMap<ItemEventListener,PacketListener> itemEventToListenerMap
           
protected  String to
           
 
Method Summary
 void addConfigurationListener(NodeConfigListener listener)
          Register a listener for configuration events.
 void addItemDeleteListener(ItemDeleteListener listener)
          Register an listener for item delete events.
 void addItemEventListener(ItemEventListener listener)
          Register a listener for item publication events.
protected  PubSub createPubsubPacket(IQ.Type type, PacketExtension ext)
           
protected  PubSub createPubsubPacket(IQ.Type type, PacketExtension ext, PubSubNamespace ns)
           
 DiscoverInfo discoverInfo()
          Discover node information in standard DiscoverInfo format.
 String getId()
          Get the NodeId
 ConfigureForm getNodeConfiguration()
          Returns a configuration form, from which you can create an answer form to be submitted via the sendConfigurationForm(Form).
 SubscribeForm getSubscriptionOptions(String jid)
          Returns a SubscribeForm for subscriptions, from which you can create an answer form to be submitted via the sendConfigurationForm(Form).
 SubscribeForm getSubscriptionOptions(String jid, String subscriptionId)
          Get the options for configuring the specified subscription.
 List<Subscription> getSubscriptions()
          Get the subscriptions currently associated with this node.
 void removeConfigurationListener(NodeConfigListener listener)
          Unregister a listener for configuration events.
 void removeItemDeleteListener(ItemDeleteListener listener)
          Unregister a listener for item delete events.
 void removeItemEventListener(ItemEventListener listener)
          Unregister a listener for publication events.
 void sendConfigurationForm(Form submitForm)
          Update the configuration with the contents of the new Form
protected  Packet sendPubsubPacket(IQ.Type type, NodeExtension ext)
           
protected  Packet sendPubsubPacket(IQ.Type type, NodeExtension ext, PubSubNamespace ns)
           
 Subscription subscribe(String jid)
          The user subscribes to the node using the supplied jid.
 Subscription subscribe(String jid, SubscribeForm subForm)
          The user subscribes to the node using the supplied jid and subscription options.
 String toString()
           
 void unsubscribe(String jid)
          Remove the subscription related to the specified JID.
 void unsubscribe(String jid, String subscriptionId)
          Remove the specific subscription related to the specified JID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

con

protected Connection con

id

protected String id

to

protected String to

itemEventToListenerMap

protected java.util.concurrent.ConcurrentHashMap<ItemEventListener,PacketListener> itemEventToListenerMap

itemDeleteToListenerMap

protected java.util.concurrent.ConcurrentHashMap<ItemDeleteListener,PacketListener> itemDeleteToListenerMap

configEventToListenerMap

protected java.util.concurrent.ConcurrentHashMap<NodeConfigListener,PacketListener> configEventToListenerMap
Method Detail

getId

public String getId()
Get the NodeId

Returns:
the node id

getNodeConfiguration

public ConfigureForm getNodeConfiguration()
                                   throws XMPPException
Returns a configuration form, from which you can create an answer form to be submitted via the sendConfigurationForm(Form).

Returns:
the configuration form
Throws:
XMPPException

sendConfigurationForm

public void sendConfigurationForm(Form submitForm)
                           throws XMPPException
Update the configuration with the contents of the new Form

Parameters:
submitForm -
Throws:
XMPPException

discoverInfo

public DiscoverInfo discoverInfo()
                          throws XMPPException
Discover node information in standard DiscoverInfo format.

Returns:
The discovery information about the node.
Throws:
XMPPException

getSubscriptions

public List<Subscription> getSubscriptions()
                                    throws XMPPException
Get the subscriptions currently associated with this node.

Returns:
List of Subscription
Throws:
XMPPException

subscribe

public Subscription subscribe(String jid)
                       throws XMPPException
The user subscribes to the node using the supplied jid. The bare jid portion of this one must match the jid for the connection. Please note that the Subscription.State should be checked on return since more actions may be required by the caller. Subscription.State.pending - The owner must approve the subscription request before messages will be received. Subscription.State.unconfigured - If the Subscription.isConfigRequired() is true, the caller must configure the subscription before messages will be received. If it is false the caller can configure it but is not required to do so.

Parameters:
jid - The jid to subscribe as.
Returns:
The subscription
Throws:
XMPPException

subscribe

public Subscription subscribe(String jid,
                              SubscribeForm subForm)
                       throws XMPPException
The user subscribes to the node using the supplied jid and subscription options. The bare jid portion of this one must match the jid for the connection. Please note that the Subscription.State should be checked on return since more actions may be required by the caller. Subscription.State.pending - The owner must approve the subscription request before messages will be received. Subscription.State.unconfigured - If the Subscription.isConfigRequired() is true, the caller must configure the subscription before messages will be received. If it is false the caller can configure it but is not required to do so.

Parameters:
jid - The jid to subscribe as.
Returns:
The subscription
Throws:
XMPPException

unsubscribe

public void unsubscribe(String jid)
                 throws XMPPException
Remove the subscription related to the specified JID. This will only work if there is only 1 subscription. If there are multiple subscriptions, use unsubscribe(String, String).

Parameters:
jid - The JID used to subscribe to the node
Throws:
XMPPException

unsubscribe

public void unsubscribe(String jid,
                        String subscriptionId)
                 throws XMPPException
Remove the specific subscription related to the specified JID.

Parameters:
jid - The JID used to subscribe to the node
subscriptionId - The id of the subscription being removed
Throws:
XMPPException

getSubscriptionOptions

public SubscribeForm getSubscriptionOptions(String jid)
                                     throws XMPPException
Returns a SubscribeForm for subscriptions, from which you can create an answer form to be submitted via the sendConfigurationForm(Form).

Returns:
A subscription options form
Throws:
XMPPException

getSubscriptionOptions

public SubscribeForm getSubscriptionOptions(String jid,
                                            String subscriptionId)
                                     throws XMPPException
Get the options for configuring the specified subscription.

Parameters:
jid - JID the subscription is registered under
subscriptionId - The subscription id
Returns:
The subscription option form
Throws:
XMPPException

addItemEventListener

public void addItemEventListener(ItemEventListener listener)
Register a listener for item publication events. This listener will get called whenever an item is published to this node.

Parameters:
listener - The handler for the event

removeItemEventListener

public void removeItemEventListener(ItemEventListener listener)
Unregister a listener for publication events.

Parameters:
listener - The handler to unregister

addConfigurationListener

public void addConfigurationListener(NodeConfigListener listener)
Register a listener for configuration events. This listener will get called whenever the node's configuration changes.

Parameters:
listener - The handler for the event

removeConfigurationListener

public void removeConfigurationListener(NodeConfigListener listener)
Unregister a listener for configuration events.

Parameters:
listener - The handler to unregister

addItemDeleteListener

public void addItemDeleteListener(ItemDeleteListener listener)
Register an listener for item delete events. This listener gets called whenever an item is deleted from the node.

Parameters:
listener - The handler for the event

removeItemDeleteListener

public void removeItemDeleteListener(ItemDeleteListener listener)
Unregister a listener for item delete events.

Parameters:
listener - The handler to unregister

toString

public String toString()
Overrides:
toString in class Object

createPubsubPacket

protected PubSub createPubsubPacket(IQ.Type type,
                                    PacketExtension ext)

createPubsubPacket

protected PubSub createPubsubPacket(IQ.Type type,
                                    PacketExtension ext,
                                    PubSubNamespace ns)

sendPubsubPacket

protected Packet sendPubsubPacket(IQ.Type type,
                                  NodeExtension ext)
                           throws XMPPException
Throws:
XMPPException

sendPubsubPacket

protected Packet sendPubsubPacket(IQ.Type type,
                                  NodeExtension ext,
                                  PubSubNamespace ns)
                           throws XMPPException
Throws:
XMPPException

Smack

Copyright © 2003-2007 Jive Software.