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: GrammarDirectoryScanner.java 6282 2008-02-09 23:49:06Z bentmann $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List
A set of grammar infos describing the included grammar files, must never benull
.private File
The absolute path to the output directory used to detect stale target files by timestamp checking, may benull
if no stale detection should be performed.private String
The package name for the generated parser, may benull
to use the package declaration from the grammar file.private org.codehaus.plexus.util.DirectoryScanner
The directory scanner used to scan the source directory for files.private int
The 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.void
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.void
setExcludes
(String[] excludes) Sets the Ant-like exclusion patterns.void
setIncludes
(String[] includes) Sets the Ant-like inclusion patterns.void
setOutputDirectory
(File directory) Sets the absolute path to the output directory used to detect stale target files.void
setParserPackage
(String packageName) Sets the package name for the generated parser.void
setSourceDirectory
(File directory) Sets the absolute path to the source directory to scan for grammar files.void
setStaleMillis
(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 benull
if no stale detection should be performed. -
parserPackage
The package name for the generated parser, may benull
to 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 benull
to 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 benull
to include all files.
-
setExcludes
Sets the Ant-like exclusion patterns.- Parameters:
excludes
- The set of Ant-like exclusion patterns, may benull
to 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 benull
if 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
.
-