org.jacoco.core.instr
Class Analyzer

java.lang.Object
  extended by org.jacoco.core.instr.Analyzer

public class Analyzer
extends Object

Several APIs to analyze class structures.

Version:
$Revision: $
Author:
Marc R. Hoffmann

Constructor Summary
Analyzer(IStructureVisitor structureVisitor)
          Creates a new analyzer reporting to the given output.
 
Method Summary
 int analyzeAll(File file)
          Analyzes all class files contained in the given file or folder.
 int analyzeAll(InputStream input)
          Analyzes all classes found in the given input stream.
 int analyzeAll(String path, File basedir)
          Analyzes all classes from the given class path.
 int analyzeArchive(InputStream input)
          Analyzes all classes contained in the ZIP archive (jar, war, ear, etc.)
 void analyzeClass(byte[] buffer)
          Analyzes the class definition from a given in-memory buffer.
 void analyzeClass(ClassReader reader)
          Analyzes the class given as a ASM reader.
 void analyzeClass(InputStream input)
          Analyzes the class definition from a given input stream.
 ClassVisitor createAnalyzingVisitor(long classid)
          Creates an ASM class visitor for analysis.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Analyzer

public Analyzer(IStructureVisitor structureVisitor)
Creates a new analyzer reporting to the given output.

Parameters:
structureVisitor - the output instance that will receive all structure data
Method Detail

createAnalyzingVisitor

public ClassVisitor createAnalyzingVisitor(long classid)
Creates an ASM class visitor for analysis.

Parameters:
classid - id of the class calculated with CRC64
Returns:
ASM visitor to write class definition to

analyzeClass

public void analyzeClass(ClassReader reader)
Analyzes the class given as a ASM reader.

Parameters:
reader - reader with class definitions

analyzeClass

public void analyzeClass(byte[] buffer)
Analyzes the class definition from a given in-memory buffer.

Parameters:
buffer - class definitions

analyzeClass

public void analyzeClass(InputStream input)
                  throws IOException
Analyzes the class definition from a given input stream.

Parameters:
input - stream to read class definition from
Throws:
IOException

analyzeArchive

public int analyzeArchive(InputStream input)
                   throws IOException
Analyzes all classes contained in the ZIP archive (jar, war, ear, etc.) given as an input stream. Contained archives are read recursively.

Parameters:
input - ZIP archive data
Returns:
number of class files found
Throws:
IOException

analyzeAll

public int analyzeAll(InputStream input)
               throws IOException
Analyzes all classes found in the given input stream. The input stream may either represent a single class file or a ZIP archive that is searched recursively for class files. All other content types are ignored.

Parameters:
input - input data
Returns:
number of class files found
Throws:
IOException

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

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