Package org.codehaus.mojo.javacc
Class GrammarDirectoryScanner
java.lang.Object
org.codehaus.mojo.javacc.GrammarDirectoryScanner
- Direct Known Subclasses:
LegacyGrammarDirectoryScanner
Scans source directories for JavaCC grammar files.
- Version:
- $Id$
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ListA set of grammar infos describing the included grammar files, must never benull.private FileThe absolute path to the output directory used to detect stale target files by timestamp checking, may benullif no stale detection should be performed.private StringThe package name for the generated parser, may benullto use the package declaration from the grammar file.private org.codehaus.plexus.util.DirectoryScannerThe directory scanner used to scan the source directory for files.private intThe granularity in milliseconds of the last modification date for testing whether a grammar file needs recompilation because its corresponding target file is stale. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the grammar files that were included by the scanner during the last invocation ofscan().protected File[]getTargetFiles(File targetDirectory, String grammarFile, GrammarInfo grammarInfo) Determines the output files corresponding to the specified grammar file.voidscan()Scans the source directory for grammar files that match at least one inclusion pattern but no exclusion pattern, optionally performing timestamp checking to exclude grammars whose corresponding parser files are up to date.voidsetExcludes(String[] excludes) Sets the Ant-like exclusion patterns.voidsetIncludes(String[] includes) Sets the Ant-like inclusion patterns.voidsetOutputDirectory(File directory) Sets the absolute path to the output directory used to detect stale target files.voidsetParserPackage(String packageName) Sets the package name for the generated parser.voidsetSourceDirectory(File directory) Sets the absolute path to the source directory to scan for grammar files.voidsetStaleMillis(int milliseconds) Sets the granularity in milliseconds of the last modification date for stale file detection.
-
Field Details
-
scanner
private org.codehaus.plexus.util.DirectoryScanner scannerThe directory scanner used to scan the source directory for files. -
outputDirectory
The absolute path to the output directory used to detect stale target files by timestamp checking, may benullif no stale detection should be performed. -
parserPackage
The package name for the generated parser, may benullto use the package declaration from the grammar file. -
staleMillis
private int staleMillisThe granularity in milliseconds of the last modification date for testing whether a grammar file needs recompilation because its corresponding target file is stale. -
includedGrammars
A set of grammar infos describing the included grammar files, must never benull.
-
-
Constructor Details
-
GrammarDirectoryScanner
public GrammarDirectoryScanner()Creates a new grammar directory scanner.
-
-
Method Details
-
setSourceDirectory
Sets the absolute path to the source directory to scan for grammar files. This directory must exist or the scanner will report an error.- Parameters:
directory- The absolute path to the source directory to scan, must not benull.
-
setParserPackage
Sets the package name for the generated parser.- Parameters:
packageName- The package name for the generated parser, may benullto use the package declaration from the grammar file.
-
setIncludes
Sets the Ant-like inclusion patterns.- Parameters:
includes- The set of Ant-like inclusion patterns, may benullto include all files.
-
setExcludes
Sets the Ant-like exclusion patterns.- Parameters:
excludes- The set of Ant-like exclusion patterns, may benullto exclude no files.
-
setOutputDirectory
Sets the absolute path to the output directory used to detect stale target files.- Parameters:
directory- The absolute path to the output directory used to detect stale target files by timestamp checking, may benullif no stale detection should be performed.
-
setStaleMillis
public void setStaleMillis(int milliseconds) Sets the granularity in milliseconds of the last modification date for stale file detection.- Parameters:
milliseconds- The granularity in milliseconds of the last modification date for testing whether a grammar file needs recompilation because its corresponding target file is stale.
-
scan
Scans the source directory for grammar files that match at least one inclusion pattern but no exclusion pattern, optionally performing timestamp checking to exclude grammars whose corresponding parser files are up to date.- Throws:
IOException- If a grammar file could not be analyzed for metadata.
-
getTargetFiles
Determines the output files corresponding to the specified grammar file.- Parameters:
targetDirectory- The absolute path to the output directory for the target files, must not benull.grammarFile- The path to the grammar file, relative to the scanned source directory, must not benull.grammarInfo- The grammar info describing the grammar file, must not benull- Returns:
- A file array with target files, never
null.
-
getIncludedGrammars
Gets the grammar files that were included by the scanner during the last invocation ofscan().- Returns:
- An array of grammar infos describing the included grammar files, will be empty if no files were included
but is never
null.
-