org.dellroad.jvser.client
Class MainClass

java.lang.Object
  extended by org.dellroad.jvser.client.MainClass
Direct Known Subclasses:
Main

public abstract class MainClass
extends Object

Support superclass for command line classes.


Field Summary
protected  Logger log
           
 
Constructor Summary
protected MainClass()
           
 
Method Summary
protected  void doMain(String[] args)
          Invokes run(java.lang.String[]), catching any exceptions thrown and exiting with a non-zero value if and only if an exception was caught.
protected  void errout(String message)
          Emit an error message an exit with exit value 1.
protected abstract  int run(String[] args)
          Subclass main implementation.
protected  void setupLogging(Level logLevel)
          Setup logging.
protected  void usageError()
          Print the usage message and exit with exit value 1.
protected abstract  void usageMessage()
          Display the usage message to standard error.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final Logger log
Constructor Detail

MainClass

protected MainClass()
Method Detail

run

protected abstract int run(String[] args)
                    throws Exception
Subclass main implementation. This method is free to throw exceptions; these will be displayed on standard error and converted into non-zero exit values.

Returns:
exit value
Throws:
Exception

usageMessage

protected abstract void usageMessage()
Display the usage message to standard error.


usageError

protected void usageError()
Print the usage message and exit with exit value 1.


setupLogging

protected void setupLogging(Level logLevel)
Setup logging.


errout

protected final void errout(String message)
Emit an error message an exit with exit value 1.


doMain

protected void doMain(String[] args)
Invokes run(java.lang.String[]), catching any exceptions thrown and exiting with a non-zero value if and only if an exception was caught.

The concrete class' main() method should invoke this method.