Class JTB
java.lang.Object
org.codehaus.mojo.javacc.ToolFacade
org.codehaus.mojo.javacc.JTB
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) classConsume and log command line output from the JJDoc process. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BooleanThe option "-f".private FileThe input grammar.private BooleanThe option "-jd".private FileThe output directory for the syntax tree files.private StringThe option "-np".private StringThe option "-ns".private FileThe base directory for the option "-o".private StringThe option "-p".private BooleanThe option "-pp".private BooleanThe toolkit option "-printer".private BooleanThe toolkit option "-scheme".private BooleanThe option "-tk".private BooleanThe option "-e".private static final StringThe default package name for syntax tree files.private static final StringThe default package name for visitor files.private FileThe output directory for the visitor files.private StringThe option "-vp". -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intexecute()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 FileGets the absolute path to the output directory for the syntax tree files.private StringGets the effective package name for the syntax tree files.private FileGets the absolute path to the output directory for the visitor files.private StringGets the effective package name for the visitor files.private StringgetLastPackageName(String name) Gets the last identifier from the specified package name.Gets the absolute path to the enhanced grammar file generated by JTB.private voidmoveDirectory(File sourceDir, File targetDir) Moves all Java files generated by JTB from the specified source directory to the given target directory.private voidMoves the previously generated Java files to their proper target directories.voidsetDescriptiveFieldNames(Boolean value) Sets the option "-f".voidsetInputFile(File value) Sets the absolute path to the grammar file to pass into JTB for preprocessing.voidSets the option "-jd".voidsetNodeDirectory(File value) Sets the absolute path to the output directory for the syntax tree files.voidsetNodePackageName(String value) Sets the option "-np".voidsetNodeParentClass(String value) Sets the option "-ns".voidsetOutputDirectory(File value) Sets the absolute path to the output directory for the generated grammar file.voidsetPackageName(String value) Sets the option "-p".voidsetParentPointers(Boolean value) Sets the option "-pp".voidsetPrinter(Boolean value) Sets the toolkit option "-printer".voidSets the toolkit option "-scheme".voidsetSpecialTokens(Boolean value) Sets the option "-tk".voidsetSupressErrorChecking(Boolean value) Sets the option "-e".voidsetVisitorDirectory(File value) Sets the absolute path to the output directory for the visitor files.voidsetVisitorPackageName(String value) Sets the option "-vp".toString()Gets a string representation of the command line arguments.Methods inherited from class ToolFacade
getLog, getToolName, run, setLog
-
Field Details
-
SYNTAX_TREE
-
VISITOR
-
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
nullif 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 benullto 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
nullif neitheroutputDirectorynornodeDirectoryhave 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 benullto 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
nullif neitheroutputDirectorynorvisitorDirectoryhave 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:
executein 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
nullif 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
-