votorola.a.register.trust
Class DoubtSignal

java.lang.Object
  extended by DoubtSignal
All Implemented Interfaces:
Serializable, Comparable<DoubtSignal>

public final class DoubtSignal
extends Object
implements Comparable<DoubtSignal>, Serializable

A signal of doubt extending from one voter (source) to another (destination).

See Also:
Doubt Signaling, TrustEdge, Serialized Form

Nested Class Summary
(package private) static class DoubtSignal.Key
          A unique identifier for a particular signal.
static class DoubtSignal.Table
          A relational store of doubt signals, backing an electoral register's doubt signaling network.
 
Field Summary
(package private) static short DOUBT_DESTINATIONS_MAX
          Limiting the number of doubt destinations, in order to prevent a DoS attack.
 
Constructor Summary
DoubtSignal(String voter0Email, String voter1Email)
          Creates a DoubtSignal with default values.
DoubtSignal(String voter0Email, String voter1Email, String reason)
          Constructs an existing DoubtSignal.
 
Method Summary
 boolean commit(DoubtSignal.Table table, ElectoralSubserver.UserSession session)
          Writes this signal to the table, if it has uncommitted changes.
 int compareTo(DoubtSignal other)
          Compares based on voter1Email (first) and voter0Email (second).
 boolean equals(Object o)
          Returns true iff the o is a doubt signal, and all of its key fields are "equal" to this signal's key fields.
 String getReason()
          An explanation of the reason for the doubt signal.
 DoubtSignal.Key key()
          The unique identifier of this signal.
 void setReason(String newReason)
           
 String toString()
          Returns a description of the signal, including the values of its unique key.
 String voter0Email()
          Identifies the source voter.
 String voter1Email()
          Identifies the destination voter.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DOUBT_DESTINATIONS_MAX

static final short DOUBT_DESTINATIONS_MAX
Limiting the number of doubt destinations, in order to prevent a DoS attack.

See Also:
Constant Field Values
Constructor Detail

DoubtSignal

public DoubtSignal(String voter0Email,
                   String voter1Email)
Creates a DoubtSignal with default values.

Parameters:
voter0Email - per voter0Email()
voter1Email - per voter1Email()

DoubtSignal

DoubtSignal(String voter0Email,
            String voter1Email,
            String reason)
Constructs an existing DoubtSignal.

Parameters:
voter0Email - per voter0Email()
voter1Email - per voter1Email()
reason - per getReason()
Method Detail

commit

public boolean commit(DoubtSignal.Table table,
                      ElectoralSubserver.UserSession session)
               throws SQLException,
                      VoterInputTable.BadInputException
Writes this signal to the table, if it has uncommitted changes.

Returns:
whether or not the signal was written
Throws:
SQLException
VoterInputTable.BadInputException

getReason

public String getReason()
An explanation of the reason for the doubt signal.

Returns:
explanation of reason, or null if there is none
See Also:
setReason(String)

setReason

public void setReason(String newReason)
See Also:
getReason()

key

public final DoubtSignal.Key key()
The unique identifier of this signal.


voter0Email

public String voter0Email()
Identifies the source voter.

Returns:
canonical email address (having no personal part)

voter1Email

public String voter1Email()
Identifies the destination voter.

Returns:
canonical email address (having no personal part)

compareTo

public int compareTo(DoubtSignal other)
Compares based on voter1Email (first) and voter0Email (second). The fields are thus reversed for the sake of speed, voter0Email values being the same in typical use cases (searching and sorting the signals of one source).

Specified by:
compareTo in interface Comparable<DoubtSignal>

equals

public boolean equals(Object o)
Returns true iff the o is a doubt signal, and all of its key fields are "equal" to this signal's key fields. Non-key fields are not compared.

Overrides:
equals in class Object

toString

public String toString()
Returns a description of the signal, including the values of its unique key.

Overrides:
toString in class Object