com.sun.im.service
Class PresenceTuple

java.lang.Object
  extended bycom.sun.im.service.PresenceTuple
All Implemented Interfaces:
Delegation

public class PresenceTuple
extends java.lang.Object
implements Delegation


Constructor Summary
PresenceTuple()
          constructor without specified priority or id should be used when the presence is defined in XMPP format
PresenceTuple(org.netbeans.lib.collab.PresenceTuple pt)
           
PresenceTuple(java.lang.String id)
          constructor without specified priority (no priority attribute is added in pidf:tuple)
PresenceTuple(java.lang.String id, java.lang.String contact, java.lang.String status)
          constructor without specified priority (no priority attribute is added in pidf:tuple)
PresenceTuple(java.lang.String id, java.lang.String contact, java.lang.String status, float priority)
          constructor with specified priority
 
Method Summary
 void addNote(java.lang.String text)
          add a note in the default language.
 void addNote(java.lang.String lang, java.lang.String text)
          set the note for a specified language
 void addSerializedCustomStatusElement(java.lang.String sElement, java.lang.String namespaceURI, boolean validateXML)
          Add a serialized custom status element as a Node.
 void addSerializedCustomTupleElement(java.lang.String sElement, java.lang.String namespaceURI, boolean validateXML)
          Add a serialized custom tuple element as a Node.
 boolean equals(java.lang.Object o)
           
 java.lang.String getBasicStatus()
           
 java.lang.String getContact()
           
 java.util.List getCustomStatusElements(java.lang.String namespace)
          returns a list of Element objects belonging to a specific XML namespace.
 java.util.List getCustomTupleElements(java.lang.String namespace)
          returns a list of Element objects belonging to a specific XML namespace.
 java.lang.Object getDelegatedObject()
          This method returns the delegated object
 java.lang.String getId()
           
 java.lang.String getLastUpdateTimeStamp()
          Get the last-update timestamp in XML dateTime format
 java.lang.String getNote()
          get the note for the default language.
 java.lang.String getNote(java.lang.String lang)
          get the note corresponding to a specified language
 java.util.Map getNotes()
          get all the notes in all the language.
 java.lang.String getPresenceURL()
           
 float getPriority()
           
 java.lang.String getSerializedCustomStatusElements()
          return a concatenation of all custom status elements.
 java.lang.String getSerializedCustomStatusElements(java.lang.String namespace)
          return a serialized XML fragment which is a concatenation of all tuple sub-elements belonging to the specified namespace.
 java.lang.String getSerializedCustomTupleElements()
          return a concatenation of all custom tuple elements.
 java.lang.String getSerializedCustomTupleElements(java.lang.String namespace)
          return a serialized XML fragment which is a concatenation of all tuple sub-elements belonging to the specified namespace.
 java.lang.String getStatus()
           
 void setContact(java.lang.String contact)
          set communication address
 void setContact(java.lang.String contact, float priority)
          set communication address
 void setLastUpdateTimeStamp(java.lang.String ts)
          Set the last-update timestamp in XML dateTime format
 void setPriority(float priority)
           
 void setStatus(java.lang.String status)
          set ICP and PIDF presence status
 java.lang.String toString()
          returns an serialized XML fragment for this tuple
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PresenceTuple

public PresenceTuple(java.lang.String id)
constructor without specified priority (no priority attribute is added in pidf:tuple)

Parameters:
id - tuple id. A tuple id must be unique within a presentity. This argument is used to generate the id attribute of the PIDF tuple element.

PresenceTuple

public PresenceTuple()
constructor without specified priority or id should be used when the presence is defined in XMPP format


PresenceTuple

public PresenceTuple(org.netbeans.lib.collab.PresenceTuple pt)

PresenceTuple

public PresenceTuple(java.lang.String id,
                     java.lang.String contact,
                     java.lang.String status)
              throws java.lang.IllegalArgumentException
constructor without specified priority (no priority attribute is added in pidf:tuple)

