votorola.a.election
Class Vote

java.lang.Object
  extended by Vote
All Implemented Interfaces:
Serializable, Cloneable

@ThreadRestricted(value="touch")
public final class Vote
extends Object
implements Cloneable, Serializable

A voter's input to an election, backed by a row of the election's voter input table.

See Also:
Serialized Form

Nested Class Summary
static class Vote.CastEvent
          An event that records the casting of a vote.
static class Vote.VotingEvent
          An event that records the casting or withdrawal of a vote.
static class Vote.WithdrawalEvent
          An event that records the withdrawal of a vote.
 
Constructor Summary
Vote(String voterEmail)
          Constructs a Vote with default initial data.
Vote(String voterEmail, String xml)
          Constructs a Vote from the specified initial data.
Vote(String voterEmail, VoterInputTable voterInputTable)
          Constructs a Vote, reading its initial state from the voter input table.
 
Method Summary
 Vote clone()
           
(package private)  void commit(VoterInputTable voterInputTable, ElectoralSubserver.UserSession userSession)
          Writes this voter input to the table, if it has uncommitted changes; or removes it, if it is at default.
(package private)  void commit(VoterInputTable voterInputTable, ElectoralSubserver.UserSession userSession, boolean toForce)
          Writes this voter input to the table; or removes it, if it is at default.
 String getCandidateEmail()
          Identifies the candidate for whom the voter is voting.
 void setCandidateEmail(String newCandidateEmail)
          Changes the candidate for whom the voter is voting.
(package private)  String voterEmail()
          Identifies the voter.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Vote

public Vote(String voterEmail,
            VoterInputTable voterInputTable)
     throws SQLException
Constructs a Vote, reading its initial state from the voter input table.

Parameters:
voterEmail - per voterEmail()
voterInputTable - of the election
Throws:
SQLException

Vote

Vote(String voterEmail,
     String xml)
throws XMLStreamException
Constructs a Vote from the specified initial data.

Parameters:
voterEmail - per voterEmail()
xml - initial data from the 'xml' column of the voter input table, or null to use defaults
Throws:
XMLStreamException

Vote

Vote(String voterEmail)
Constructs a Vote with default initial data.

Parameters:
voterEmail - per voterEmail()
Method Detail

commit

void commit(VoterInputTable voterInputTable,
            ElectoralSubserver.UserSession userSession)
      throws SQLException,
             VoterInputTable.BadInputException
Writes this voter input to the table, if it has uncommitted changes; or removes it, if it is at default.

Parameters:
voterInputTable - of the election
Throws:
SQLException
VoterInputTable.BadInputException

commit

void commit(VoterInputTable voterInputTable,
            ElectoralSubserver.UserSession userSession,
            boolean toForce)
      throws SQLException,
             VoterInputTable.BadInputException
Writes this voter input to the table; or removes it, if it is at default.

Parameters:
voterInputTable - of the election
toForce - false to commit only if changes were made in this instance of voter input; true to force the commit, regardless
Throws:
SQLException
VoterInputTable.BadInputException

getCandidateEmail

public String getCandidateEmail()
Identifies the candidate for whom the voter is voting.

Returns:
canonical email address (having no personal part); or null, if the voter's vote is currently uncast
See Also:
setCandidateEmail(String)

setCandidateEmail

public void setCandidateEmail(String newCandidateEmail)
Changes the candidate for whom the voter is voting.

See Also:
getCandidateEmail()

voterEmail

String voterEmail()
Identifies the voter.

Returns:
canonical email address (having no personal part)

clone

public final Vote clone()
Overrides:
clone in class Object