net.sourceforge.cobertura.reporting
public class ComplexityCalculator extends java.lang.Object
One instance of this class should be used for the same set of source files - an object of this class can cache computed results.
Modifier and Type | Class and Description |
---|---|
private static class |
ComplexityCalculator.Complexity
Represents complexity of source file, package or project.
|
Modifier and Type | Field and Description |
---|---|
private FileFinder |
finder |
private static org.apache.log4j.Logger |
logger |
private java.util.Map |
packageCNNCache |
private java.util.Map |
sourceFileCNNCache |
static ComplexityCalculator.Complexity |
ZERO_COMPLEXITY |
Constructor and Description |
---|
ComplexityCalculator(FileFinder finder)
Creates new calculator.
|
Modifier and Type | Method and Description |
---|---|
private ComplexityCalculator.Complexity |
getAccumlatedCCNForSingleFile(java.lang.String sourceFileName)
Calculates the code complexity number for single source file.
|
private ComplexityCalculator.Complexity |
getAccumlatedCCNForSource(java.lang.String sourceFileName,
Source source)
Calculates the code complexity number for an input stream.
|
double |
getCCNForClass(ClassData classData)
Computes CCN for source file the specified class belongs to.
|
double |
getCCNForPackage(PackageData packageData)
Computes CCN for all sources contained in the specified package.
|
private ComplexityCalculator.Complexity |
getCCNForPackageInternal(PackageData packageData) |
double |
getCCNForProject(ProjectData projectData)
Computes CCN for all sources contained in the project.
|
double |
getCCNForSourceFile(SourceFileData sourceFile)
Computes CCN for single source file.
|
private ComplexityCalculator.Complexity |
getCCNForSourceFileNameInternal(java.lang.String sourceFileName) |
private static final org.apache.log4j.Logger logger
public static final ComplexityCalculator.Complexity ZERO_COMPLEXITY
private final FileFinder finder
private java.util.Map sourceFileCNNCache
private java.util.Map packageCNNCache
public ComplexityCalculator(FileFinder finder)
FileFinder
will be used to
map source file names to existing files when needed.finder
- FileFinder
that allows to find source filesjava.lang.NullPointerException
- if finder is nullprivate ComplexityCalculator.Complexity getAccumlatedCCNForSource(java.lang.String sourceFileName, Source source)
file
- The input stream for which you want to calculate
the complexityprivate ComplexityCalculator.Complexity getAccumlatedCCNForSingleFile(java.lang.String sourceFileName) throws java.io.IOException
sourceFileName
- file
- The source file for which you want to calculate
the complexityjava.io.IOException
public double getCCNForProject(ProjectData projectData)
projectData
- project to compute CCN forjava.lang.NullPointerException
- if projectData is nullpublic double getCCNForPackage(PackageData packageData)
packageData
- package to compute CCN forjava.lang.NullPointerException
- if packageData
is null
private ComplexityCalculator.Complexity getCCNForPackageInternal(PackageData packageData)
public double getCCNForSourceFile(SourceFileData sourceFile)
sourceFile
- source file to compute CCN forsourceFile
to existing filejava.lang.NullPointerException
- if sourceFile
is null
private ComplexityCalculator.Complexity getCCNForSourceFileNameInternal(java.lang.String sourceFileName)
public double getCCNForClass(ClassData classData)
classData
- package to compute CCN forjava.lang.NullPointerException
- if classData
is null