class JTB extends ToolFacade
Modifier and Type | Class and Description |
---|---|
(package private) class |
JTB.MojoLogStreamConsumer
Consume and log command line output from the JJDoc process.
|
Modifier and Type | Field and Description |
---|---|
private java.lang.Boolean |
descriptiveFieldNames
The option "-f".
|
private java.io.File |
inputFile
The input grammar.
|
private java.lang.Boolean |
javadocFriendlyComments
The option "-jd".
|
private java.io.File |
nodeDirectory
The output directory for the syntax tree files.
|
private java.lang.String |
nodePackageName
The option "-np".
|
private java.lang.String |
nodeParentClass
The option "-ns".
|
private java.io.File |
outputDirectory
The base directory for the option "-o".
|
private java.lang.String |
packageName
The option "-p".
|
private java.lang.Boolean |
parentPointers
The option "-pp".
|
private java.lang.Boolean |
printer
The toolkit option "-printer".
|
private java.lang.Boolean |
scheme
The toolkit option "-scheme".
|
private java.lang.Boolean |
specialTokens
The option "-tk".
|
private java.lang.Boolean |
supressErrorChecking
The option "-e".
|
private static java.lang.String |
SYNTAX_TREE
The default package name for syntax tree files.
|
private static java.lang.String |
VISITOR
The default package name for visitor files.
|
private java.io.File |
visitorDirectory
The output directory for the visitor files.
|
private java.lang.String |
visitorPackageName
The option "-vp".
|
Constructor and Description |
---|
JTB() |
Modifier and Type | Method and Description |
---|---|
protected int |
execute()
Runs the tool using the previously set parameters.
|
private java.lang.String[] |
generateArguments()
Assembles the command line arguments for the invocation of JTB according to the configuration.
|
private java.io.File |
getEffectiveNodeDirectory()
Gets the absolute path to the output directory for the syntax tree files.
|
private java.lang.String |
getEffectiveNodePackageName()
Gets the effective package name for the syntax tree files.
|
private java.io.File |
getEffectiveVisitorDirectory()
Gets the absolute path to the output directory for the visitor files.
|
private java.lang.String |
getEffectiveVisitorPackageName()
Gets the effective package name for the visitor files.
|
private java.lang.String |
getLastPackageName(java.lang.String name)
Gets the last identifier from the specified package name.
|
java.io.File |
getOutputFile()
Gets the absolute path to the enhanced grammar file generated by JTB.
|
private void |
moveDirectory(java.io.File sourceDir,
java.io.File targetDir)
Moves all Java files generated by JTB from the specified source directory to the given target directory.
|
private void |
moveJavaFiles()
Moves the previously generated Java files to their proper target directories.
|
void |
setDescriptiveFieldNames(java.lang.Boolean value)
Sets the option "-f".
|
void |
setInputFile(java.io.File value)
Sets the absolute path to the grammar file to pass into JTB for preprocessing.
|
void |
setJavadocFriendlyComments(java.lang.Boolean value)
Sets the option "-jd".
|
void |
setNodeDirectory(java.io.File value)
Sets the absolute path to the output directory for the syntax tree files.
|
void |
setNodePackageName(java.lang.String value)
Sets the option "-np".
|
void |
setNodeParentClass(java.lang.String value)
Sets the option "-ns".
|
void |
setOutputDirectory(java.io.File value)
Sets the absolute path to the output directory for the generated grammar file.
|
void |
setPackageName(java.lang.String value)
Sets the option "-p".
|
void |
setParentPointers(java.lang.Boolean value)
Sets the option "-pp".
|
void |
setPrinter(java.lang.Boolean value)
Sets the toolkit option "-printer".
|
void |
setScheme(java.lang.Boolean value)
Sets the toolkit option "-scheme".
|
void |
setSpecialTokens(java.lang.Boolean value)
Sets the option "-tk".
|
void |
setSupressErrorChecking(java.lang.Boolean value)
Sets the option "-e".
|
void |
setVisitorDirectory(java.io.File value)
Sets the absolute path to the output directory for the visitor files.
|
void |
setVisitorPackageName(java.lang.String value)
Sets the option "-vp".
|
java.lang.String |
toString()
Gets a string representation of the command line arguments.
|
getLog, getToolName, run, setLog
private static final java.lang.String SYNTAX_TREE
private static final java.lang.String VISITOR
private java.io.File inputFile
private java.io.File outputDirectory
private java.io.File nodeDirectory
private java.io.File visitorDirectory
private java.lang.String packageName
private java.lang.String nodePackageName
private java.lang.String visitorPackageName
private java.lang.Boolean supressErrorChecking
private java.lang.Boolean javadocFriendlyComments
private java.lang.Boolean descriptiveFieldNames
private java.lang.String nodeParentClass
private java.lang.Boolean parentPointers
private java.lang.Boolean specialTokens
private java.lang.Boolean scheme
private java.lang.Boolean printer
public void setInputFile(java.io.File value)
value
- The absolute path to the grammar file to pass into JTB for preprocessing.public void setOutputDirectory(java.io.File value)
value
- The absolute path to the output directory for the generated grammar file. If this directory does not
exist yet, it is created. Note that this path should already include the desired package hierarchy
because JTB will not append the required sub directories automatically.public java.io.File getOutputFile()
null
if either the
input file or the output directory have not been set.public void setNodeDirectory(java.io.File value)
value
- The absolute path to the output directory for the generated syntax tree files, may be
null
to use a sub directory in the output directory of the grammar file. If this
directory does not exist yet, it is created. Note that this path should already include the desired
package hierarchy because JTB will not append the required sub directories automatically.private java.io.File getEffectiveNodeDirectory()
null
if neither
outputDirectory
nor nodeDirectory
have been set.public void setVisitorDirectory(java.io.File value)
value
- The absolute path to the output directory for the generated visitor files, may be null
to use a sub directory in the output directory of the grammar file. If this directory does not exist
yet, it is created. Note that this path should already include the desired package hierarchy because
JTB will not append the required sub directories automatically.private java.io.File getEffectiveVisitorDirectory()
null
if neither
outputDirectory
nor visitorDirectory
have been set.public void setPackageName(java.lang.String value)
value
- The option value, may be null
.public void setNodePackageName(java.lang.String value)
value
- The option value, may be null
.private java.lang.String getEffectiveNodePackageName()
null
.public void setVisitorPackageName(java.lang.String value)
value
- The option value, may be null
.private java.lang.String getEffectiveVisitorPackageName()
null
.public void setSupressErrorChecking(java.lang.Boolean value)
value
- The option value, may be null
.public void setJavadocFriendlyComments(java.lang.Boolean value)
value
- The option value, may be null
.public void setDescriptiveFieldNames(java.lang.Boolean value)
value
- The option value, may be null
.public void setNodeParentClass(java.lang.String value)
value
- The option value, may be null
.public void setParentPointers(java.lang.Boolean value)
value
- The option value, may be null
.public void setSpecialTokens(java.lang.Boolean value)
value
- The option value, may be null
.public void setScheme(java.lang.Boolean value)
value
- The option value, may be null
.public void setPrinter(java.lang.Boolean value)
value
- The option value, may be null
.protected int execute() throws java.lang.Exception
execute
in class ToolFacade
java.lang.Exception
- If the tool could not be invoked.private java.lang.String[] generateArguments()
private java.lang.String getLastPackageName(java.lang.String name)
name
- The package name from which to retrieve the last sub package, may be null
.null
if the input was null
private void moveJavaFiles() throws java.io.IOException
java.io.IOException
- If the move failed.private void moveDirectory(java.io.File sourceDir, java.io.File targetDir) throws java.io.IOException
File.renameTo(java.io.File)
which would fail if the target directory already existed (at least on
Windows).sourceDir
- The absolute path to the source directory, must not be null
.targetDir
- The absolute path to the target directory, must not be null
.java.io.IOException
- If the move failed.public java.lang.String toString()
toString
in class java.lang.Object