com.mcdermottroe.exemplar.ui.cli
Class Main

java.lang.Object
  extended by com.mcdermottroe.exemplar.ui.cli.Main

public final class Main
extends Object

A class to provide a main entry point for the program.

Since:
0.1

Field Summary
private static ExitHandler exitHandler
          The exit handler.
private static Timer timer
          A timer for the application.
 
Constructor Summary
private Main()
          Private constructor to prevent instantiation of this class.
 
Method Summary
private static void abort(int code, CharSequence message)
          Shorthand for an unclean exit.
private static void cleanExit(CharSequence message)
          Shorthand for a clean exit.
static ExitHandler getExitHandler()
          Get the current ExitHandler.
static void main(String[] args)
          The main entry point for the program.
static void setExitHandler(ExitHandler handler)
          Set a new ExitHandler.
private static String usageMessage()
          Format a usage message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timer

private static Timer timer
A timer for the application.


exitHandler

private static ExitHandler exitHandler
The exit handler.

Constructor Detail

Main

private Main()
Private constructor to prevent instantiation of this class.

Method Detail

main

public static void main(String[] args)
The main entry point for the program.

Parameters:
args - The arguments passed to the program

usageMessage

private static String usageMessage()
Format a usage message.

Returns:
A String containing the usage message.

getExitHandler

public static ExitHandler getExitHandler()
Get the current ExitHandler.

Returns:
The current ExitHandler.

setExitHandler

public static void setExitHandler(ExitHandler handler)
Set a new ExitHandler.

Parameters:
handler - The new ExitHandler.

cleanExit

private static void cleanExit(CharSequence message)
Shorthand for a clean exit. The program will exit with the exit code corresponding to Constants.UI.CLI.EXIT_SUCCESS.

Parameters:
message - A message to send to the user. If this is null, nothing is sent.

abort

private static void abort(int code,
                          CharSequence message)
Shorthand for an unclean exit.

Parameters:
code - The value to pass to ExitHandler.exit(int).
message - An optional message to log (only logged if non-null).