Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.forum.proxy
Class PollProxy

java.lang.Object
  extended by com.jivesoftware.forum.proxy.PollProxy
All Implemented Interfaces:
Poll

public class PollProxy
extends java.lang.Object
implements Poll

A protection proxy for Polls. A proxy has a set of permissions that are specified at creation time of the proxy. Subsequently, those permissions are use to restrict access to protected methods. If a user does not have the right to execute a particular method, an UnauthorizedException is thrown.

See Also:
Poll, Permissions, UnauthorizedException

Field Summary
 
Fields inherited from interface com.jivesoftware.base.Poll
ALLOW_ANONYMOUS_VOTE_MODIFICATION, ALLOW_USER_VOTE_MODIFICATION, MULTIPLE_SELECTIONS_ALLOWED
 
Constructor Summary
PollProxy(Poll poll, Permissions permissions)
          Creates a new PollProxy object.
 
Method Summary
 void addAnonymousVote(int optionIndex, java.lang.String uniqueID)
          Add a guest vote for an option in the poll.
 void addOption(java.lang.String value)
          Add a new option to the poll.
 void addUserVote(int optionIndex, User user)
          Add a user vote for an option in the poll.
 void changeAnonymousVote(int prevOptionIndex, int newOptionIndex, java.lang.String uniqueID)
          Change a guest vote.
 void changeUserVote(int prevOptionIndex, int newOptionIndex, User user)
          Change a user vote.
 void deleteOption(int index)
          Remove an option from the poll.
 int getAnonymousVoteCount()
          Returns a count of all guests user votes for all options in the poll.
 int getAnonymousVoteCount(int index)
          Returns a count of all user votes for the specified option in the poll.
 java.util.Iterator getAnonymousVotes()
          Returns an Iterator of uniqueID's for guests who have voted for the option at the given index.
 java.util.Iterator getAnonymousVotes(int optionIndex)
          Returns an Iterator of uniqueID's for guests who have voted for the option at the given index.
 java.util.List getAnonymousVotes(java.lang.String uniqueID)
          Returns a list of option indexes corresponding to the anonymous votes, or an empty array if the user has not voted.
 java.util.Date getCreationDate()
          Returns the date the poll was created.
 java.lang.String getDescription()
          Returns a brief description of the poll.
 java.util.Date getEndDate()
          Returns the date voting for the poll should end.
 java.util.Date getExpirationDate()
          Returns the date the poll should expire.
 long getID()
          Returns the unique ID of the poll.
 java.util.Date getModificationDate()
          Returns the date the poll was last modified.
 java.lang.String getName()
          Returns the name of the poll.
 long getObjectID()
          Returns the object ID of the container that 'contains' the poll.
 int getObjectType()
          Returns the object type of the container that 'contains' the poll.
 java.lang.String getOption(int index)
          Returns the text of the option at the specified index.
 int getOptionCount()
          Returns the number of options available in the poll.
 java.util.Date getStartDate()
          Returns the date voting for the poll is set to start.
 User getUser()
          Returns the user who created the poll or null if the poll was created anonymously.
 int getUserVoteCount()
          Returns a count of all user votes for all options in the poll.
 int getUserVoteCount(int optionIndex)
          Returns a count of all user votes for the specified option in the poll.
 java.util.Iterator getUserVotes()
          Returns an Iterator of User objects for users who have voted for any options in the poll.
 java.util.Iterator getUserVotes(int optionIndex)
          Returns an Iterator of User objects for users who have voted for the option at the given index.
 java.util.List getUserVotes(User user)
          Returns a list of option indexes corresponding to the user votes, or an empty array if the user has not voted.
 int getVoteCount()
          Returns a count of all votes (both guest and user votes) for all options in the poll.
 int getVoteCount(int optionIndex)
          Returns a count of all votes (both guest and user votes) for the specified option in the poll.
 boolean hasAnonymousVoted(java.lang.String uniqueID)
          Returns true if the guest associated with the uniqueID has previously voted in the poll, false otherwise.
 boolean hasUserVoted(User user)
          Returns true if the user specified has previously voted in the poll, false otherwise.
 boolean isAuthorized(long permissionType)
          Returns true if the handle on the object has the permission specified.
 boolean isModeEnabled(long mode)
          Returns true if the mode specified is enabled for the poll, false otherwise.
 void removeAnonymousVote(int prevOptionIndex, java.lang.String uniqueID)
          Remove a guest vote.
 void removeUserVote(int prevOptionIndex, User user)
          Remove a user vote.
 void setDescription(java.lang.String description)
          Sets the description of the poll.
 void setEndDate(java.util.Date endDate)
          Sets the date the poll should end.
 void setExpirationDate(java.util.Date expireDate)
          Sets the date the poll should expire.
 void setMode(long mode, boolean enabled)
          Sets a mode to be enabled or disabled for the poll.
 void setName(java.lang.String name)
          Sets the name of the poll.
 void setOption(int index, java.lang.String value)
          Sets the text of the option at the specified index.
 void setOptionIndex(int currentIndex, int newIndex)
          Moves the option's index.
 void setStartDate(java.util.Date startDate)
          Sets the date voting for the poll should start.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PollProxy

