net.sourceforge.cobertura.instrument
Class Main

java.lang.Object
  extended by net.sourceforge.cobertura.instrument.Main

public class Main
extends java.lang.Object

Add coverage instrumentation to existing classes.

What does that mean, exactly?

It means Cobertura will look at each class you give it. It loads the bytecode into memory. For each line of source, Cobertura adds a few extra instructions. These instructions do the following:

  1. Get an instance of the ProjectData class.
  2. Call a method in this ProjectData class that increments a counter for this line of code.

After every line in a class has been "instrumented," Cobertura edits the bytecode for the class one more time and adds "implements net.sourceforge.cobertura.coveragedata.HasBeenInstrumented" This is basically just a flag used internally by Cobertura to determine whether a class has been instrumented or not, so as not to instrument the same class twice.


Field Summary
private  ClassPattern classPattern
           
private  java.io.File destinationDirectory
           
private  java.util.Collection ignoreBranchesRegexes
           
private  java.util.Collection ignoreRegexes
           
private static org.apache.log4j.Logger logger
           
private  ProjectData projectData
           
 
Constructor Summary
Main()
           
 
Method Summary
private  void addInstrumentation(CoberturaFile coberturaFile)
           
private  void addInstrumentationToArchive(Archive archive)
           
private  void addInstrumentationToArchive(CoberturaFile archive)
           
private  boolean addInstrumentationToArchive(CoberturaFile file, java.io.InputStream archive, java.io.OutputStream output)
           
private  boolean addInstrumentationToArchive(CoberturaFile file, java.util.zip.ZipInputStream archive, java.util.zip.ZipOutputStream output)
           
private  void addInstrumentationToSingleClass(java.io.File file)
           
private static boolean isClass(java.util.zip.ZipEntry entry)
           
static void main(java.lang.String[] args)
           
private  void parseArguments(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final org.apache.log4j.Logger logger

destinationDirectory

private java.io.File destinationDirectory

ignoreRegexes

private java.util.Collection ignoreRegexes

ignoreBranchesRegexes

private java.util.Collection ignoreBranchesRegexes

classPattern

private ClassPattern classPattern

projectData

private ProjectData projectData
Constructor Detail

Main

public Main()
Method Detail

isClass

private static boolean isClass(java.util.zip.ZipEntry entry)
Parameters:
entry - A zip entry.
Returns:
True if the specified entry has "class" as its extension, false otherwise.

addInstrumentationToArchive

private boolean addInstrumentationToArchive(CoberturaFile file,
                                            java.io.InputStream archive,
                                            java.io.OutputStream output)
                                     throws java.lang.Exception
Throws:
java.lang.Exception

addInstrumentationToArchive

private boolean addInstrumentationToArchive(CoberturaFile file,
                                            java.util.zip.ZipInputStream archive,
                                            java.util.zip.ZipOutputStream output)
                                     throws java.lang.Exception
Throws:
java.lang.Exception

addInstrumentationToArchive

private void addInstrumentationToArchive(Archive archive)
                                  throws java.lang.Exception
Throws:
java.lang.Exception

addInstrumentationToArchive

private void addInstrumentationToArchive(CoberturaFile archive)

addInstrumentationToSingleClass

private void addInstrumentationToSingleClass(java.io.File file)

addInstrumentation

private void addInstrumentation(CoberturaFile coberturaFile)

parseArguments

private void parseArguments(java.lang.String[] args)

main

public static void main(java.lang.String[] args)