votorola.a.register
Class ListNodeC

java.lang.Object
  extended by ListNodeC
All Implemented Interfaces:
Serializable, ListNode
Direct Known Subclasses:
ListNodeIC

@ThreadRestricted(value="single writer, readers touch")
public class ListNodeC
extends Object
implements ListNode

A committable node in a compiled voter list.

See Also:
Serialized Form

Nested Class Summary
static interface ListNodeC.Runner
          A routine that runs in the context of a list node.
static class ListNodeC.Table
          The relational store of voters, that (in part) backs a compiled voter list.
 
Constructor Summary
ListNodeC(ListNodeC.Table table, String voterEmail)
          Creates a ListNodeC, with all variable items at default values.
ListNodeC(ListNodeC.Table table, String voterEmail, String bar, int doubterCount, String neighbourhoodPath, String residence, int[] trustEdgeCountArray)
          Constructs a ListNodeC.
 
Method Summary
 void attachTrustEdge(int trustLevel0)
          Attaches a trust edge to this node.
 void commit()
          Writes this node to the table, if it has uncommitted changes.
(package private) static String defaultRootNeighbourhoodBar(String voterEmail)
          Returns an un-localized bar, complaining that the voter's residential address cannot be parsed to a local neighbourhood.
 void detachTrustEdge(int trustLevel0)
          Detaches a trust edge from this node.
 int doubterCount()
          The number of doubt signals extended to this voter, from unbarred voters.
 String getBar()
          The list bar against the voter, if any.
 String getNeighbourhoodPath()
          The path to the voter's leaf neighbourhood, where she resides.
 String getResidence()
          The primary residential address of the voter.
(package private)  void incrementDoubterCount()
          Increments the doubter count.
 String leafRegisterPath()
          Returns the slash-delimited (/) path to the voter's leaf register, within the sub-hierarchy of electoral offices.
 int primaryTrustEdgeCount()
          The number of primary trust extending to this node.
 void setBar(String newBar)
          Sets a list bar against the voter.
 void setNeighbourhoodPath(String newNeighbourhoodPath)
           
 void setResidence(String newResidence)
           
 ListNodeC.Table table()
          The table in which this node is stored.
 String toString()
          Returns the voter email address.
 int trustLevel()
          Calculates the trust level of this node.
 String voterEmail()
          Identifies the voter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ListNodeC

ListNodeC(ListNodeC.Table table,
          String voterEmail)
Creates a ListNodeC, with all variable items at default values.

Parameters:
table - per table()
voterEmail - per voterEmail()

ListNodeC

public ListNodeC(ListNodeC.Table table,
                 String voterEmail,
                 String bar,
                 int doubterCount,
                 String neighbourhoodPath,
                 String residence,
                 int[] trustEdgeCountArray)
Constructs a ListNodeC.

Parameters:
table - per table()
voterEmail - per voterEmail()
bar - per getBar()
doubterCount - per doubterCount()
neighbourhoodPath - per getNeighbourhoodPath()
residence - per getResidence()
trustEdgeCountArray - defining attached trust edges()
Method Detail

attachTrustEdge

public final void attachTrustEdge(int trustLevel0)
Attaches a trust edge to this node. The change may affect the trust level of this node, but is not automatically propagated to other nodes.

Parameters:
trustLevel0 - trust level of source node, or Integer.MAX_VALUE for infinity
See Also:
detachTrustEdge(int), trustLevel()

detachTrustEdge

public final void detachTrustEdge(int trustLevel0)
Detaches a trust edge from this node. The change may affect the trust level of this node, but is not automatically propagated to other nodes.

Parameters:
trustLevel0 - trust level of source node
See Also:
attachTrustEdge(int)

commit

public final void commit()
                  throws SQLException
Writes this node to the table, if it has uncommitted changes.

Throws:
SQLException

defaultRootNeighbourhoodBar

static String defaultRootNeighbourhoodBar(String voterEmail)
Returns an un-localized bar, complaining that the voter's residential address cannot be parsed to a local neighbourhood.


