votorola.a.election
Class CountNode.Table

java.lang.Object
  extended by CountNode.Table
Direct Known Subclasses:
CR_Vote.CachedCountNodeTable
Enclosing class:
CountNode

@ThreadSafe
public static class CountNode.Table
extends Object

The relational store of count nodes that (in part) backs a election count.


Nested Class Summary
(package private) static class CountNode.Table.RankedCumulate
           
 
Constructor Summary
CountNode.Table(ReadyDirectory readyDirectory, Database database)
          Constructs a Table.
 
Method Summary
(package private)  void create()
          Creates this table in the database.
(package private)  Database database()
          Returns the database in which this table is stored.
(package private)  void drop()
          Drops this table from the database.
(package private)  boolean exists()
          Returns true if this table exists in the database; false otherwise.
(package private)  CountNode get(String voterEmail)
          Retrieves a node from this table.
(package private)  List<CountNode> getByRankIndeces(int first, int lastBound)
          Retrieves a list of nodes by rank indeces.
 List<CountNode> getCastersByCandidate(String candidateEmail, long minimumCarryCount)
          Retrieves a list of nodes that are successfully casting for a particular candidate.
 CountNode getOrCreate(String voterEmail)
          Retrieves a node from this table; or, if none is stored, a default node.
 void put(CountNode node)
          Stores a node.
(package private)  CountNode.Table.RankedCumulate rank()
          Sorts all rows by the columns that determine rank; stores the resulting rank and rank-index for each row; and returns the cumulative count of votes cast, and so forth.
(package private)  ReadyDirectory readyDirectory()
          The file-based counterpart to this table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CountNode.Table

CountNode.Table(ReadyDirectory readyDirectory,
                Database database)
          throws IOException
Constructs a Table.

Parameters:
readyDirectory - per readyDirectory()
database - per database()
Throws:
IOException
Method Detail

create

final void create()
           throws SQLException
Creates this table in the database.

Throws:
SQLException

database

final Database database()
Returns the database in which this table is stored.


drop

final void drop()
         throws SQLException
Drops this table from the database.

Throws:
SQLException

exists

final boolean exists()
              throws SQLException
Returns true if this table exists in the database; false otherwise.

Throws:
SQLException

get

CountNode get(String voterEmail)
        throws SQLException
Retrieves a node from this table.

Returns:
node as stored in the table; or null, if none is stored
Throws:
SQLException

getByRankIndeces

List<CountNode> getByRankIndeces(int first,
                                 int lastBound)
                           throws SQLException
Retrieves a list of nodes by rank indeces. The list includes all nodes from first index (inclusive) to lastBound (exclusive). It is pre-sorted, from low to high.

Throws:
SQLException

getCastersByCandidate

public List<CountNode> getCastersByCandidate(String candidateEmail,
                                             long minimumCarryCount)
                                      throws SQLException
Retrieves a list of nodes that are successfully casting for a particular candidate. The list is pre-sorted by carry count, from high to low.

Parameters:
minimumCarryCount - the minimum carry count that a node must have, for inclusion in the list; all others are excluded
Throws:
SQLException

getOrCreate

public CountNode getOrCreate(String voterEmail)
                      throws SQLException
Retrieves a node from this table; or, if none is stored, a default node.

Returns:
CountNode as stored in the table; or, if none is stored, a CountNodeIC with default values
Throws:
SQLException

put

public final void put(CountNode node)
               throws SQLException
Stores a node.

Throws:
SQLException

rank

CountNode.Table.RankedCumulate rank()
                              throws SQLException
Sorts all rows by the columns that determine rank; stores the resulting rank and rank-index for each row; and returns the cumulative count of votes cast, and so forth.

Throws:
SQLException

readyDirectory

final ReadyDirectory readyDirectory()
The file-based counterpart to this table.