org.gswing.components.common
Class Result

java.lang.Object
  extended by org.gswing.components.common.Result
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
OverallResult

public class Result
extends Object
implements Serializable

Purpose: Represents a single constituency or regional result.

See Also:
Serialized Form

Field Summary
static char CONSTITUENCY
          Constituency election result type.
static char COUNCIL
          Regional election result type.
protected  Vector<Entry> entries
          Holds all result entries.
protected static String GAIN
          Result gain string.
protected static String HOLD
          Result hold string.
static char INVALID
          Invalid election result type.
static char LOCAL
          Local election result type.
protected  int m_electorate
          Size of the electorate.
protected  String m_result
          The actual result.
protected  int m_totalVotes
          Total votes cast.
protected  int m_turnout
          The size of the electorate.
static char NATIONAL
          Overall election result type.
static char REGIONAL
          Regional election result type.
protected static String WIN
          Result win string.
 
Constructor Summary
Result(Constituency constituency)
          Constructor.
 
Method Summary
 void add(Entry entry)
          Add an entry to the result.
 void calculateResult(String previousWinner)
          Work out the result.
protected  void calculateWinner(String previousWinner)
          Is this a win, hold or gain.
 Vector cloneEntries()
          Clone entries vector.
 Entry elementAt(int i)
          Get the entry at this index.
 Constituency getConstituency()
          Get the constituency of this result.
 Election getElection()
          Set the election data for this result.
 int getElectorate()
          Get the number of voters eligible to vote in this constituency.
 Vector getEntries()
          Get all entries in this result.
 int getIndex()
          Set the index of this result in relation to other results of the same constituency.
 int getMajority()
          Get the size of the mojority in this result.
 int getPercentage(String party)
          Returns the percentage of the specified party.
 String getResult()
          Get this result.
 int getTotalVotes()
          Get total number of votes cast in this constituency.
 int getTurnout()
          Gets the percentage of eligible voters who participated in the election.
 char getType()
          What type of result is this - Constituency, regional or overall.
 Party getWinningParty()
          Get the winning party.
 boolean isLatest()
          Get whether this result is the latest in the database.
 boolean isOldest()
          Get whether this result is the oldest in the database.
 void removeEntries()
          Remove all entries.
 void setElection(Election election)
          Set the election data of this result.
 void setElectorate(int electorate)
          The number of voters eligible to vote in this constituency.
 void setIndex(int index)
          Set the index of this result in relation to other results of the same constituency.
 void setIsLatest(boolean isLatest)
          Set whether this result is the latest result in the database.
 void setIsOldest(boolean isOldest)
          Set whether this result is the oldest result in the database.
 void setTurnout(int turnout)
          Sets the percentage of eligible voters who participated in the election.
 int size()
          Get the number of entries in this result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WIN

protected static final String WIN
Result win string.

See Also:
Constant Field Values

HOLD

protected static final String HOLD
Result hold string.

See Also:
Constant Field Values

GAIN

protected static final String GAIN
Result gain string.

See Also:
Constant Field Values

INVALID

public static final char INVALID
Invalid election result type.

See Also:
Constant Field Values

NATIONAL

public static final char NATIONAL
Overall election result type.

See Also:
Constant Field Values

REGIONAL

public static final char REGIONAL
Regional election result type.

See Also:
Constant Field Values

COUNCIL

public static final char COUNCIL
Regional election result type.

See Also:
Constant Field Values

CONSTITUENCY

public static final char CONSTITUENCY
Constituency election result type.

See Also:
Constant Field Values

LOCAL

public static final char LOCAL
Local election result type.

See Also:
Constant Field Values

entries

protected Vector<Entry> entries
Holds all result entries.


m_result

protected String m_result
The actual result.


m_electorate

protected int m_electorate
Size of the electorate.


m_totalVotes

protected int m_totalVotes
Total votes cast.


m_turnout

protected int m_turnout
The size of the electorate.

Constructor Detail

Result

public Result(Constituency constituency)
Constructor.

Parameters:
constituency - The constituency name.
Method Detail

add

public void add(Entry entry)
Add an entry to the result.

Parameters:
entry - An entry representing a candidates vote.

size

public int size()
Get the number of entries in this result.

Returns:
The number of entries.

elementAt

public Entry elementAt(int i)
Get the entry at this index.

Parameters:
i - The entry index.
Returns:
The entry data.

getConstituency

public Constituency getConstituency()
Get the constituency of this result.

Returns:
The constituency reference.

getWinningParty

public Party getWinningParty()
Get the winning party.

Returns:
The name of the winning party.

getMajority

public int getMajority()
Get the size of the mojority in this result.

Returns:
The majority in number of votes.

calculateResult

public void calculateResult(String previousWinner)
Work out the result.

Parameters:
previousWinner - The party of the previous winner of this constituency.

calculateWinner

protected void calculateWinner(String previousWinner)
Is this a win, hold or gain.

Parameters:
previousWinner - The party of the previous winner of this constituency.

getPercentage

public int getPercentage(String party)
Returns the percentage of the specified party.

Parameters:
party - The party name.
Returns:
The percntage as an integer.

setElection

public void setElection(Election election)
Set the election data of this result.

Parameters:
election - The election data.

getElection

public Election getElection()
Set the election data for this result.

Returns:
The election data.

getResult

public String getResult()
Get this result.

Returns:
The result.

setIsLatest

public void setIsLatest(boolean isLatest)
Set whether this result is the latest result in the database.

Parameters:
isLatest - Whether this is the latest result.

isLatest

public boolean isLatest()
Get whether this result is the latest in the database.

Returns:
Whether true if this result is the latest result.

setIsOldest

public void setIsOldest(boolean isOldest)
Set whether this result is the oldest result in the database.

Parameters:
isOldest - Whether this is the oldest result.

isOldest

public boolean isOldest()
Get whether this result is the oldest in the database.

Returns:
Whether true if this result is the oldest result.

setIndex

public void setIndex(int index)
Set the index of this result in relation to other results of the same constituency.

Parameters:
index - The result index.

getIndex

public int getIndex()
Set the index of this result in relation to other results of the same constituency.

Returns:
The result index.

getTotalVotes

public int getTotalVotes()
Get total number of votes cast in this constituency.

Returns:
Total number of votes.

setTurnout

public void setTurnout(int turnout)
Sets the percentage of eligible voters who participated in the election.

Parameters:
turnout - The percentage turnout as an integer.

getTurnout

public int getTurnout()
Gets the percentage of eligible voters who participated in the election.

Returns:
The percentage turnout as an integer.

getEntries

public Vector getEntries()
Get all entries in this result.

Returns:
A vector of entries.

removeEntries

public void removeEntries()
Remove all entries.


cloneEntries

public Vector cloneEntries()
Clone entries vector.

Returns:
A new entries vector.

getType

public char getType()
What type of result is this - Constituency, regional or overall.

Returns:
The result type.

setElectorate

public void setElectorate(int electorate)
The number of voters eligible to vote in this constituency.

Parameters:
electorate - The number of eligible voters.

getElectorate

public int getElectorate()
Get the number of voters eligible to vote in this constituency.

Returns:
The number of eligible voters.


Copyright © 2008. All Rights Reserved.