public PollProxy(Poll poll,
                 Permissions permissions)
Creates a new PollProxy object.

Parameters:
poll - the poll to protect by proxy
permissions - the permissions to use with this proxy
Method Detail

getUser

public User getUser()
Description copied from interface: Poll
Returns the user who created the poll or null if the poll was created anonymously.

Specified by:
getUser in interface Poll
Returns:
the user who created the poll or null if the poll was created anonymously.

getObjectType

public int getObjectType()
Description copied from interface: Poll
Returns the object type of the container that 'contains' the poll. The container type returned wiill be a value in JiveConstants (e.g. JiveConstants.FORUM).

Specified by:
getObjectType in interface Poll
Returns:
the object type of the container that 'contains' the poll.

getObjectID

public long getObjectID()
Description copied from interface: Poll
Returns the object ID of the container that 'contains' the poll.

Specified by:
getObjectID in interface Poll
Returns:
the object ID of the container that 'contains' the poll.

getID

public long getID()
Description copied from interface: Poll
Returns the unique ID of the poll.

Specified by:
getID in interface Poll
Returns:
the unique ID of the poll.

getName

public java.lang.String getName()
Description copied from interface: Poll
Returns the name of the poll.

Specified by:
getName in interface Poll
Returns:
the name of the poll.

setName

public void setName(java.lang.String name)
             throws UnauthorizedException
Description copied from interface: Poll
Sets the name of the poll. If the name passed in is null, an IllegalArguementException will be thrown.

Specified by:
setName in interface Poll
Parameters:
name - the new name of the poll.
Throws:
UnauthorizedException - if the user does not have permissions to administer the poll.

getDescription

public java.lang.String getDescription()
Description copied from interface: Poll
Returns a brief description of the poll.

Specified by:
getDescription in interface Poll
Returns:
a brief description of the poll.

setDescription

public void setDescription(java.lang.String description)
                    throws UnauthorizedException
Description copied from interface: Poll
Sets the description of the poll.

Specified by:
setDescription in interface Poll
Parameters:
description - the description of the poll.
Throws:
UnauthorizedException - if the user does not have permissions to administer the poll.

isModeEnabled

public boolean isModeEnabled(long mode)
Description copied from interface: Poll
Returns true if the mode specified is enabled for the poll, false otherwise. Valid modes are defined as static final constants in this interface.

Specified by:
isModeEnabled in interface Poll
Returns:
true if the mode specified is enabled for the poll, false otherwise.

setMode

public void setMode(long mode,
                    boolean enabled)
             throws UnauthorizedException
Description copied from interface: Poll
Sets a mode to be enabled or disabled for the poll. Valid modes are defined as static final constants in this interface.

Specified by:
setMode in interface Poll
Parameters:
mode - a valid mode
Throws:
UnauthorizedException - if the user does not have permissions to administer the poll.

getCreationDate

public java.util.Date getCreationDate()
Description copied from interface: Poll
Returns the date the poll was created.

Specified by:
getCreationDate in interface Poll
Returns:
the date the poll was created.

getModificationDate

public java.util.Date getModificationDate()
Description copied from interface: Poll
Returns the date the poll was last modified. The last modified date only applies to the poll itself, it does not take into account votes for options in the poll.

Specified by:
getModificationDate in interface Poll
Returns:
the date the poll was last modified.

getStartDate

public java.util.Date getStartDate()
Description copied from interface: Poll
Returns the date voting for the poll is set to start.

Specified by:
getStartDate in interface Poll
Returns:
the date voting for the poll is set to start.

