Package org.codehaus.mojo.javacc
Class JTB
java.lang.Object
org.codehaus.mojo.javacc.ToolFacade
org.codehaus.mojo.javacc.JTB
Provides a facade for the mojos to invoke JTB.
- Version:
- $Id$
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) class
Consume and log command line output from the JJDoc process. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Boolean
The option "-f".private File
The input grammar.private Boolean
The option "-jd".private File
The output directory for the syntax tree files.private String
The option "-np".private String
The option "-ns".private File
The base directory for the option "-o".private String
The option "-p".private Boolean
The option "-pp".private Boolean
The toolkit option "-printer".private Boolean
The toolkit option "-scheme".private Boolean
The option "-tk".private Boolean
The option "-e".private static final String
The default package name for syntax tree files.private static final String
The default package name for visitor files.private File
The output directory for the visitor files.private String
The option "-vp". -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected int
execute()
Runs the tool using the previously set parameters.private String[]
Assembles the command line arguments for the invocation of JTB according to the configuration.private File
Gets the absolute path to the output directory for the syntax tree files.private String
Gets the effective package name for the syntax tree files.private File
Gets the absolute path to the output directory for the visitor files.private String
Gets the effective package name for the visitor files.private String
getLastPackageName
(String name) Gets the last identifier from the specified package name.Gets the absolute path to the enhanced grammar file generated by JTB.private void
moveDirectory
(File sourceDir, File targetDir) Moves all Java files generated by JTB from the specified source directory to the given target directory.private void
Moves the previously generated Java files to their proper target directories.void
setDescriptiveFieldNames
(Boolean value) Sets the option "-f".void
setInputFile
(File value) Sets the absolute path to the grammar file to pass into JTB for preprocessing.void
Sets the option "-jd".void
setNodeDirectory
(File value) Sets the absolute path to the output directory for the syntax tree files.void
setNodePackageName
(String value) Sets the option "-np".void
setNodeParentClass
(String value) Sets the option "-ns".void
setOutputDirectory
(File value) Sets the absolute path to the output directory for the generated grammar file.void
setPackageName
(String value) Sets the option "-p".void
setParentPointers
(Boolean value) Sets the option "-pp".void
setPrinter
(Boolean value) Sets the toolkit option "-printer".void
Sets the toolkit option "-scheme".void
setSpecialTokens
(Boolean value) Sets the option "-tk".void
setSupressErrorChecking
(Boolean value) Sets the option "-e".void
setVisitorDirectory
(File value) Sets the absolute path to the output directory for the visitor files.void
setVisitorPackageName
(String value) Sets the option "-vp".toString()
Gets a string representation of the command line arguments.Methods inherited from class org.codehaus.mojo.javacc.ToolFacade
getLog, getToolName, run, setLog
-
Field Details
-
SYNTAX_TREE
The default package name for syntax tree files.- See Also:
-
VISITOR
The default package name for visitor files.- See Also:
-
inputFile
The input grammar. -
outputDirectory
The base directory for the option "-o". -
nodeDirectory
The output directory for the syntax tree files. -
visitorDirectory
The output directory for the visitor files. -
packageName
The option "-p". -
nodePackageName
The option "-np". -
visitorPackageName
The option "-vp". -
supressErrorChecking
The option "-e". -
javadocFriendlyComments
The option "-jd". -
descriptiveFieldNames
The option "-f". -
nodeParentClass
The option "-ns". -
parentPointers
The option "-pp". -
specialTokens
The option "-tk". -
scheme
The toolkit option "-scheme". -
printer
The toolkit option "-printer".
-
-
Constructor Details
-
JTB
JTB()
-
-
Method Details
-
setInputFile
Sets the absolute path to the grammar file to pass into JTB for preprocessing.- Parameters:
value
- The absolute path to the grammar file to pass into JTB for preprocessing.
-
setOutputDirectory
Sets the absolute path to the output directory for the generated grammar file.- Parameters:
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.
-
getOutputFile
Gets the absolute path to the enhanced grammar file generated by JTB.- Returns:
- The absolute path to the enhanced grammar file generated by JTB or
null
if either the input file or the output directory have not been set.
-
setNodeDirectory
Sets the absolute path to the output directory for the syntax tree files.- Parameters:
value
- The absolute path to the output directory for the generated syntax tree files, may benull
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.
-
getEffectiveNodeDirectory
Gets the absolute path to the output directory for the syntax tree files.- Returns:
- The absolute path to the output directory for the syntax tree files, only
null
if neitheroutputDirectory
nornodeDirectory
have been set.
-
setVisitorDirectory
Sets the absolute path to the output directory for the visitor files.- Parameters:
value
- The absolute path to the output directory for the generated visitor files, may benull
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.
-
getEffectiveVisitorDirectory
Gets the absolute path to the output directory for the visitor files.- Returns:
- The absolute path to the output directory for the visitor, only
null
if neitheroutputDirectory
norvisitorDirectory
have been set.
-
setPackageName
Sets the option "-p". Will overwrite the options "-np" and "-vp" if specified.- Parameters:
value
- The option value, may benull
.
-
setNodePackageName
Sets the option "-np".- Parameters:
value
- The option value, may benull
.
-
getEffectiveNodePackageName
Gets the effective package name for the syntax tree files.- Returns:
- The effective package name for the syntax tree files, never
null
.
-
setVisitorPackageName
Sets the option "-vp".- Parameters:
value
- The option value, may benull
.
-
getEffectiveVisitorPackageName
Gets the effective package name for the visitor files.- Returns:
- The effective package name for the visitor files, never
null
.
-
setSupressErrorChecking
Sets the option "-e".- Parameters:
value
- The option value, may benull
.
-
setJavadocFriendlyComments
Sets the option "-jd".- Parameters:
value
- The option value, may benull
.
-
setDescriptiveFieldNames
Sets the option "-f".- Parameters:
value
- The option value, may benull
.
-
setNodeParentClass
Sets the option "-ns".- Parameters:
value
- The option value, may benull
.
-
setParentPointers
Sets the option "-pp".- Parameters:
value
- The option value, may benull
.
-
setSpecialTokens
Sets the option "-tk".- Parameters:
value
- The option value, may benull
.
-
setScheme
Sets the toolkit option "-scheme".- Parameters:
value
- The option value, may benull
.
-
setPrinter
Sets the toolkit option "-printer".- Parameters:
value
- The option value, may benull
.
-
execute
Runs the tool using the previously set parameters.- Specified by:
execute
in classToolFacade
- Returns:
- The exit code of the tool, non-zero means failure.
- Throws:
Exception
- If the tool could not be invoked.
-
generateArguments
Assembles the command line arguments for the invocation of JTB according to the configuration.- Returns:
- A string array that represents the command line arguments to use for JTB.
-
getLastPackageName
Gets the last identifier from the specified package name. For example, returns "apache" upon input of "org.apache". JTB uses this approach to derive the output directories for the visitor and syntax tree files.- Parameters:
name
- The package name from which to retrieve the last sub package, may benull
.- Returns:
- The name of the last sub package or
null
if the input wasnull
-
moveJavaFiles
Moves the previously generated Java files to their proper target directories. JTB simply assumes that the current working directory represents the parent package of the configured node/visitor packages which does not meet our needs.- Throws:
IOException
- If the move failed.
-
moveDirectory
Moves all Java files generated by JTB from the specified source directory to the given target directory. Existing files in the target directory will be overwritten. Note that this move assumes a flat source directory, i.e. copying of sub directories is not supported.
This method must be used instead ofFile.renameTo(java.io.File)
which would fail if the target directory already existed (at least on Windows).- Parameters:
sourceDir
- The absolute path to the source directory, must not benull
.targetDir
- The absolute path to the target directory, must not benull
.- Throws:
IOException
- If the move failed.
-
toString
Gets a string representation of the command line arguments.
-