|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectCountNode
public class CountNode
A node in a delegate cascade, it records the cumulative cast/count state for a single voter/candidate. It is partly serializeable; when unserialized, it becomes detached from the table, so that calling any of the table-dependent methods (such as commit, or trace) will result in a runtime exception.
| Nested Class Summary | |
|---|---|
static class |
CountNode.Table
The relational store of count nodes that (in part) backs a election count. |
| Constructor Summary | |
|---|---|
CountNode(CountNode.Table table,
String voterEmail)
Creates a CountNode with default values: all counts at zero, no chosen candidate, and no vote cast. |
|
CountNode(CountNode.Table table,
String voterEmail,
String bar,
String candidateEmail,
long carryCount,
boolean isCast,
long rank,
long rankIndex,
long receiveCount)
Constructs a CountNode. |
|
| Method Summary | |
|---|---|
long |
carryCount()
The number of received votes that are carried to the candidate node along with this node's single cast vote. |
(package private) CountNode[] |
cast(boolean toCarry)
Attempts to cast a vote for the chosen candidate. |
CountNode |
clone()
|
(package private) void |
commit()
Writes this node to the table, if it has uncommitted changes. |
String |
getBar()
The bar against the voter, if any. |
String |
getCandidateEmail()
Identifies the candidate for whom the voter will be voting, once the vote is actually cast. |
long |
getRank()
Returns the rank assigned to this node, with respect to votes received. |
long |
getRankIndex()
Returns the unique index assigned to this node, by order of rank, and (secondarily) email address. |
long |
holdCount()
The number of votes held. |
boolean |
isCast()
Returns true if a vote was successfully cast for the candidate; false otherwise. |
long |
receiveCount()
The number of votes received from other nodes. |
(package private) void |
setBar(String newBar)
Sets an eligibility bar against the voter. |
(package private) void |
setCandidateEmail(String newCandidateEmail)
Changes the candidate for whom the voter will be voting. |
(package private) void |
setRank(long newRank)
Assigns a rank to this node. |
(package private) void |
setRankIndex(long newRankIndex)
Assigns a rank index to this node. |
long |
singleCastCount()
The number of votes cast for the candidate; either 0 or 1. |
CountNode.Table |
table()
The table in which this node is stored. |
String |
toString()
Returns the voter email address. |
(package private) CountNode[] |
trace()
Traces the route a vote would follow if it a cast were attempted from this node to the candidate node, and carried onward to the terminal node. |
(package private) CountNode[] |
uncast(boolean toCarry)
Withdraws a vote for the candidate, if one was cast. |
String |
voterEmail()
Identifies the voter. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
CountNode(CountNode.Table table,
String voterEmail)
table - per table()voterEmail - per voterEmail()
CountNode(CountNode.Table table,
String voterEmail,
String bar,
String candidateEmail,
long carryCount,
boolean isCast,
long rank,
long rankIndex,
long receiveCount)
table - per table()voterEmail - per voterEmail()bar - per getBar()candidateEmail - per getCandidateEmail()carryCount - per carryCount()isCast - per isCast()receiveCount - per receiveCount()| Method Detail |
|---|
public final long carryCount()
holdCount()
final void commit()
throws SQLException
SQLExceptionpublic final long holdCount()
public final String getBar()
The bar may also be a list bar. A list bar applies to all elections.
setBar(String)final void setBar(String newBar)
getBar()public final long getRank()
1, 2, 2, 3, 4, 4, 4, 4, 4, 4, 4
In the example above, two candidates are tied for second place (rank 2). The bottom rank of 4 is shared by 7 voters who are probably non-candidates (receiving no votes).
setRank(long)final void setRank(long newRank)
getRank()public final long getRankIndex()
setRankIndex(long)final void setRankIndex(long newRankIndex)
getRankIndex()public final boolean isCast()
cast(boolean),
uncast(boolean)
final CountNode[] cast(boolean toCarry)
throws SQLException
toCarry - Set to true to carry the received votes
along with the cast vote. Set to false to transfer the single vote
of this voter, alone.
IllegalStateException - if the vote is already cast,
SQLExceptionuncast(boolean)
final CountNode[] uncast(boolean toCarry)
throws SQLException
toCarry - Set to true to withdraw any carried votes
along with the cast vote. Set to false to withdraw the single vote
of this voter, alone.
SQLExceptioncast(boolean)public final long receiveCount()
carryCount,
holdCount()public final long singleCastCount()
carryCount(),
cast(boolean),
isCast()public final CountNode.Table table()
final CountNode[] trace()
throws SQLException
SQLExceptionpublic final String getCandidateEmail()
setCandidateEmail(String)final void setCandidateEmail(String newCandidateEmail)
getCandidateEmail()public final String voterEmail()
public final CountNode clone()
clone in class Objectpublic final String toString()
toString in class Object
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||