org.gswing.components.viewer
Class ResultsInterface

java.lang.Object
  extended by org.gswing.components.viewer.ResultsInterface
All Implemented Interfaces:
IConstituencyBrowsing

public class ResultsInterface
extends Object
implements IConstituencyBrowsing

Purpose: The applet's interface to all the results. This class deals with the opening and reading of the serialised data files. If the applet is run from a web page it reads the files from a URL, if it is run from an appletviewer they are read from a file.


Constructor Summary
ResultsInterface(boolean isApplet, String rootDir)
          Constructor.
ResultsInterface(boolean isApplet, URL baseURL)
          Constructor.
 
Method Summary
 boolean containsResult(char type)
          Do any results for this constituency type exist?
 ListModel getConstituencyList(String region)
          Get the list of constituencies for this region.
 ListModel getConstituencyList(String parent, char type)
          Get the list of constituencies for this parent.
 ListModel getCouncilList(String region)
          Get the list of councils for this region.
 String getGSwingVersion()
          Get the version of the software that was stored in the serialised file.
 Result getLatestResult(char type, String constituency)
          Get the most recent result for this constituency.
 Result getNextResult(Result oldResult)
          Get the result after this one.
 Result getOverallResult(Date date, int selection)
          Get overall results for this election for this date.
 Result getPreviousResult(Result oldResult)
          Get the previous result to this one.
 String getRegion(String ward)
          Get the region of this council ward.
 String getRegion(String constituency, char type)
          Get the region of this constituency.
 ListModel getRegionList()
          Get the list of regions in the results.
 Result[] getResults(char type, String constituency)
          Get all results for this constituency.
 Result[] getResults(Result result)
          Get all results in relation to this result.
 String getState()
          Get the name of the state.
 ListModel getWardList(String council)
          Get the list of wards for this council.
 boolean init()
          Initialise the results interface.
 void readFromFile(char type, String constituency)
          Read results from serialised file.
 void setGSwingVersion(String swingVersion)
          Get the version of the software that was stored in the serialised file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResultsInterface

public ResultsInterface(boolean isApplet,
                        String rootDir)
Constructor.

Parameters:
isApplet - Has this interface been created by and applet?
rootDir - The root directory of the applet / application.

ResultsInterface

public ResultsInterface(boolean isApplet,
                        URL baseURL)
Constructor.

Parameters:
isApplet - Has this interface been created by and applet?
baseURL - The base URL of the applet / application.
Method Detail

init

public boolean init()
Initialise the results interface. This gets the overall results from a URL or file, decompresses it and assigns it to results.

Returns:
True if the results have been assigned successfully.

getConstituencyList

public ListModel getConstituencyList(String region)
Get the list of constituencies for this region.

Parameters:
region - The region to do the search on.
Returns:
A list of constituencies.

getConstituencyList

public ListModel getConstituencyList(String parent,
                                     char type)
Get the list of constituencies for this parent.

Specified by:
getConstituencyList in interface IConstituencyBrowsing
Parameters:
parent - The parent constituency name.
type - The parent constituency type.
Returns:
A list of constituencies.

getRegionList

public ListModel getRegionList()
Get the list of regions in the results.

Specified by:
getRegionList in interface IConstituencyBrowsing
Returns:
The region list.

getCouncilList

public ListModel getCouncilList(String region)
Get the list of councils for this region.

Parameters:
region - The region to do the search on.
Returns:
A list of councils.

getWardList

public ListModel getWardList(String council)
Get the list of wards for this council.

Parameters:
council - The council to do the search on.
Returns:
A list of wards.

getLatestResult

public Result getLatestResult(char type,
                              String constituency)
Get the most recent result for this constituency.

Parameters:
constituency - The constituency to search for.
Returns:
The most recent result.

getOverallResult

public Result getOverallResult(Date date,
                               int selection)
Get overall results for this election for this date.

Parameters:
date - The date of the election.
selection - Whether the user selection is previous or next.
Returns:
The overall result.

getPreviousResult

public Result getPreviousResult(Result oldResult)
Get the previous result to this one.

Parameters:
oldResult - The result from which to start search.
Returns:
The result for the previous year.

getNextResult

public Result getNextResult(Result oldResult)
Get the result after this one.

Parameters:
oldResult - The result from which to start search.
Returns:
The next result.

getResults

public Result[] getResults(char type,
                           String constituency)
Get all results for this constituency.

Parameters:
constituency - The constituency name.
Returns:
The array of results.

getResults

public Result[] getResults(Result result)
Get all results in relation to this result. For example if this result is an overall result get all overall results. Else if this is a constituency get all results for this constituency.

Parameters:
result - The result to be base the request on.
Returns:
An array of results.

readFromFile

public void readFromFile(char type,
                         String constituency)
Read results from serialised file.

Parameters:
type - The type of result.
constituency - The name of the constituency.

getRegion

public String getRegion(String constituency,
                        char type)
Get the region of this constituency. This isn't efficient but it is unlikely to be called often - in the lifetime of the applet once for each region.

Parameters:
constituency - The constituency name.
type - The constituency type.
Returns:
The region name.

getRegion

public String getRegion(String ward)
Get the region of this council ward. This isn't efficient but it is unlikely to be called often - in the lifetime of the applet once for each region.

Parameters:
ward - The ward constituency name.
Returns:
The region name.

getGSwingVersion

public String getGSwingVersion()
Get the version of the software that was stored in the serialised file.

Returns:
Returns the gSwingVersion.

setGSwingVersion

public void setGSwingVersion(String swingVersion)
Get the version of the software that was stored in the serialised file.

Parameters:
swingVersion - The gSwingVersion to set.

containsResult

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

Parameters:
type - The constituency type.
Returns:
True if any results exist.

getState

public String getState()
Get the name of the state.

Specified by:
getState in interface IConstituencyBrowsing
Returns:
The country / nation name.


Copyright © 2008. All Rights Reserved.