Parameters:
id - tuple id. A tuple id must be unique within a presentity. This argument is used to generate the id attribute of the PIDF tuple element.
contact - contact address associated with this tuple. This argument is used as the text inside the PIDF contact element.
status - status string. Must be one of the status values defined in com.sun.im.service.PresenceService. This value is used to create the contents of the PIDF basic element and the ICP xstatus element.
Throws:
java.lang.IllegalArgumentException - unknown status value or invalid address format
See Also:
PresenceService

PresenceTuple

public PresenceTuple(java.lang.String id,
                     java.lang.String contact,
                     java.lang.String status,
                     float priority)
              throws java.lang.IllegalArgumentException
constructor with specified priority

Parameters:
id - tuple id. A tuple id must be unique within a presentity. This argument is used to generate the id attribute of the PIDF tuple element.
contact - contact address associated with this tuple. This argument is used as the text inside the PIDF contact element.
status - status string. Must be one of the status values defined in com.sun.im.service.PresenceService. This value is used to create the contents of the PIDF basic element and the ICP xstatus element.
priority - priority to use as value the PIDF priority attribute (part of tuple element).
Throws:
java.lang.IllegalArgumentException - priority not within the 0-1 range, or unknown status value or invalid address format
Method Detail

getNote

public java.lang.String getNote(java.lang.String lang)
get the note corresponding to a specified language

Parameters:
lang - language tag
Returns:
note

getNote

public java.lang.String getNote()
get the note for the default language. if there is no note for the default language and there is only one note, this unique note is returned.

Returns:
note

getNotes

public java.util.Map getNotes()
get all the notes in all the language.

Returns:
notes

addNote

public void addNote(java.lang.String lang,
                    java.lang.String text)
set the note for a specified language

Parameters:
lang - language tag
text - note content

addNote

public void addNote(java.lang.String text)
add a note in the default language. This overrides any existing note added for the default language

Returns:
note

getLastUpdateTimeStamp

public java.lang.String getLastUpdateTimeStamp()
Get the last-update timestamp in XML dateTime format

Returns:
last-update timestamp if any has been provided, null otherwise

setLastUpdateTimeStamp

public void setLastUpdateTimeStamp(java.lang.String ts)
Set the last-update timestamp in XML dateTime format


getId

public java.lang.String getId()
Returns:
Tuple ID

getPresenceURL

public java.lang.String getPresenceURL()
Returns:
containing presentity ID

getPriority

public float getPriority()
Returns:
priority

getContact

public java.lang.String getContact()
Returns:
communication address

getStatus

public java.lang.String getStatus()
Returns:
presence status
See Also:
PresenceService

getBasicStatus

public java.lang.String getBasicStatus()
Returns:
basic status (OPEN or CLOSED)

setPriority

public void setPriority(float priority)
                 throws java.lang.IllegalArgumentException
Parameters:
priority - priority to use as value the PIDF priority attribute (part of tuple element).
Returns:
priority
Throws:
java.lang.IllegalArgumentException - priority not within the 0-1 range

setContact

public void setContact(java.lang.String contact,
                       float priority)
                throws java.lang.IllegalArgumentException
set communication address

Parameters:
contact - contact address associated with this tuple. This argument is used as the text inside the PIDF contact element.
priority - priority to use as value the PIDF priority attribute (part of tuple element).
Throws:
java.lang.IllegalArgumentException - invalid address format

setContact

public void setContact(java.lang.String contact)
                throws java.lang.IllegalArgumentException
set communication address

Parameters:
contact - contact address associated with this tuple. This argument is used as the text inside the PIDF contact element.
Throws:
java.lang.IllegalArgumentException - invalid address format

setStatus

public void setStatus(java.lang.String status)
               throws java.lang.IllegalArgumentException
set ICP and PIDF presence status

Parameters:
status - status string. Must be one of the status values defined in com.sun.im.service.PresenceService. This value is used to create the contents of the PIDF basic element and the ICP xstatus element.
Throws:
java.lang.IllegalArgumentException - unknown status value
See Also:
PresenceService

toString

public java.lang.String toString()
returns an serialized XML fragment for this tuple


equals

public boolean equals(java.lang.Object o)

