public abstract class Tool
extends java.lang.Object
| Constructor and Description |
|---|
Tool()
Create a new tool.
|
| Modifier and Type | Method and Description |
|---|---|
void |
diagnose()
Print tool diagnostics.
|
java.lang.String |
getCopy()
Get this tool's copyright.
|
java.lang.String |
getExplanation()
Get this tool's explanation.
|
abstract java.lang.String |
getName()
Get this tool's name.
|
java.lang.String |
getVersion()
Get this tool's version.
|
void |
init()
Initialize this tool.
|
java.io.File |
locate(java.lang.String name)
Locate the file with the specified name.
|
abstract Node |
parse(java.io.Reader in,
java.io.File file)
Parse the specified file.
|
void |
prepare()
Prepare for processing.
|
void |
printHeader(Printer printer)
Print a tool header to the specified printer.
|
void |
process(Node node)
Process the specified AST node.
|
void |
process(java.lang.String name)
Recursively process the file with the specified name.
|
void |
run(java.lang.String[] args)
Run this tool with the specified command line arguments.
|
void |
wrapUp()
Wrap up this tool.
|
protected final Runtime runtime
public abstract java.lang.String getName()
public java.lang.String getVersion()
Constants.VERSION.public java.lang.String getCopy()
Constants.FULL_COPY.public java.lang.String getExplanation()
null to indicate that there is no explanation.public void init()
optionSilent for silent
operation,optionVerbose for verbose
operation,optionNoExit for not exiting
the Java virtual machine,Runtime.INPUT_DIRECTORY
for the file search path,Runtime.OUTPUT_DIRECTORY for the
output directory,Runtime.INPUT_ENCODING for the
character encoding when reading files,Runtime.OUTPUT_ENCODING for the
character encoding when writing files,optionDiagnostics for printing
tool diagnostics,optionPerformance for
collecting performance statistics,optionMeasureParser for
measuring parser performance only.optionMeasureProcessing for
measuring processing performance only.optionGC for performing
GC,runsWarmUp with a default of 2
for the number of warm-up runs,runsTotal with a default
of 12 for the total number of runs.public void prepare()
Runtime.initDefaultValues(). It
also checks that the optionSilent and
optionVerbose flags are not both set at the same
time.wrapUp()public void diagnose()
public java.io.File locate(java.lang.String name)
throws java.io.IOException
name - The file name.java.lang.IllegalArgumentException - Signals an inappropriate file
(e.g., one that is too large).java.io.IOException - Signals an I/O error.Runtime.locate(String)public abstract Node parse(java.io.Reader in, java.io.File file) throws java.io.IOException, ParseException
in - The input stream for the file.file - The corresponding file.null if no tree has been generated.java.lang.IllegalArgumentException - Signals an inappropriate file
(e.g., one that is too large).java.io.IOException - Signals an I/O error.ParseException - Signals a parse error.public void process(Node node)
parse(Reader,File) has completed successfuly, has
returned a node (and not null), and no errors have
been reported through Runtime.error(), Runtime.error(String), or Runtime.error(String,Node)
while parsing. The default implementation of this method does
nothing.node - The node.public void process(java.lang.String name)
throws java.io.IOException,
ParseException
locates the specified file, opens
it, parses it, closes it, and then
processes the resulting AST node.name - The file name.java.lang.IllegalArgumentException - Signals an inappropriate file
(e.g., one that is too large).java.io.FileNotFoundException - Signals that the file was not
found.java.io.IOException - Signals an I/O error while accessing the
file.ParseException - Signals a parse error.VisitingException - Signals an error while visiting a node.public void printHeader(Printer printer)
printer - The printer.public void wrapUp()
public void run(java.lang.String[] args)
init() to initialize this tool.name, version, and copyright to the console.options and, optionally, an explanation. It then exits.processes the specified
command line arguments and prepares for
processing the files. If any errors have been reported during the two method calls, it
exits.locates the file, parses the contents, and processes the
resulting AST. If the -performance command line
option has been specified, it repeatedly parses and processes
each file, measuring both latency and heap utilization. It then
exits.args - The command line arguments.Copyright © 2014. All Rights Reserved.