org.apache.tools.ant.util.depend

## Class AbstractAnalyzer

- java.lang.Object
- - org.apache.tools.ant.util.depend.AbstractAnalyzer

- All Implemented Interfaces:
    DependencyAnalyzer
  Direct Known Subclasses:
    AncestorAnalyzer, AntAnalyzer, FullAnalyzer

      public abstract class AbstractAnalyzer
      extends java.lang.Object
      implements DependencyAnalyzer

  An abstract implementation of the analyzer interface providing support for the bulk of interface methods.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `MAX_LOOPS` Maximum number of loops for looking for indirect dependencies.

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractAnalyzer()` Setup the analyzer

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addClassPath(Path classPath)` Add a classpath to the classpath being used by the analyzer.
    `void` | `addRootClass(java.lang.String className)` Add a root class.
    `void` | `addSourcePath(Path sourcePath)` Add a source path to the source path used by this analyzer.
    `void` | `config(java.lang.String name, java.lang.Object info)` Configure an aspect of the analyzer.
    `protected abstract void` | `determineDependencies(java.util.Vector<java.io.File> files, java.util.Vector<java.lang.String> classes)` Determine the dependencies of the current set of root classes
    `java.io.File` | `getClassContainer(java.lang.String classname)` Get the file that contains the class definition
    `java.util.Enumeration<java.lang.String>` | `getClassDependencies()` Get the list of classes upon which root classes depend.
    `java.util.Enumeration<java.io.File>` | `getFileDependencies()` Get the list of files in the file system upon which the root classes depend.
    `protected java.util.Enumeration<java.lang.String>` | `getRootClasses()` Get an enumeration of the root classes
    `java.io.File` | `getSourceContainer(java.lang.String classname)` Get the file that contains the class source.
    `protected boolean` | `isClosureRequired()` Indicate if the analyzer is required to follow indirect class relationships.
    `void` | `reset()` Reset the dependency list.
    `void` | `setClosure(boolean closure)` Set the closure flag.
    `protected abstract boolean` | `supportsFileDependencies()` Indicate if the particular subclass supports file dependency information.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### MAX_LOOPS

          public static final int MAX_LOOPS

      Maximum number of loops for looking for indirect dependencies.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### AbstractAnalyzer

          protected AbstractAnalyzer()

      Setup the analyzer

  - ### Method Detail

    - #### setClosure

          public void setClosure(boolean closure)

      Set the closure flag. If this flag is true the analyzer will traverse all class relationships until it has collected the entire set of direct and indirect dependencies
      Specified by:
        `setClosure` in interface `DependencyAnalyzer`
      Parameters:
        `closure` - true if dependencies should be traversed to determine indirect dependencies.

    - #### getFileDependencies

          public java.util.Enumeration<java.io.File> getFileDependencies()

      Get the list of files in the file system upon which the root classes depend. The files will be either the classfiles or jar files upon which the root classes depend.
      Specified by:
        `getFileDependencies` in interface `DependencyAnalyzer`
      Returns:
        an enumeration of File instances.

    - #### getClassDependencies

          public java.util.Enumeration<java.lang.String> getClassDependencies()

      Get the list of classes upon which root classes depend. This is a list of Java classnames in dot notation.
      Specified by:
        `getClassDependencies` in interface `DependencyAnalyzer`
      Returns:
        an enumeration of Strings, each being the name of a Java class in dot notation.

    - #### getClassContainer

          public java.io.File getClassContainer(java.lang.String classname)
                                         throws java.io.IOException

      Get the file that contains the class definition
      Specified by:
        `getClassContainer` in interface `DependencyAnalyzer`
      Parameters:
        `classname` - the name of the required class
      Returns:
        the file instance, zip or class, containing the class or null if the class could not be found.
      Throws:
        `java.io.IOException` - if the files in the classpath cannot be read.

    - #### getSourceContainer

          public java.io.File getSourceContainer(java.lang.String classname)
                                          throws java.io.IOException

      Get the file that contains the class source.
      Specified by:
        `getSourceContainer` in interface `DependencyAnalyzer`
      Parameters:
        `classname` - the name of the required class
      Returns:
        the file instance, zip or java, containing the source or null if the source for the class could not be found.
      Throws:
        `java.io.IOException` - if the files in the sourcepath cannot be read.

    - #### addSourcePath

          public void addSourcePath(Path sourcePath)

      Add a source path to the source path used by this analyzer. The elements in the given path contain the source files for the classes being analyzed. Not all analyzers will use this information.
      Specified by:
        `addSourcePath` in interface `DependencyAnalyzer`
      Parameters:
        `sourcePath` - The Path instance specifying the source path elements.

    - #### addClassPath

          public void addClassPath(Path classPath)

      Add a classpath to the classpath being used by the analyzer. The classpath contains the binary classfiles for the classes being analyzed The elements may either be the directories or jar files.Not all analyzers will use this information.
      Specified by:
        `addClassPath` in interface `DependencyAnalyzer`
      Parameters:
        `classPath` - the Path instance specifying the classpath elements

    - #### addRootClass

          public void addRootClass(java.lang.String className)

      Add a root class. The root classes are used to drive the determination of dependency information. The analyzer will start at the root classes and add dependencies from there.
      Specified by:
        `addRootClass` in interface `DependencyAnalyzer`
      Parameters:
        `className` - the name of the class in Java dot notation.

    - #### config

          public void config(java.lang.String name,
                             java.lang.Object info)

      Configure an aspect of the analyzer. The set of aspects that are supported is specific to each analyzer instance.
      Specified by:
        `config` in interface `DependencyAnalyzer`
      Parameters:
        `name` - the name of the aspect being configured
        `info` - the configuration info.

    - #### reset

          public void reset()

      Reset the dependency list. This will reset the determined dependencies and the also list of root classes.
      Specified by:
        `reset` in interface `DependencyAnalyzer`

    - #### getRootClasses

          protected java.util.Enumeration<java.lang.String> getRootClasses()

      Get an enumeration of the root classes
      Returns:
        an enumeration of Strings, each of which is a class name for a root class.

    - #### isClosureRequired

          protected boolean isClosureRequired()

      Indicate if the analyzer is required to follow indirect class relationships.
      Returns:
        true if indirect relationships should be followed.

    - #### determineDependencies

          protected abstract void determineDependencies(java.util.Vector<java.io.File> files,
                                                        java.util.Vector<java.lang.String> classes)

      Determine the dependencies of the current set of root classes
      Parameters:
        `files` - a vector into which Files upon which the root classes depend should be placed.
        `classes` - a vector of Strings into which the names of classes upon which the root classes depend should be placed.

    - #### supportsFileDependencies

          protected abstract boolean supportsFileDependencies()

      Indicate if the particular subclass supports file dependency information.
      Returns:
        true if file dependencies are supported.