org.gswing.components.common
Class Election

java.lang.Object
  extended by org.gswing.components.common.Election
All Implemented Interfaces:
Serializable, Comparator

public class Election
extends Object
implements Serializable, Comparator

Purpose: Class represents a single election.

See Also:
Serialized Form

Constructor Summary
Election(int electionNo, String type, Date date)
          Constructor.
Election(int electionNo, String name, String type, String system, Date date)
          Constructor.
Election(String type, Date date)
          Constructor.
Election(String name, String type, String system, Date date)
          Constructor.
 
Method Summary
 int compare(Object lhs, Object rhs)
          Compare elections for sorting.
 Date getDate()
          Get the date the election took place.
 int getElectionNo()
          Get the unique election number of this election.
 String getName()
          Get the name of this election.
 String getSystem()
          Get the electoral system of this election.
 String getType()
          Get the election type - general, devolved, regional, local etc.
 boolean isByElection()
           
 boolean isStandalone()
          A standalone election is an election that is used to build an overall result.
 void setName(String name)
          Set the name of this election.
 void setStandalone(Vector elections)
          Set whether this election is standalone.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

Election

public Election(int electionNo,
                String name,
                String type,
                String system,
                Date date)
Constructor.

Parameters:
electionNo - The unique election number.
name - The name given to the election.
type - The election type - general, devolved, regional, local etc.
system - The electoral system - eg. F.P.T.F. ot list.
date - The date the election took place.

Election

public Election(String name,
                String type,
                String system,
                Date date)
Constructor.

Parameters:
name - The election name.
type - The election type - general, devolved, regional, local etc..
system - The election system - F.P.T.P, List etc.
date - The date the election took place.

Election

public Election(int electionNo,
                String type,
                Date date)
Constructor.

Parameters:
electionNo - The unique election number.
type - The election type - general, devolved, regional, local etc.
date - The date the election took place.

Election

public Election(String type,
                Date date)
Constructor.

Parameters:
type - The election type - general, devolved, regional, local etc.
date - The date the election took place.
Method Detail

getElectionNo

public int getElectionNo()
Get the unique election number of this election.

Returns:
The unique election number.

getName

public String getName()
Get the name of this election.

Returns:
The election name.

setName

public void setName(String name)
Set the name of this election.

Parameters:
name - The election name.

getType

public String getType()
Get the election type - general, devolved, regional, local etc.

Returns:
The election type.

getDate

public Date getDate()
Get the date the election took place.

Returns:
The election date.

getSystem

public String getSystem()
Get the electoral system of this election.

Returns:
The electoral system.

isStandalone

public boolean isStandalone()
A standalone election is an election that is used to build an overall result. Here are the rules: 1. A general or devolved election is always a standalone result. 2. A regional election is only standalone if there is no general or devolved election on the same day. 3. A by-election is never standalone.

Returns:
Returns whether this election is standalone.

setStandalone

public void setStandalone(Vector elections)
Set whether this election is standalone. This method only appies to regional elections. A regional election is standalone if there is not another general or devolved election election on the same day.

Parameters:
elections - Vector of elections in the database.

isByElection

public boolean isByElection()
Returns:
Is this election a by-election.

toString

public String toString()
Overrides:
toString in class Object
Returns:
Return an election as a string.

compare

public int compare(Object lhs,
                   Object rhs)
Compare elections for sorting.

Specified by:
compare in interface Comparator
Parameters:
lhs - Left hand side election.
rhs - Right hand side election.
Returns:
0 is both are equal, -1 if left is before right or 1 if right is before left.


Copyright © 2008. All Rights Reserved.