Package org.codehaus.mojo.javacc
Class GrammarDirectoryScanner
- java.lang.Object
-
- org.codehaus.mojo.javacc.GrammarDirectoryScanner
-
- Direct Known Subclasses:
LegacyGrammarDirectoryScanner
class GrammarDirectoryScanner extends java.lang.ObjectScans source directories for JavaCC grammar files.- Version:
- $Id$
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<GrammarInfo>includedGrammarsA set of grammar infos describing the included grammar files, must never benull.private java.io.FileoutputDirectoryThe absolute path to the output directory used to detect stale target files by timestamp checking, may benullif no stale detection should be performed.private java.lang.StringparserPackageThe package name for the generated parser, may benullto use the package declaration from the grammar file.private org.codehaus.plexus.util.DirectoryScannerscannerThe directory scanner used to scan the source directory for files.private intstaleMillisThe 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 Constructor Description GrammarDirectoryScanner()Creates a new grammar directory scanner.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GrammarInfo[]getIncludedGrammars()Gets the grammar files that were included by the scanner during the last invocation ofscan().protected java.io.File[]getTargetFiles(java.io.File targetDirectory, java.lang.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(java.lang.String[] excludes)Sets the Ant-like exclusion patterns.voidsetIncludes(java.lang.String[] includes)Sets the Ant-like inclusion patterns.voidsetOutputDirectory(java.io.File directory)Sets the absolute path to the output directory used to detect stale target files.voidsetParserPackage(java.lang.String packageName)Sets the package name for the generated parser.voidsetSourceDirectory(java.io.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 Detail
-
scanner
private final org.codehaus.plexus.util.DirectoryScanner scanner
The directory scanner used to scan the source directory for files.
-
outputDirectory
private java.io.File 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
private java.lang.String parserPackage
The package name for the generated parser, may benullto use the package declaration from the grammar file.
-
staleMillis
private int staleMillis
The granularity in milliseconds of the last modification date for testing whether a grammar file needs recompilation because its corresponding target file is stale.
-
includedGrammars
private final java.util.List<GrammarInfo> includedGrammars
A set of grammar infos describing the included grammar files, must never benull.
-
-
Method Detail
-
setSourceDirectory
public void setSourceDirectory(java.io.File directory)
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
public void setParserPackage(java.lang.String packageName)
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
public void setIncludes(java.lang.String[] includes)
Sets the Ant-like inclusion patterns.- Parameters:
includes- The set of Ant-like inclusion patterns, may benullto include all files.
-
setExcludes
public void setExcludes(java.lang.String[] excludes)
Sets the Ant-like exclusion patterns.- Parameters:
excludes- The set of Ant-like exclusion patterns, may benullto exclude no files.
-
setOutputDirectory
public void setOutputDirectory(java.io.File directory)
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
public void scan() throws java.io.IOExceptionScans 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:
java.io.IOException- If a grammar file could not be analyzed for metadata.
-
getTargetFiles
protected java.io.File[] getTargetFiles(java.io.File targetDirectory, java.lang.String grammarFile, GrammarInfo grammarInfo)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
public GrammarInfo[] 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.
-
-