org.gswing.components.common
Class Misc

java.lang.Object
  extended by org.gswing.components.common.Misc
Direct Known Subclasses:
Misc

public class Misc
extends Object

Purpose: Miscellaneous utility class for the common package.


Field Summary
static Color APPLET_BACKGROUND
          The applet background colour.
static JLabel CONST_LABEL
          constituency label
static String CONSTITUENCY
          Constituency election string.
static String COUNCIL
          Council election string.
static JLabel COUNCIL_LABEL
          council label
static String DEV_BY_ELEC
          Devolved by-election string.
static String DEVOLVED
          Devolved election string.
static int ERROR
          Message severity Error.
static int FPTP
          First past the post electoral system string.
static String FPTP_STR
          First past the post electoral system string.
static String GEN_BY_ELEC
          General by-election string.
static String GENERAL
          General election string.
static String GSWING_VERSION
          Current gswing version.
static int INFO
          Message severity Information
static int INVALID
          Invalid const.
static int LIST
          List electoral system string.
static String LIST_STR
          List electoral system string.
static String LOCAL
          Local election string.
static String LOCAL_FILE_NAME_ENDING
          Local results file name ending.
static JLabel LOCAL_LABEL
          local label
static String NATIONAL
          National election string.
static String NEW_LINE
          platform independant new line string.
static int NEXT
          Next const.
static String NONE_DEFINED
          none defined const.
static Font NORMAL_FONT
          Normal canvas font.
static int PREVIOUS
          Previous const.
static JLabel REGION_LABEL
          region label
static String REGIONAL
          Regional election string.
static String REGIONAL_FILE_NAME
          Regional results file name.
static String SERIALISED_FILE_EXT
          Serialised files file extension
static Font SMALL_FONT
          Small canvas font.
static Color TABLE_ROW_SELECT
          The colour of a selected table row.
static Font TITLE_FONT
          The canvas title font.
static int UNCONTESTED
          The number of votes assigned to an uncontested seat.
static int WARN
          Message severity Warning.
 
Constructor Summary
Misc()
           
 
Method Summary
static Date getDateFromDbString(String text)
          Convert database date string to a Java Date.
static Date getDateFromString(String text)
          Convert simple date string to a Java Date.
static String getDbProtocol()
          Convert system properties into the JDBC protocol.
static Color getElectionColour(String election)
          Get the colour of a for an election type.
static String getFormattedDate(Date date)
          Convert a Java Date into a simple string.
static String getFormattedDate(Date date, String pattern)
          Convert a Java Date into a simple string with the given pattern.
static int getIntFromStdInput()
          Get an integer from standard input.
static String getShortYear(Date date)
          Remove the first two character of the year.
static String getStringFromStdInput()
          Get a String from standard input.
static String getWholeYear(Date date)
          Get the four digits year from a Date object.
static void initialise(IMessageHandling logger)
          Set up message logging capability.
static void logError(String message)
          Log error message.
static void logMessage(int level, String message)
          Log a messge with severity.
static void logMessage(String message)
          Log information message.
 void logToFile(String message)
          Log a message to file.
static void logWarning(String message)
          Log warning message.
static void printTitle()
          Print the title message to standard output.
static void showError(Component comp, String message)
          Popup an error dialog box.
static void showError(String message)
          Popup an error dialog box.
static void showMessage(Component comp, String message)
          Popup a message dialog box.
static void showMessage(String message)
          Popup a message dialog box.
static void toStdErr(String message)
          Print message to standard error stream.
static void toStdOut(String message)
          Print a message to the standard output.
static void toStdOut(String message, boolean printLine)
          Print a message to the standard output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GSWING_VERSION

public static final String GSWING_VERSION
Current gswing version.

See Also:
Constant Field Values

TITLE_FONT

public static final Font TITLE_FONT
The canvas title font.


NORMAL_FONT

public static final Font NORMAL_FONT
Normal canvas font.


SMALL_FONT

public static final Font SMALL_FONT
Small canvas font.


TABLE_ROW_SELECT

public static final Color TABLE_ROW_SELECT
The colour of a selected table row.


APPLET_BACKGROUND

public static final Color APPLET_BACKGROUND
The applet background colour.


NATIONAL

public static final String NATIONAL
National election string.

See Also:
Constant Field Values

REGIONAL

public static final String REGIONAL
Regional election string.

See Also:
Constant Field Values

GENERAL

public static final String GENERAL
General election string.

See Also:
Constant Field Values

DEVOLVED

public static final String DEVOLVED
Devolved election string.

See Also:
Constant Field Values

CONSTITUENCY

public static final String CONSTITUENCY
Constituency election string.

See Also:
Constant Field Values

DEV_BY_ELEC

public static final String DEV_BY_ELEC
Devolved by-election string.

See Also:
Constant Field Values

GEN_BY_ELEC

public static final String GEN_BY_ELEC
General by-election string.

See Also:
Constant Field Values

COUNCIL

public static final String COUNCIL
Council election string.

See Also:
Constant Field Values

LOCAL

public static final String LOCAL
Local election string.

See Also:
Constant Field Values

NONE_DEFINED

public static final String NONE_DEFINED
none defined const.

See Also:
Constant Field Values

FPTP_STR

public static final String FPTP_STR
First past the post electoral system string.

