com.sun.im.service
Class Presence

java.lang.Object
  extended bycom.sun.im.service.Presence
All Implemented Interfaces:
java.io.Serializable

public class Presence
extends java.lang.Object
implements java.io.Serializable

Version:
See Also:
Serialized Form

Field Summary
 java.lang.String url
          presentity id / url
 
Constructor Summary
Presence(PresenceTuple tuple)
           
Presence(java.lang.String id)
           
 
Method Summary
protected  void addCustomElement(org.w3c.dom.Element element)
          add a custom element as a Node.
protected  java.lang.String addNamespace(java.lang.String prefix, java.lang.String nsURI)
          add a namespace declaration to be used in elements of the presence document.
 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 addSerializedCustomElement(java.lang.String sElement, java.lang.String namespaceURI, boolean validateXML)
          add a serialized custom element as a Node.
 void addTuple(PresenceTuple t)
          Add a tuple to this presentity If a tuple with the same tuple id already exists in this presentity, the existing tuple is removed and replaces with the one specified here.
 void addTuple(PresenceTuple[] t)
           
protected  void copyTo(java.lang.StringBuffer buf)
           
 java.util.List getCustomElements(java.lang.String namespace)
          returns a list of Element objects belonging to a specific XML namespace.
 java.lang.String getNamespaces()
          returns string containing all necessary namespace declarations for this presentity.
protected  java.lang.String getNamespaceURI(java.lang.String s)
           
 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.lang.String getSerializedCustomElements()
          return a concatenation of all custom elements.
 java.lang.String getSerializedCustomElements(java.lang.String namespace)
          return a serialized XML fragment which is a concatenation of all sub-elements belonging to the specified namespace.
 java.util.Collection getTuples()
          do not modify result
protected  boolean hasNamespaceURI(java.lang.String prefix)
           
 void removeTuple(PresenceTuple t)
           
 void setNamespaces(java.lang.String namespaceList)
          set the namespace list for this presentity.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

url

public java.lang.String url
presentity id / url

Constructor Detail

Presence

public Presence(java.lang.String id)

Presence

public Presence(PresenceTuple tuple)
Method Detail

getTuples

public java.util.Collection getTuples()
do not modify result


addTuple

public void addTuple(PresenceTuple t)
Add a tuple to this presentity If a tuple with the same tuple id already exists in this presentity, the existing tuple is removed and replaces with the one specified here. If custom XML namespaces have been declared in the tuple, they are automatically taken into account when building the serialized presence document.

Parameters:
t - tuple to add

removeTuple

public void removeTuple(PresenceTuple t)

addTuple

public void addTuple(PresenceTuple[] t)

toString

public java.lang.String toString()

copyTo

protected void copyTo(java.lang.StringBuffer buf)
               throws java.lang.Exception
Throws:
java.lang.Exception

addNamespace

protected java.lang.String addNamespace(java.lang.String prefix,
                                        java.lang.String nsURI)
add a namespace declaration to be used in elements of the presence document.

Returns:
prefix to use in the XML in case a conflict was detected. null if no prefix conlict was found.

hasNamespaceURI

protected boolean hasNamespaceURI(java.lang.String prefix)

getNamespaceURI

protected java.lang.String getNamespaceURI(java.lang.String s)

setNamespaces

public void setNamespaces(java.lang.String namespaceList)
set the namespace list for this presentity. This method is used by the presence store to generate Presence object based on information stored in the database.

Parameters:
namespaceList - String containing all necessary XML namespace declarations separated by whitespaces.

getNamespaces

public java.lang.String getNamespaces()
returns string containing all necessary namespace declarations for this presentity. The resulting String is ready to be included in a serialized presence element. This method is used by the presence store to generate a String that can be stored in the database. Example:


addCustomElement

protected void addCustomElement(org.w3c.dom.Element element)
                         throws com.sun.im.service.util.XMLProcessingException
add a custom element as a Node. This is used by PresenceHelper to populate the Presence data object during parsing.

Parameters:
element - custom tuple sub-element to add
Throws:
com.sun.im.service.util.XMLProcessingException

addSerializedCustomElement

public void addSerializedCustomElement(java.lang.String sElement,
                                       java.lang.String namespaceURI,
                                       boolean validateXML)
                                throws com.sun.im.service.util.XMLProcessingException
add a serialized custom element as a Node. This is used by application to add custom presence sub-elements while buiding a presence document. Note: elements added using this method may not be retrieved immediately using getCustomElement. To do this the presence document needs to be built and then parsed.

Parameters:
sElement - custom tuple sub-element to add in serialized form.
Throws:
com.sun.im.service.util.XMLProcessingException - ill-formed XML or missing or unrecognized namespace prefix

getSerializedCustomElements

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

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

getCustomElements

public java.util.List getCustomElements(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 extentions.

Parameters:
namespace - namespace URI or prefix.
Returns:
list of org.w3c.dom.Element objects.

getSerializedCustomElements

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

Parameters:
namespace - XML namespace URI or prefix
Throws:
com.sun.im.service.util.XMLProcessingException

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

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