com.sun.im.service
Class Poll

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

public class Poll
extends java.lang.Object
implements Delegation

Helper class for application using the poll functionality. This class can be used to parse the xml from the poll message and generate a poll response based on user input.


Field Summary
static java.lang.String ATTRIBUTE_ACCESS
           
static java.lang.String ATTRIBUTE_CUSTOM
           
static java.lang.String ATTRIBUTE_ID
           
static java.lang.String ATTRIBUTE_LABEL
           
static java.lang.String ATTRIBUTE_POLLTYPE
           
static java.lang.String ATTRIBUTE_QUESTION
           
static java.lang.String ATTRIBUTE_VAR
           
static java.lang.String ELEMENT_FIELD
           
static java.lang.String ELEMENT_OPTION
           
static java.lang.String ELEMENT_VALUE
           
static java.lang.String POLLACCESS_NONE
           
static java.lang.String POLLACCESS_PARTICIPANTS
           
static java.lang.String POLLACCESS_PRIVATE
           
static java.lang.String POLLACCESS_PUBLIC
           
static java.lang.String POLLTYPE_ANONYMOUS
           
static java.lang.String POLLTYPE_OPEN
           
 
Constructor Summary
Poll(java.io.InputStream in)
          Constructor used by poll message receiver
Poll(org.netbeans.lib.collab.Poll p)
           
Poll(java.lang.String message)
          Constructor used by poll message receiver
Poll(java.lang.String question, java.util.List answers, boolean custom)
          Constructor used by poll sender
Poll(java.lang.String pollID, java.lang.String question, java.util.List answers, boolean custom, java.lang.String pollType, java.lang.String access)
          Constructor used by polster
 
Method Summary
 int countAnswers()
           
 java.lang.String createResponse(int index)
           
 java.lang.String createResponse(java.lang.String answer)
          returns a serialized pollr element based on the specified custom answer.
 java.lang.String createResponse(java.lang.String pollID, java.lang.String answer)
           
 java.io.InputStream createResponseStream(java.lang.String answer)
           
 org.jabberstudio.jso.x.xdata.XDataForm createXDataResponse(java.lang.String answer)
           
 java.lang.String getAccess()
           
 java.lang.String getAnswer(int index)
           
 int getCount(java.lang.String answerID)
           
 java.lang.Object getDelegatedObject()
          This method returns the delegated object
 java.lang.String getPollID()
           
 java.lang.String getQuestion()
           
 org.jabberstudio.jso.x.xdata.XDataForm getXDataForm()
           
 boolean isAnonynous()
           
 boolean isCustomAnswerAllowed()
           
static void main(java.lang.String[] arg)
           
 java.lang.String parseAnswer(java.io.InputStream in)
          parse an answer received for this poll
 java.lang.String parseAnswer(java.lang.String str)
          parse an answer received for this poll
 java.lang.String toString()
          get the XML representation of this Poll The return string can be used to generate the contents of a poll message
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ELEMENT_FIELD

public static final java.lang.String ELEMENT_FIELD
See Also:
Constant Field Values

ELEMENT_VALUE

public static final java.lang.String ELEMENT_VALUE
See Also:
Constant Field Values

ELEMENT_OPTION

public static final java.lang.String ELEMENT_OPTION
See Also:
Constant Field Values

ATTRIBUTE_VAR

public static final java.lang.String ATTRIBUTE_VAR
See Also:
Constant Field Values

ATTRIBUTE_LABEL

public static final java.lang.String ATTRIBUTE_LABEL
See Also:
Constant Field Values

ATTRIBUTE_ID

public static final java.lang.String ATTRIBUTE_ID
See Also:
Constant Field Values

ATTRIBUTE_QUESTION

public static final java.lang.String ATTRIBUTE_QUESTION
See Also:
Constant Field Values

ATTRIBUTE_POLLTYPE

public static final java.lang.String ATTRIBUTE_POLLTYPE
See Also:
Constant Field Values

ATTRIBUTE_ACCESS

public static final java.lang.String ATTRIBUTE_ACCESS
See Also:
Constant Field Values

ATTRIBUTE_CUSTOM