table

public final ListNodeC.Table table()
The table in which this node is stored.

Returns:
table, or null if this is a deserialized, read-only node

doubterCount

public int doubterCount()
Description copied from interface: ListNode
The number of doubt signals extended to this voter, from unbarred voters. Doubt signals from list-barred voters are excluded from this count.

Specified by:
doubterCount in interface ListNode
See Also:
incrementDoubterCount()

incrementDoubterCount

final void incrementDoubterCount()
Increments the doubter count.

See Also:
doubterCount()

getBar

public final String getBar()
Description copied from interface: ListNode
The list bar against the voter, if any. A barred voter does not appear in the compiled voter list (unless clearly marked as barred), and is ineligible to vote in any of the elections. Criteria for list bars include, for example, the voter being registered; living in the general electoral district that the office serves; and having sufficient trust to appear in the list.

The bar is intended for voters to read. It ought to include the email address of the barred voter. It ought to provide information that will be helpful in allowing the voter to overcome the bar, where possible (for instance, by correcting a registration error).

Specified by:
getBar in interface ListNode
Returns:
description of bar, or null if there is no bar
See Also:
setBar(String)

setBar

public final void setBar(String newBar)
Sets a list bar against the voter.

See Also:
getBar()

getNeighbourhoodPath

public final String getNeighbourhoodPath()
Description copied from interface: ListNode
The path to the voter's leaf neighbourhood, where she resides. It is used during indexing of the voter list, and determines where her name will appear in the compiled list.

If the path is empty (root leaf), then the bar is guaranteed to be non-null, barring the voter from the list. Because the list browsing facilities cannot display voters at the root leaf, we avoid confusion by barring them from the outset.

Specified by:
getNeighbourhoodPath in interface ListNode
Returns:
a non-null string, possibly empty (the leaf on the root)
See Also:
setNeighbourhoodPath(String)

setNeighbourhoodPath

public final void setNeighbourhoodPath(String newNeighbourhoodPath)
See Also:
getNeighbourhoodPath()

getResidence

public final String getResidence()
Description copied from interface: ListNode
The primary residential address of the voter.

Specified by:
getResidence in interface ListNode
Returns:
residential address, or null if unknown
See Also:
setResidence(String)

setResidence

public final void setResidence(String newResidence)
See Also:
getResidence()

leafRegisterPath

public final String leafRegisterPath()
Description copied from interface: ListNode
Returns the slash-delimited (/) path to the voter's leaf register, within the sub-hierarchy of electoral offices. Each element of the path is a service email identifier designating a single sub-register. The path is anchored in the trace register of this electoral office (which is not itself expressed as an element), and terminates with the voter's most immediate register (i.e. the leaf register). For example, if this is the Canadian national office, then the path to its Toronto leaf register might be:
register@v4ontario.ca/register@v2toronto.ca

If the trace register is the leaf register (if this is the Toronto office, for example), then a dot (.) is returned.

Specified by:
leafRegisterPath in interface ListNode
Returns:
path to voter's leaf register, or '.' if the trace register is the leaf

primaryTrustEdgeCount

public final int primaryTrustEdgeCount()
Description copied from interface: ListNode
The number of primary trust extending to this node.

Specified by:
primaryTrustEdgeCount in interface ListNode

trustLevel

public final int trustLevel()
Description copied from interface: ListNode
Calculates the trust level of this node. The trust level is the highest level (T) among all immediate trust sources, such that the count of sources at that level or higher (nT) is at least equal to T (nT >= T). For example, to have a trust level of 3, this node must have 3 or more immediate trust sources, each itself at level 3 or higher.

Specified by:
trustLevel in interface ListNode
See Also:
attachTrustEdge(int)

voterEmail

public final String voterEmail()
Description copied from interface: ListNode
Identifies the voter.

Specified by:
voterEmail in interface ListNode
Returns:
canonical email address (having no personal part)
See Also:
Registration.voterEmail()

toString

public final String toString()
Returns the voter email address.

Overrides:
toString in class Object