See Also:
Constant Field Values

LIST_STR

public static final String LIST_STR
List electoral system string.

See Also:
Constant Field Values

FPTP

public static final int FPTP
First past the post electoral system string.

See Also:
Constant Field Values

LIST

public static final int LIST
List electoral system string.

See Also:
Constant Field Values

UNCONTESTED

public static final int UNCONTESTED
The number of votes assigned to an uncontested seat.

See Also:
Constant Field Values

PREVIOUS

public static final int PREVIOUS
Previous const.

See Also:
Constant Field Values

NEXT

public static final int NEXT
Next const.

See Also:
Constant Field Values

INVALID

public static final int INVALID
Invalid const.

See Also:
Constant Field Values

INFO

public static final int INFO
Message severity Information

See Also:
Constant Field Values

WARN

public static final int WARN
Message severity Warning.

See Also:
Constant Field Values

ERROR

public static final int ERROR
Message severity Error.

See Also:
Constant Field Values

REGIONAL_FILE_NAME

public static final String REGIONAL_FILE_NAME
Regional results file name.

See Also:
Constant Field Values

LOCAL_FILE_NAME_ENDING

public static final String LOCAL_FILE_NAME_ENDING
Local results file name ending.

See Also:
Constant Field Values

NEW_LINE

public static final String NEW_LINE
platform independant new line string.


CONST_LABEL

public static final JLabel CONST_LABEL
constituency label


REGION_LABEL

public static final JLabel REGION_LABEL
region label


COUNCIL_LABEL

public static final JLabel COUNCIL_LABEL
council label


LOCAL_LABEL

public static final JLabel LOCAL_LABEL
local label


SERIALISED_FILE_EXT

public static final String SERIALISED_FILE_EXT
Serialised files file extension

See Also:
Constant Field Values
Constructor Detail

Misc

public Misc()
Method Detail

initialise

public static void initialise(IMessageHandling logger)
Set up message logging capability.

Parameters:
logger - Framework message handler.

getDateFromDbString

public static Date getDateFromDbString(String text)
Convert database date string to a Java Date.

Parameters:
text - A date string.
Returns:
The Java Date object.

getDateFromString

public static Date getDateFromString(String text)
Convert simple date string to a Java Date.

Parameters:
text - A date string.
Returns:
The Java Date object.

getFormattedDate

public static String getFormattedDate(Date date)
Convert a Java Date into a simple string.

Parameters:
date - The Java Date object.
Returns:
The string representation.

getFormattedDate

public static String getFormattedDate(Date date,
                                      String pattern)
Convert a Java Date into a simple string with the given pattern.

Parameters:
date - The Java Date object.
pattern - The date pattern.
Returns:
The string representation.

showError

public static void showError(String message)
Popup an error dialog box.

Parameters:
message - The message to display.

showError

public static void showError(Component comp,
                             String message)
Popup an error dialog box.

Parameters:
comp - The parent conmponent.
message - The message to display.

showMessage

public static void showMessage(String message)
Popup a message dialog box.

Parameters:
message - The message to display.

showMessage

public static void showMessage(Component comp,
                               String message)
Popup a message dialog box.

Parameters:
comp - The parent conmponent.
message - The message to display.

logToFile

public void logToFile(String message)
Log a message to file. If there is no message handler simply print to standard out.

Parameters:
message - The message to log.

getDbProtocol

public static String getDbProtocol()
Convert system properties into the JDBC protocol.

Returns:
The JDBC protocol.

getShortYear

public static String getShortYear(Date date)
Remove the first two character of the year. Eg 2004 = 04 and 1999 = 99.

Parameters:
date - The date to perform on.
Returns:
A two digit year string.

getWholeYear

public static String getWholeYear(Date date)
Get the four digits year from a Date object.

Parameters:
date - The date to perform on.
Returns:
A four digit year string.

getElectionColour

public static Color getElectionColour(String election)
Get the colour of a for an election type. General = red, Devolved = red, and by-election = yellow.

Parameters:
election - The election data.
Returns:
The election colour.

toStdOut

public static void toStdOut(String message)
Print a message to the standard output.

Parameters:
message - The message to print.

toStdErr

public static void toStdErr(String message)
Print message to standard error stream.

Parameters:
message - The message to print.

toStdOut

public static void toStdOut(String message,
                            boolean printLine)
Print a message to the standard output.

Parameters:
message - The message to print.
printLine - Should the message be printed as a line?

logMessage

public static void logMessage(int level,
                              String message)
Log a messge with severity. If a message handler is available use it otherwise write to stdout / stderr.

Parameters:
level - The serverity level - INFO, WARN or ERROR.
message - The message to log.

logMessage

public static void logMessage(String message)
Log information message.

Parameters:
message - The message to log.

logWarning

public static void logWarning(String message)
Log warning message.

Parameters:
message - The warning to log.

logError

public static void logError(String message)
Log error message.

Parameters:
message - The error to log.

printTitle

public static void printTitle()
Print the title message to standard output.


getIntFromStdInput

public static int getIntFromStdInput()
Get an integer from standard input.

Returns:
The integer the user has input.

getStringFromStdInput

public static String getStringFromStdInput()
Get a String from standard input.

Returns:
The string the user has input.


Copyright © 2008. All Rights Reserved.