public static final java.lang.String ATTRIBUTE_CUSTOM
See Also:
Constant Field Values

POLLTYPE_ANONYMOUS

public static final java.lang.String POLLTYPE_ANONYMOUS
See Also:
Constant Field Values

POLLTYPE_OPEN

public static final java.lang.String POLLTYPE_OPEN
See Also:
Constant Field Values

POLLACCESS_PRIVATE

public static final java.lang.String POLLACCESS_PRIVATE
See Also:
Constant Field Values

POLLACCESS_PARTICIPANTS

public static final java.lang.String POLLACCESS_PARTICIPANTS
See Also:
Constant Field Values

POLLACCESS_PUBLIC

public static final java.lang.String POLLACCESS_PUBLIC
See Also:
Constant Field Values

POLLACCESS_NONE

public static final java.lang.String POLLACCESS_NONE
See Also:
Constant Field Values
Constructor Detail

Poll

public Poll(java.io.InputStream in)
     throws java.lang.Exception
Constructor used by poll message receiver

Parameters:
in - xml content's input stream. The stream must be UTF-8 encoded.

Poll

public Poll(java.lang.String message)
     throws java.lang.Exception
Constructor used by poll message receiver

Parameters:
message - content of the application/x-iim-poll message

Poll

public Poll(java.lang.String question,
            java.util.List answers,
            boolean custom)
Constructor used by poll sender

Parameters:
question - the question
answers - valid answers
custom - whether custom answers are allowed

Poll

public Poll(java.lang.String pollID,
            java.lang.String question,
            java.util.List answers,
            boolean custom,
            java.lang.String pollType,
            java.lang.String access)
Constructor used by polster

Parameters:
pollID - unique poll identifier
question - the question
answers - valid answers
custom - whether custom answers are allowed
pollType - anonymous vs. open
access - access list or type (private, public, participants).

Poll

public Poll(org.netbeans.lib.collab.Poll p)
Method Detail

getPollID

public java.lang.String getPollID()

getQuestion

public java.lang.String getQuestion()

countAnswers

public int countAnswers()

getAnswer

public java.lang.String getAnswer(int index)
                           throws java.lang.IndexOutOfBoundsException
Throws:
java.lang.IndexOutOfBoundsException

createResponse

public java.lang.String createResponse(int index)
                                throws CollaborationException
Throws:
CollaborationException

createXDataResponse

public org.jabberstudio.jso.x.xdata.XDataForm createXDataResponse(java.lang.String answer)
                                                           throws CollaborationException
Throws:
CollaborationException

createResponse

public java.lang.String createResponse(java.lang.String answer)
                                throws CollaborationException
returns a serialized pollr element based on the specified custom answer. The returned string is suitable for use in a poll response message.

Throws:
CollaborationException

createResponseStream

public java.io.InputStream createResponseStream(java.lang.String answer)
                                         throws CollaborationException
Throws:
CollaborationException

isCustomAnswerAllowed

public boolean isCustomAnswerAllowed()

isAnonynous

public boolean isAnonynous()

getAccess

public java.lang.String getAccess()

createResponse

public java.lang.String createResponse(java.lang.String pollID,
                                       java.lang.String answer)
                                throws CollaborationException
Throws:
CollaborationException

parseAnswer

public java.lang.String parseAnswer(java.io.InputStream in)
                             throws java.lang.Exception
parse an answer received for this poll

Parameters:
in - UTF-8 encoded input stream to the content of the application/x-iim-poll-reply message or message part
Throws:
java.lang.Exception

parseAnswer

public java.lang.String parseAnswer(java.lang.String str)
                             throws java.lang.Exception
parse an answer received for this poll

Parameters:
str - content of the application/x-iim-poll-reply message or message part
Throws:
java.lang.Exception

getCount

public int getCount(java.lang.String answerID)

getXDataForm

public org.jabberstudio.jso.x.xdata.XDataForm getXDataForm()

toString

public java.lang.String toString()
get the XML representation of this Poll The return string can be used to generate the contents of a poll message

Returns:
poll message content String

main

public static void main(java.lang.String[] arg)

getDelegatedObject

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

Specified by:
getDelegatedObject in interface Delegation