ESC/Java2
© 2003,2004,2005 David Cok and Joseph Kiniry
© 2005 UCD Dublin
© 2003,2004 Radboud University Nijmegen
© 1999,2000 Compaq Computer Corporation
© 1997,1998,1999 Digital Equipment Corporation
All Rights Reserved

javafe
Class Tool

java.lang.Object
  extended byjavafe.Tool
Direct Known Subclasses:
FrontEndTool

public abstract class Tool
extends java.lang.Object

Tool is an abstract class for tools.

Tools are command-line applications invoked by calling their static main(String[]) method.


Field Summary
static int badUsageExitCode
           
static int errorExitCode
           
static int okExitCode
          Exit codes *
static Options options
          A statically held Options object.
static int outOfMemoryExitCode
           
private static java.lang.Runtime rt
           
 
Constructor Summary
Tool()
           
 
Method Summary
 void badOptionUsage(java.lang.Exception e)
           
static long currentTime()
           
static void main(java.lang.String[] args)
          Start up an instance of this tool using command-line arguments args.
abstract  java.lang.String name()
          Return the non-null name of this tool.
abstract  int run(java.lang.String[] args)
          A tool's main entry point; args are the command-line arguments we have been invoked with.
static java.lang.String spaceUsed()
           
static java.lang.String timeUsed(long startTime)
          Compute the time used from a start time to now, then return it in a user readable form.
 void usage()
          Print our usage message to System.err.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

okExitCode

public static final int okExitCode
Exit codes *

See Also:
Constant Field Values

badUsageExitCode

public static final int badUsageExitCode
See Also:
Constant Field Values

errorExitCode

public static final int errorExitCode
See Also:
Constant Field Values

outOfMemoryExitCode

public static final int outOfMemoryExitCode
See Also:
Constant Field Values

options

public static Options options
A statically held Options object. The object is static to facilitate using the options in other classes throughout the program. All processing and reporting of options is managed by this object.


rt

private static java.lang.Runtime rt
Constructor Detail

Tool

public Tool()
Method Detail

name

public abstract java.lang.String name()
Return the non-null name of this tool. E.g., "ls" or "cp". Used in usage and error messages.


usage

public void usage()
Print our usage message to System.err.


badOptionUsage

public void badOptionUsage(java.lang.Exception e)

main

public static void main(java.lang.String[] args)
Start up an instance of this tool using command-line arguments args.

Note: this code needs to be copied verbatim to each subclass of Tool except with the name of the actual subclass inserted after the new operator and the comment characters (//) removed.

(This needs to be done because static methods cannot be inherited.)


run

public abstract int run(java.lang.String[] args)
A tool's main entry point; args are the command-line arguments we have been invoked with.

Returns:
the exit code (0 = success, >0 is a failure)

timeUsed

public static java.lang.String timeUsed(long startTime)
Compute the time used from a start time to now, then return it in a user readable form.


currentTime

public static long currentTime()

spaceUsed

public static java.lang.String spaceUsed()

ESC/Java2
© 2003,2004,2005 David Cok and Joseph Kiniry
© 2005 UCD Dublin
© 2003,2004 Radboud University Nijmegen
© 1999,2000 Compaq Computer Corporation
© 1997,1998,1999 Digital Equipment Corporation
All Rights Reserved

The ESC/Java2 Project Homepage