setStartDate

public void setStartDate(java.util.Date startDate)
                  throws UnauthorizedException
Description copied from interface: Poll
Sets the date voting for the poll should start.

Specified by:
setStartDate in interface Poll
Parameters:
startDate - the date voting for the poll should start.
Throws:
UnauthorizedException - if the user does not have permissions to administer the poll.

getEndDate

public java.util.Date getEndDate()
Description copied from interface: Poll
Returns the date voting for the poll should end.

Specified by:
getEndDate in interface Poll
Returns:
the date voting for the poll should end.

setEndDate

public void setEndDate(java.util.Date endDate)
                throws UnauthorizedException
Description copied from interface: Poll
Sets the date the poll should end.

Specified by:
setEndDate in interface Poll
Parameters:
endDate - the date the poll should end.
Throws:
UnauthorizedException - if the user does not have permissions to administer the poll.

getExpirationDate

public java.util.Date getExpirationDate()
Description copied from interface: Poll
Returns the date the poll should expire. The expire date is different from the end date in that users will be able to see the poll but not vote between the end date and the expire date.

Specified by:
getExpirationDate in interface Poll
Returns:
the date the poll should expire.

setExpirationDate

public void setExpirationDate(java.util.Date expireDate)
                       throws UnauthorizedException
Description copied from interface: Poll
Sets the date the poll should expire. This date must be on or after the end date. This date is automatically set to the end date by default.

Specified by:
setExpirationDate in interface Poll
Parameters:
expireDate - the date the poll should expire.
Throws:
UnauthorizedException - if the user does not have permissions to administer the poll.

getOptionCount

public int getOptionCount()
Description copied from interface: Poll
Returns the number of options available in the poll.

Specified by:
getOptionCount in interface Poll
Returns:
the number of options available in the poll.

getOption

public java.lang.String getOption(int index)
Description copied from interface: Poll
Returns the text of the option at the specified index.

Specified by:
getOption in interface Poll
Parameters:
index - the index of the option to return the text for.
Returns:
the text of the option at the specified index.

setOption

public void setOption(int index,
                      java.lang.String value)
               throws UnauthorizedException
Description copied from interface: Poll
Sets the text of the option at the specified index.

Specified by:
setOption in interface Poll
Parameters:
index - the index of the option to set the text for.
value - the new text for the option.
Throws:
UnauthorizedException - if the user does not have permissions to administer the poll.

setOptionIndex

public void setOptionIndex(int currentIndex,
                           int newIndex)
                    throws UnauthorizedException
Description copied from interface: Poll
Moves the option's index.

Specified by:
setOptionIndex in interface Poll
Parameters:
currentIndex - the current index of the option.
newIndex - the new index of the option.
Throws:
UnauthorizedException - if the user does not have permissions to administer the poll.

addOption

public void addOption(java.lang.String value)
               throws UnauthorizedException
Description copied from interface: Poll
Add a new option to the poll. The option will be added to the end of the option list for the poll.

Specified by:
addOption in interface Poll
Parameters:
value - the text for the new option.
Throws:
UnauthorizedException - if the user does not have permissions to administer the poll.

deleteOption

public void deleteOption(int index)
                  throws UnauthorizedException
Description copied from interface: Poll
Remove an option from the poll.

Specified by:
deleteOption in interface Poll
Throws:
UnauthorizedException - if the user does not have permissions to administer the poll.

getVoteCount

public int getVoteCount()
                 throws PollException
Description copied from interface: Poll
Returns a count of all votes (both guest and user votes) for all options in the poll.

Specified by:
getVoteCount in interface Poll
Returns:
a count of all votes for all options in the poll.
Throws:
PollException - reserved for future changes.

getVoteCount

public int getVoteCount(int optionIndex)
                 throws PollException
Description copied from interface: Poll
Returns a count of all votes (both guest and user votes) for the specified option in the poll.

Specified by:
getVoteCount in interface Poll
Returns:
a count of all votes for the specified option in the poll.
Throws:
PollException - reserved for future changes.

getUserVoteCount

public int getUserVoteCount()
                     throws PollException
Description copied from interface: Poll
Returns a count of all user votes for all options in the poll.

Specified by:
getUserVoteCount in interface Poll
Returns:
a count of all user votes for all options in the poll.
Throws:
PollException - reserved for future changes.