addSerializedCustomTupleElement

public void addSerializedCustomTupleElement(java.lang.String sElement,
                                            java.lang.String namespaceURI,
                                            boolean validateXML)
                                     throws com.sun.im.service.util.XMLProcessingException
Add a serialized custom tuple element as a Node. This is used by application to add custom tuple sub-elements while buiding a presence tuple. The input xml string must not contain the XML header.

Elements added using this method may not be retrieved immediately as a Node using getCustomTupleElement. To do this the presence document needs to be built and then parsed.

Parameters:
sElement - custom tuple sub-element to add in serialized form.
validateXML - verify that sElement contains well-formed XML.
namespaceURI - XML namespace URI corresponding to the prefix used in the XML fragment. Note that only one custom namespace may be used in the xml fragment.
Throws:
com.sun.im.service.util.XMLProcessingException - ill-formed XML or missing or unrecognized namespace prefix

getSerializedCustomTupleElements

public java.lang.String getSerializedCustomTupleElements()
                                                  throws com.sun.im.service.util.XMLProcessingException
return a concatenation of all custom tuple elements. This method is used by the presence store to obtain a serialized XML fragment containing all custom tuple elements of this tuple.

Throws:
com.sun.im.service.util.XMLProcessingException

getCustomTupleElements

public java.util.List getCustomTupleElements(java.lang.String namespace)
returns a list of Element objects belonging to a specific XML namespace. This allows applications to retrieve only elements they are interested in and ignore other custom tuple extentions.

Parameters:
namespace - namespace URI or prefix.

getSerializedCustomTupleElements

public java.lang.String getSerializedCustomTupleElements(java.lang.String namespace)
                                                  throws com.sun.im.service.util.XMLProcessingException
return a serialized XML fragment which is a concatenation of all tuple sub-elements belonging to the specified namespace. This allows applications to retrieve only elements they are interested in and ignore other custom extentions.

Throws:
com.sun.im.service.util.XMLProcessingException

addSerializedCustomStatusElement

public void addSerializedCustomStatusElement(java.lang.String sElement,
                                             java.lang.String namespaceURI,
                                             boolean validateXML)
                                      throws com.sun.im.service.util.XMLProcessingException
Add a serialized custom status element as a Node. This is used by application to add custom status sub-elements while buiding a presence tuple. The input xml string must not contain the XML header.

Elements added using this method may not be retrieved immediately as a Node using getCustomStatusElement. To do this the presence document needs to be built and then parsed.

Parameters:
sElement - custom status sub-element to add in serialized form.
validateXML - verify that sElement contains well-formed XML.
namespaceURI - XML namespace URI corresponding to the prefix used in the XML fragment. Note that only one custom namespace may be used in the xml fragment.
Throws:
com.sun.im.service.util.XMLProcessingException - ill-formed XML or missing or unrecognized namespace prefix

getSerializedCustomStatusElements

public java.lang.String getSerializedCustomStatusElements()
                                                   throws com.sun.im.service.util.XMLProcessingException
return a concatenation of all custom status elements. This method is used by the presence store to obtain a serialized XML fragment containing all custom status elements of this tuple.

Throws:
com.sun.im.service.util.XMLProcessingException

getCustomStatusElements

public java.util.List getCustomStatusElements(java.lang.String namespace)
returns a list of Element objects belonging to a specific XML namespace. This allows applications to retrieve only elements they are interested in and ignore other custom tuple extentions.

Parameters:
namespace - namespace URI or prefix.

getSerializedCustomStatusElements

public java.lang.String getSerializedCustomStatusElements(java.lang.String namespace)
                                                   throws com.sun.im.service.util.XMLProcessingException
return a serialized XML fragment which is a concatenation of all tuple sub-elements belonging to the specified namespace. This allows applications to retrieve only elements they are interested in and ignore other custom extentions.

Throws:
com.sun.im.service.util.XMLProcessingException

getDelegatedObject

public java.lang.Object getDelegatedObject()
Description copied from interface: Delegation
This method returns the delegated object

Specified by:
getDelegatedObject in interface Delegation