Class GrammarDirectoryScanner

java.lang.Object
org.codehaus.mojo.javacc.GrammarDirectoryScanner
Direct Known Subclasses:
LegacyGrammarDirectoryScanner

class GrammarDirectoryScanner extends Object
Scans source directories for JavaCC grammar files.
Version:
$Id$
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private List
    A set of grammar infos describing the included grammar files, must never be null.
    private File
    The absolute path to the output directory used to detect stale target files by timestamp checking, may be null if no stale detection should be performed.
    private String
    The package name for the generated parser, may be null 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
    Constructor
    Description
    Creates a new grammar directory scanner.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the grammar files that were included by the scanner during the last invocation of scan().
    protected File[]
    getTargetFiles(File targetDirectory, String grammarFile, GrammarInfo grammarInfo)
    Determines the output files corresponding to the specified grammar file.
    void
    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
    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
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • scanner

      private org.codehaus.plexus.util.DirectoryScanner scanner
      The directory scanner used to scan the source directory for files.
    • outputDirectory

      private File outputDirectory
      The absolute path to the output directory used to detect stale target files by timestamp checking, may be null if no stale detection should be performed.
    • parserPackage

      private String parserPackage
      The package name for the generated parser, may be null to 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 List includedGrammars
      A set of grammar infos describing the included grammar files, must never be null.
  • Constructor Details

    • GrammarDirectoryScanner

      public GrammarDirectoryScanner()
      Creates a new grammar directory scanner.
  • Method Details

    • setSourceDirectory

      public void setSourceDirectory(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 be null.
    • setParserPackage

      public void setParserPackage(String packageName)
      Sets the package name for the generated parser.
      Parameters:
      packageName - The package name for the generated parser, may be null to use the package declaration from the grammar file.
    • setIncludes

      public void setIncludes(String[] includes)
      Sets the Ant-like inclusion patterns.
      Parameters:
      includes - The set of Ant-like inclusion patterns, may be null to include all files.
    • setExcludes

      public void setExcludes(String[] excludes)
      Sets the Ant-like exclusion patterns.
      Parameters:
      excludes - The set of Ant-like exclusion patterns, may be null to exclude no files.
    • setOutputDirectory

      public void setOutputDirectory(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 be null 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

      public void scan() throws IOException
      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

      protected File[] getTargetFiles(File targetDirectory, 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 be null.
      grammarFile - The path to the grammar file, relative to the scanned source directory, must not be null.
      grammarInfo - The grammar info describing the grammar file, must not be null
      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 of scan().
      Returns:
      An array of grammar infos describing the included grammar files, will be empty if no files were included but is never null.