org.gswing.components.common
Class Constituency

java.lang.Object
  extended by org.gswing.components.common.SimpleConstituency
      extended by org.gswing.components.common.Constituency
All Implemented Interfaces:
Serializable, Comparable<Constituency>

public class Constituency
extends SimpleConstituency
implements Comparable<Constituency>

Represents a electoral constituency. This is national, regional, council, constituency or local.

See Also:
Serialized Form

Constructor Summary
Constituency(String name, int number, char type, SimpleConstituency parent)
          Constructor.
 
Method Summary
 int compareTo(Constituency left)
          Compare another constituency to this.
 boolean equals(Object obj)
          Compare another constituency with this.
 String getParentName()
          Get the name of the parent constituency.
 int getParentNo()
          Get the unique parent identifier for this constituency.
static char getParentType(char child)
          The parent constituency char.
 char getType()
          The constituency type - national, regional, council, constituency or local (defined in Result).
static char getType(String type)
          Convert string type to constituency type.
 void setType(char type)
          Set the constituency type.
 String toString()
          Get this constituency as a string.
 
Methods inherited from class org.gswing.components.common.SimpleConstituency
getConstituencyNo, getName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Constituency

public Constituency(String name,
                    int number,
                    char type,
                    SimpleConstituency parent)
Constructor.

Parameters:
name - The constituency name.
number - The unique constituency number (primary key) in the database.
type - The constituency type - national, regional, council, constituency or local (defined in Result).
parent - The parent constituency.
Method Detail

getType

public char getType()
The constituency type - national, regional, council, constituency or local (defined in Result).

Returns:
The constituency type character.

getParentType

public static char getParentType(char child)
The parent constituency char.

Parameters:
child - The child constituency.
Returns:
The parent constituency character.

setType

public void setType(char type)
Set the constituency type.

Parameters:
type - The new char type.

getType

public static char getType(String type)
Convert string type to constituency type.

Parameters:
type - The type as a string as stored in the database.
Returns:
The associated type as a character.

getParentNo

public int getParentNo()
Get the unique parent identifier for this constituency.

Returns:
The parent id.

getParentName

public String getParentName()
Get the name of the parent constituency.

Returns:
The parent name.

toString

public String toString()
Get this constituency as a string.

Overrides:
toString in class Object
Returns:
The constituency name.

equals

public boolean equals(Object obj)
Compare another constituency with this.

Overrides:
equals in class Object
Parameters:
obj - The constituency to compare this with.
Returns:
True if the constituency name and parent are the same.

compareTo

public int compareTo(Constituency left)
Compare another constituency to this. For this to work the toString() method must return the constituency name.

Specified by:
compareTo in interface Comparable<Constituency>
Parameters:
left - The object to compare with this.


Copyright © 2008. All Rights Reserved.