support143
Class DriverHelper

java.lang.Object
  |
  +--support143.DriverHelper
Direct Known Subclasses:
DriverHelper2

public abstract class DriverHelper
extends java.lang.Object

Base class driver. Gets us out of static land into happy land. Supports primitive argument processing, which includes boolean flags and untagged strings. Clients should extend this class for more specialized processing.


Field Summary
protected  java.lang.String[] debugCmd
           
protected  java.lang.String[] helpCmd
           
 
Constructor Summary
DriverHelper(java.lang.String name)
          Sole constructor.
 
Method Summary
protected  void addArgumentAndHelp(java.lang.String[] cmd)
          Adds a pair [argument, help] to the argument processor.
protected  Args createArguments(java.lang.String name, java.lang.String[] args)
          Creates the appropriate argument processor.
protected abstract  void defineArguments()
          Primes argument processor with expected arguments.
protected  void defineBasicArguments()
          Defines common (basic) arguments generally available to all programs.
protected  void exit(int exitValue)
          Terminates the program with given exit value.
protected  void exit(int exitValue, java.lang.String helpMsg)
          Terminates the program with given exit after dumping help messages.
 Args getArguments()
          Gets the Args associated with this driver.
 void go(java.lang.String[] args)
          Starts the system.
protected abstract  void initialize()
          Starts phase 2 of system.
protected  boolean isArgumentPresent(java.lang.String[] cmd)
          Checks if a given argument is present in the parsed arguments.
protected  boolean needDebug()
          Checks if debug is requested.
protected  boolean needHelp()
          Checks if help is requested.
protected abstract  void process()
          Starts phase 3.
protected  void setup(java.lang.String[] args)
          Starts phase 1 of the system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

helpCmd

protected java.lang.String[] helpCmd

debugCmd

protected java.lang.String[] debugCmd
Constructor Detail

DriverHelper

public DriverHelper(java.lang.String name)
Sole constructor.

Parameters:
name - of program
Method Detail

go

public void go(java.lang.String[] args)
Starts the system.

Parameters:
args - command line (presumably) arguments

getArguments

public Args getArguments()
Gets the Args associated with this driver.

Returns:
instance of appropriate argument class.

setup

protected void setup(java.lang.String[] args)
Starts phase 1 of the system.

Parameters:
args - (presumably) command line arguments

createArguments

protected Args createArguments(java.lang.String name,
                               java.lang.String[] args)
Creates the appropriate argument processor. Subtypes may override this for richer argument processing.

Parameters:
name - to give argument processor.
args - command line arguments

initialize

protected abstract void initialize()
Starts phase 2 of system.


process

protected abstract void process()
Starts phase 3.


defineArguments

protected abstract void defineArguments()
Primes argument processor with expected arguments.


addArgumentAndHelp

protected void addArgumentAndHelp(java.lang.String[] cmd)
Adds a pair [argument, help] to the argument processor. NOTE: This method should really be part of the basic Args class.

Parameters:
cmd - array of arg and help msg.

isArgumentPresent

protected boolean isArgumentPresent(java.lang.String[] cmd)
Checks if a given argument is present in the parsed arguments. This is really a helper function to simplify argument construction. NOTE: This method should really be part of the basic Args class.

Parameters:
cmd - array of given argument and incidental help message.

needHelp

protected boolean needHelp()
Checks if help is requested. NOTE: This method should really be part of the basic Args class.

Returns:
true if true, false otherwise.

needDebug

protected boolean needDebug()
Checks if debug is requested. NOTE: This method should really be part of the basic Args class.

Returns:
true if true, false otherwise.

defineBasicArguments

protected void defineBasicArguments()
Defines common (basic) arguments generally available to all programs.


exit

protected void exit(int exitValue,
                    java.lang.String helpMsg)
Terminates the program with given exit after dumping help messages.

Parameters:
exitValue - reason for exit (passed to OS)
helpMsg - extra message to print along with help.

exit

protected void exit(int exitValue)
Terminates the program with given exit value.

Parameters:
exitValue - reason for exit.