getUserVoteCount

public int getUserVoteCount(int optionIndex)
                     throws PollException
Description copied from interface: Poll
Returns a count of all user votes for the specified option in the poll.

Specified by:
getUserVoteCount in interface Poll
Returns:
a count of all user votes for the specified option in the poll.
Throws:
PollException - reserved for future changes.

getAnonymousVoteCount

public int getAnonymousVoteCount()
                          throws PollException
Description copied from interface: Poll
Returns a count of all guests user votes for all options in the poll.

Specified by:
getAnonymousVoteCount in interface Poll
Returns:
a count of all guest votes for all options in the poll.
Throws:
PollException - reserved for future changes.

getAnonymousVoteCount

public int getAnonymousVoteCount(int index)
                          throws PollException
Description copied from interface: Poll
Returns a count of all user votes for the specified option in the poll.

Specified by:
getAnonymousVoteCount in interface Poll
Returns:
a count of all user votes for the specified option in the poll.
Throws:
PollException - reserved for future changes.

getUserVotes

public java.util.Iterator getUserVotes()
                                throws PollException
Description copied from interface: Poll
Returns an Iterator of User objects for users who have voted for any options in the poll.

Specified by:
getUserVotes in interface Poll
Returns:
an Iterator of users who have voted for any option in the poll
Throws:
PollException - reserved for future changes.

getUserVotes

public java.util.Iterator getUserVotes(int optionIndex)
                                throws PollException
Description copied from interface: Poll
Returns an Iterator of User objects for users who have voted for the option at the given index.

Specified by:
getUserVotes in interface Poll
Parameters:
optionIndex - the index to return the voting users for.
Returns:
an Iterator of users who have voted for the option at the given index.
Throws:
PollException - reserved for future changes.

getAnonymousVotes

public java.util.Iterator getAnonymousVotes()
                                     throws PollException
Description copied from interface: Poll
Returns an Iterator of uniqueID's for guests who have voted for the option at the given index.

Specified by:
getAnonymousVotes in interface Poll
Returns:
an Iterator of uniqueID's for guests who have voted for the option at the given index.
Throws:
PollException - reserved for future changes.

getAnonymousVotes

public java.util.Iterator getAnonymousVotes(int optionIndex)
                                     throws PollException
Description copied from interface: Poll
Returns an Iterator of uniqueID's for guests who have voted for the option at the given index.

Specified by:
getAnonymousVotes in interface Poll
Parameters:
optionIndex - the index to return the voting guests for.
Returns:
an Iterator of uniqueID's for guests who have voted for the option at the given index.
Throws:
PollException - reserved for future changes.

hasUserVoted

public boolean hasUserVoted(User user)
Description copied from interface: Poll
Returns true if the user specified has previously voted in the poll, false otherwise.

Specified by:
hasUserVoted in interface Poll
Parameters:
user - the user to check to see if they've voted already.
Returns:
true if the user specified has previously voted in the poll, false otherwise.

hasAnonymousVoted

public boolean hasAnonymousVoted(java.lang.String uniqueID)
Description copied from interface: Poll
Returns true if the guest associated with the uniqueID has previously voted in the poll, false otherwise.

Specified by:
hasAnonymousVoted in interface Poll
Parameters:
uniqueID - the uniqueID of the guest to check to see if they've voted already.
Returns:
true if the guest specified has previously voted in the poll, false otherwise.

addUserVote

public void addUserVote(int optionIndex,
                        User user)
                 throws PollException,
                        UnauthorizedException
Description copied from interface: Poll
Add a user vote for an option in the poll.

Specified by:
addUserVote in interface Poll
Parameters:
optionIndex - the index of the option that the user is voting for
user - the user making the vote
Throws:
PollException - if the user has previously voted in the poll (2 second leeway is provided for posting multiple votes if that mode is enabled) or the poll is not active.
UnauthorizedException - if the user does not have permission to vote.

addAnonymousVote

public void addAnonymousVote(int optionIndex,
                             java.lang.String uniqueID)
                      throws PollException,
                             UnauthorizedException
Description copied from interface: Poll
Add a guest vote for an option in the poll.

