org.bolson.vote
Class SynchronizedVSWrapper

java.lang.Object
  extended by org.bolson.vote.VotingSystem
      extended by org.bolson.vote.SynchronizedVSWrapper
All Implemented Interfaces:
java.io.Serializable

public class SynchronizedVSWrapper
extends VotingSystem

Wrapper that makes all calls synchronized on the subordinate VotingSystem object.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.bolson.vote.VotingSystem
debug, NO_VOTE, numc
 
Constructor Summary
SynchronizedVSWrapper(VotingSystem it)
           
 
Method Summary
 int[] getWinners()
          Do processing if necessary, return winners.
 java.lang.String htmlSummary(java.lang.String[] names)
          A fancy html representation.
 java.lang.String toString(java.lang.String[] names)
          A more interesting representation.
 int voteRanking(int[] ranking)
           
 int voteRating(double[] rating)
           
 int voteRating(float[] rating)
           
 int voteRating(int[] rating)
           
 
Methods inherited from class org.bolson.vote.VotingSystem
checkRatedVote, getDebugHTML, getDebugText, getNumberOfCandidates, getWinners, getWinners, getWinners, init, isValidRankedVote, isValidRatedVote, name, normalize, normalize, normalize, normalize, normalize, normalizeL2, normalizeL2, normalizeL2, normalizeL2, normalizeL2, stretch, voteRating
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SynchronizedVSWrapper

public SynchronizedVSWrapper(VotingSystem it)
Method Detail

voteRating

public int voteRating(int[] rating)
Specified by:
voteRating in class VotingSystem
Parameters:
rating - An array int[numc]. rating[i] is the rating of choice i. A rating can be any int value. Higher means more preferred. NO_VOTE for unrated.
Returns:
0 on success

voteRating

public int voteRating(float[] rating)
Specified by:
voteRating in class VotingSystem
Parameters:
rating - An array int[N]. rating[i] is the rating of choice i. A rating can be any int value. Higher means more preferred. NO_VOTE for unrated.
Returns:
0 on success

voteRating

public int voteRating(double[] rating)
Specified by:
voteRating in class VotingSystem
Parameters:
rating - An array int[N]. rating[i] is the rating of choice i. A rating can be any int value. Higher means more preferred. NO_VOTE for unrated.
Returns:
0 on success

voteRanking

public int voteRanking(int[] ranking)
Specified by:
voteRanking in class VotingSystem
Parameters:
ranking - An array int[N]. ranking[i] is the ranking of choice i. rankings are 1 (most preferred) through N (least). INT_MAX, N, or NO_VOTE for unspecified.
Returns:
0 on success

getWinners

public int[] getWinners()
Description copied from class: VotingSystem
Do processing if necessary, return winners.

It is recommended to cache the return value in such a way that calling this function again does not do complex recalculation. That cache should be cleared if voteRating or voteRanking is called.

Specified by:
getWinners in class VotingSystem
Returns:
indecies of winners (hopefully 1 of them)

toString

public java.lang.String toString(java.lang.String[] names)
Description copied from class: VotingSystem
A more interesting representation. Include the names of the choices voted upon in the representation.

Specified by:
toString in class VotingSystem
Parameters:
names - The names of the choices.
Returns:
state, with names!

htmlSummary

public java.lang.String htmlSummary(java.lang.String[] names)
Description copied from class: VotingSystem
A fancy html representation. Include the names of the choices voted upon in the representation.

Specified by:
htmlSummary in class VotingSystem
Parameters:
names - The names of the choices. May be null.
Returns:
state, with names!