net.sourceforge.cobertura.coveragedata
Class CoverageDataContainer

java.lang.Object
  extended bynet.sourceforge.cobertura.coveragedata.CoverageDataContainer
All Implemented Interfaces:
CoverageData, HasBeenInstrumented, java.io.Serializable
Direct Known Subclasses:
ClassData, PackageData, ProjectData, SourceFileData

public abstract class CoverageDataContainer
extends java.lang.Object
implements CoverageData, HasBeenInstrumented, java.io.Serializable

Coverage data information is typically serialized to a file.

This class implements HasBeenInstrumented so that when cobertura instruments itself, it will omit this class. It does this to avoid an infinite recursion problem because instrumented classes make use of this class.

See Also:
Serialized Form

Field Summary
(package private)  java.util.Map children
          Each key is the name of a child, usually stored as a String or an Integer object.
private static long serialVersionUID
           
 
Constructor Summary
CoverageDataContainer()
           
 
Method Summary
 boolean equals(java.lang.Object obj)
          Determine if this CoverageDataContainer is equal to another one.
 double getBranchCoverageRate()
           
 CoverageData getChild(java.lang.String name)
          Get a child from this container with the specified key.
 double getLineCoverageRate()
           
 int getNumberOfChildren()
           
 int getNumberOfCoveredBranches()
           
 int getNumberOfCoveredLines()
           
 int getNumberOfValidBranches()
           
 int getNumberOfValidLines()
           
 int hashCode()
          It is highly recommended that classes extending this class override this hashCode method and generate a more effective hash code.
 void merge(CoverageData coverageData)
          Merge two CoverageDataContainers.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

children

java.util.Map children
Each key is the name of a child, usually stored as a String or an Integer object. Each value is information about the child, stored as an object that implements the CoverageData interface.

Constructor Detail

CoverageDataContainer

public CoverageDataContainer()
Method Detail

equals

public boolean equals(java.lang.Object obj)
Determine if this CoverageDataContainer is equal to another one. Subclasses should override this and make sure they implement the hashCode method.

Parameters:
obj - An object to test for equality.
Returns:
True if the objects are equal.

getBranchCoverageRate

public double getBranchCoverageRate()
Specified by:
getBranchCoverageRate in interface CoverageData
Returns:
The average branch coverage rate for all children in this container.

getChild

public CoverageData getChild(java.lang.String name)
Get a child from this container with the specified key.

Parameters:
name - The key used to lookup the child in the map.
Returns:
The child object, if found, or null if not found.

getLineCoverageRate

public double getLineCoverageRate()
Specified by:
getLineCoverageRate in interface CoverageData
Returns:
The average line coverage rate for all children in this container. This number will be a decimal between 0 and 1, inclusive.

getNumberOfChildren

public int getNumberOfChildren()
Returns:
The number of children in this container.

getNumberOfCoveredBranches

public int getNumberOfCoveredBranches()
Specified by:
getNumberOfCoveredBranches in interface CoverageData

getNumberOfCoveredLines

public int getNumberOfCoveredLines()
Specified by:
getNumberOfCoveredLines in interface CoverageData

getNumberOfValidBranches

public int getNumberOfValidBranches()
Specified by:
getNumberOfValidBranches in interface CoverageData

getNumberOfValidLines

public int getNumberOfValidLines()
Specified by:
getNumberOfValidLines in interface CoverageData

hashCode

public int hashCode()
It is highly recommended that classes extending this class override this hashCode method and generate a more effective hash code.


merge

public void merge(CoverageData coverageData)
Merge two CoverageDataContainers.

Specified by:
merge in interface CoverageData
Parameters:
coverageData - The container to merge into this one.