Specified by:
addAnonymousVote in interface Poll
Parameters:
optionIndex - the index of the option that the guest is voting for
uniqueID - a uniqueID for the guest. We suggest either using a session ID or the remote IP of the guest voting.
Throws:
PollException - if the guest has previously voted in the poll (2 second leeway is provided for posting multiple votes if that mode is enabled) or the poll is not active.
UnauthorizedException - if the guest does not have permission to vote.

changeUserVote

public void changeUserVote(int prevOptionIndex,
                           int newOptionIndex,
                           User user)
                    throws PollException,
                           UnauthorizedException
Description copied from interface: Poll
Change a user vote. This method will throw a PollException unless the mode 'ALLOW_USER_VOTE_MODIFICATION' is enabled for the poll.

Specified by:
changeUserVote in interface Poll
Parameters:
prevOptionIndex - the index of the option to change the vote from.
newOptionIndex - the index of the option to change the vote to.
Throws:
PollException - if the poll is not active, the user did not vote for the prevOptionIndex or vote modification is not enabled for users.
UnauthorizedException - if the user does not have permission to vote.

changeAnonymousVote

public void changeAnonymousVote(int prevOptionIndex,
                                int newOptionIndex,
                                java.lang.String uniqueID)
                         throws PollException,
                                UnauthorizedException
Description copied from interface: Poll
Change a guest vote. This method will throw a PollException unless the mode 'ALLOW_ANONYMOUS_VOTE_MODIFICATION' is enabled for the poll.

Specified by:
changeAnonymousVote in interface Poll
Parameters:
prevOptionIndex - the index of the option to change the vote from.
newOptionIndex - the index of the option to change the vote to.
uniqueID - a uniqueID for the guest.
Throws:
PollException - if the poll is not active, the guest did not vote for the prevOptionIndex or vote modification is not enabled for guests.
UnauthorizedException - if the guest does not have permission to vote.

removeUserVote

public void removeUserVote(int prevOptionIndex,
                           User user)
                    throws PollException,
                           UnauthorizedException
Description copied from interface: Poll
Remove a user vote. This method will throw a PollException unless the mode 'ALLOW_USER_VOTE_MODIFICATION' is enabled for the poll.

Specified by:
removeUserVote in interface Poll
Parameters:
prevOptionIndex - the index of the option to remove the vote from.
Throws:
PollException - if the poll is not active, the user did not vote for the prevOptionIndex or vote modification is not enabled for users.
UnauthorizedException - if the user does not have permission to vote.

removeAnonymousVote

public void removeAnonymousVote(int prevOptionIndex,
                                java.lang.String uniqueID)
                         throws PollException,
                                UnauthorizedException
Description copied from interface: Poll
Remove a guest vote. This method will throw a PollException unless the mode 'ALLOW_ANONYMOUS_VOTE_MODIFICATION' is enabled for the poll.

Specified by:
removeAnonymousVote in interface Poll
Parameters:
prevOptionIndex - the index of the option to remove the vote from.
uniqueID - a uniqueID for the guest.
Throws:
PollException - if the poll is not active, the guest did not vote for the prevOptionIndex or vote modification is not enabled for guests.
UnauthorizedException - if the guest does not have permission to vote.

getUserVotes

public java.util.List getUserVotes(User user)
Description copied from interface: Poll
Returns a list of option indexes corresponding to the user votes, or an empty array if the user has not voted.

Specified by:
getUserVotes in interface Poll
Parameters:
user - the user to return the indexes of options the user has voted for.
Returns:
a list of option indexes (as Integers) corresponding to the user votes.

getAnonymousVotes

public java.util.List getAnonymousVotes(java.lang.String uniqueID)
Description copied from interface: Poll
Returns a list of option indexes corresponding to the anonymous votes, or an empty array if the user has not voted.

Specified by:
getAnonymousVotes in interface Poll
Parameters:
uniqueID - a uniqueID for the guest.
Returns:
a list of option indexes (as Integers) corresponding to the anonymous votes.

isAuthorized

public boolean isAuthorized(long permissionType)
Description copied from interface: Poll
Returns true if the handle on the object has the permission specified. For example, if a user authorized to vote has a handle on this object, then calling isAuthorized(ForumPermissions.VOTE_IN_POLL) would return true.

A list of possible permissions can be found in the ForumPermissions class. Certain methods of this class are restricted to certain permissions as specified in the method comments.

Specified by:
isAuthorized in interface Poll
Parameters:
permissionType - permissionType a permission type.
Returns:
true if the handle on the object has the specified permission.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.