org.gswing.components.common
Class AllResults

java.lang.Object
  extended by org.gswing.components.common.AllResults
All Implemented Interfaces:
Serializable

public class AllResults
extends Object
implements Serializable

Purpose: Stores the results for an entire election. Elements of this object are stored in serialised files by the Extracter. The object is built back up by the applet region by region on demand.

See Also:
Serialized Form

Constructor Summary
AllResults(String stateName)
          Constructor.
 
Method Summary
 void addResult(int type, String constituency, Result[] result)
          Add results to model.
 void addToOverallResult(Result result)
          Add this single constituency result to an overall result.
 boolean containsResult(char type)
          Do ant results for this constituency type exist?
 String getGSwingVersion()
          Get the version of the software version.
 ListModel getList(char type, String parent)
          Returns a list of constituency names.
 Result getOverallResult(Date date, int selection)
          Get the overall result in relation to the current result (before or after).
 Hashtable getOverallResults()
          Returns the Hashtable of overall results.
 Result[] getResult(char type, String constituency)
          Get the result.
 Date[] getSortedDates()
          Sort the dates for all overall results.
 String getStateName()
          Get the name of the nation state.
 boolean resultExists(char type, String constituency)
          Determine if a particular result exists.
 void setGSwingVersion(String version)
          Set the version of the software.
protected  boolean setLeaderVotes(Result result, Entry entry)
          Add the number of votes in an entry (a result from a constituency) to the total votes of the party's leader.
 void setList(char type, Object resultList)
          Set a list of constituency names.
 void setOverallResult(Date date, OverallResult result)
          Add a result to the overall election result.
 void setOverallResults()
          Finalise the overall result calculation.
 void setOverallResults(String councilName)
          Finalise the overall result calculation for council results.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AllResults

public AllResults(String stateName)
Constructor.

Parameters:
stateName - The nation name.
Method Detail

getList

public ListModel getList(char type,
                         String parent)
Returns a list of constituency names.

Parameters:
type - The search type. Options: Result.NATION, Result.REGIONAL, Result.CONSTITUENCY, Result.COUNCIL or Result.LOCAL
parent - The parent costituency.
Returns:
The list of region names.

setList

public void setList(char type,
                    Object resultList)
Set a list of constituency names.

Parameters:
type - The search type. Options: Result.NATION, Result.REGIONAL, Result.CONSTITUENCY, Result.COUNCIL or Result.LOCAL
resultList - The list of region names.

resultExists

public boolean resultExists(char type,
                            String constituency)
Determine if a particular result exists. If the type is invalid, false will be returned.

Parameters:
type - The result type. Possible values: Result.CONSTITUENCY, Result.REGIONAL or Result.LOCAL .
constituency - The constituency name.
Returns:
True if a result of this type and constituency exists.

getResult

public Result[] getResult(char type,
                          String constituency)
Get the result. If the type is invalid return null .

Parameters:
type - The result type. Possible values: Result.CONSTITUENCY, Result.REGIONAL or Result.LOCAL .
constituency - The constituency name.
Returns:
Result for this constituency and type.

addResult

public void addResult(int type,
                      String constituency,
                      Result[] result)
Add results to model. If the type is invalid an exception will be raised.

Parameters:
type - The result type. Possible values: Result.CONSTITUENCY, Result.REGIONAL or Result.LOCAL .
constituency - The constituency name.
result - The result array to add.

getOverallResults

public Hashtable getOverallResults()
Returns the Hashtable of overall results.

Returns:
The Hashtable of overall results.

setOverallResult

public void setOverallResult(Date date,
                             OverallResult result)
Add a result to the overall election result.

Parameters:
date - The election date.
result - The overall election result.

addToOverallResult

public void addToOverallResult(Result result)
Add this single constituency result to an overall result.

Parameters:
result - The result to add.

setLeaderVotes

protected boolean setLeaderVotes(Result result,
                                 Entry entry)
Add the number of votes in an entry (a result from a constituency) to the total votes of the party's leader.

Parameters:
result - The result to add the votes to.
entry - The entry for a constituency result.
Returns:
True if the result was successfully added.

getOverallResult

public Result getOverallResult(Date date,
                               int selection)
Get the overall result in relation to the current result (before or after).

Parameters:
date - The date of the current viewed election.
selection - The type of selection - before or after.
Returns:
The result of a particular election.

setOverallResults

public void setOverallResults()
Finalise the overall result calculation.


setOverallResults

public void setOverallResults(String councilName)
Finalise the overall result calculation for council results.

Parameters:
councilName - The council name.

getSortedDates

public Date[] getSortedDates()
Sort the dates for all overall results.

Returns:
A sorted array of dates.

getGSwingVersion

public String getGSwingVersion()
Get the version of the software version.

Returns:
Returns the m_gswingVersion.

setGSwingVersion

public void setGSwingVersion(String version)
Set the version of the software.

Parameters:
version - The m_gswingVersion to set.

containsResult

public boolean containsResult(char type)
Do ant results for this constituency type exist?

Parameters:
type - The search type. Options: Result.NATION, Result.REGIONAL, Result.CONSTITUENCY, Result.COUNCIL or Result.LOCAL
Returns:
True if the constituency exists.

getStateName

public String getStateName()
Get the name of the nation state.

Returns:
The state name.


Copyright © 2008. All Rights Reserved.