org.jacoco.core.analysis

## Class Analyzer

- java.lang.Object
- - org.jacoco.core.analysis.Analyzer

    public class Analyzer
    extends Object

An `Analyzer` instance processes a set of Java class files and calculates coverage data for them. For each class file the result is reported to a given `ICoverageVisitor` instance. In addition the `Analyzer` requires a `ExecutionDataStore` instance that holds the execution data for the classes to analyze. The `Analyzer` offers several methods to analyze classes from a variety of sources.

### Constructor Summary

Constructors
Constructor and Description
`Analyzer(ExecutionDataStore executionData, ICoverageVisitor coverageVisitor)` Creates a new analyzer reporting to the given output.

### Method Summary

All Methods Instance Methods Concrete Methods
`int` `analyzeAll(File file)` Analyzes all class files contained in the given file or folder.
`int` `analyzeAll(InputStream input, String location)` Analyzes all classes found in the given input stream.
`int` `analyzeAll(String path, File basedir)` Analyzes all classes from the given class path.
`void` `analyzeClass(byte[] buffer, String location)` Analyzes the class definition from a given in-memory buffer.
`void` `analyzeClass(org.objectweb.asm.ClassReader reader)` Analyzes the class given as a ASM reader.
`void` `analyzeClass(InputStream input, String location)` Analyzes the class definition from a given input stream.

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

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

### Constructor Detail

#### Analyzer

    public Analyzer(ExecutionDataStore executionData,
                    ICoverageVisitor coverageVisitor)

Creates a new analyzer reporting to the given output.

Parameters:
  `executionData` - execution data
  `coverageVisitor` - the output instance that will coverage data for every analyzed class

### Method Detail

#### analyzeClass

    public void analyzeClass(org.objectweb.asm.ClassReader reader)

Analyzes the class given as a ASM reader.

Parameters:
  `reader` - reader with class definitions

#### analyzeClass

    public void analyzeClass(byte[] buffer,
                             String location)
                      throws IOException

Analyzes the class definition from a given in-memory buffer.

Parameters:
  `buffer` - class definitions
  `location` - a location description used for exception messages
Throws:
  `IOException` - if the class can't be analyzed

#### analyzeClass

    public void analyzeClass(InputStream input,
                             String location)
                      throws IOException

Analyzes the class definition from a given input stream.

Parameters:
  `input` - stream to read class definition from
  `location` - a location description used for exception messages
Throws:
  `IOException` - if the stream can't be read or the class can't be analyzed

#### analyzeAll

    public int analyzeAll(InputStream input,
                          String location)
                   throws IOException

Analyzes all classes found in the given input stream. The input stream may either represent a single class file, a ZIP archive, a Pack200 archive or a gzip stream that is searched recursively for class files. All other content types are ignored.

Parameters:
  `input` - input data
  `location` - a location description used for exception messages
Returns:
  number of class files found
Throws:
  `IOException` - if the stream can't be read or a class can't be analyzed

#### analyzeAll

    public int analyzeAll(File file)
                   throws IOException

Analyzes all class files contained in the given file or folder. Class files as well as ZIP files are considered. Folders are searched recursively.

Parameters:
  `file` - file or folder to look for class files
Returns:
  number of class files found
Throws:
  `IOException` - if the file can't be read or a class can't be analyzed

#### analyzeAll

    public int analyzeAll(String path,
                          File basedir)
                   throws IOException

Analyzes all classes from the given class path. Directories containing class files as well as archive files are considered.

Parameters:
  `path` - path definition
  `basedir` - optional base directory, if `null` the current working directory is used as the base for relative path entries
Returns:
  number of class files found
Throws:
  `IOException` - if a file can't be read or a class can't be analyzed