org.jacoco.core.analysis
Class CoverageNodeImpl

java.lang.Object
  extended by org.jacoco.core.analysis.CoverageNodeImpl
All Implemented Interfaces:
ICoverageNode
Direct Known Subclasses:
BundleCoverage, ClassCoverage, MethodCoverage, PackageCoverage, SourceFileCoverage

public class CoverageNodeImpl
extends Object
implements ICoverageNode

Base implementation for coverage data nodes.

Version:
0.4.1.20101007204400
Author:
Marc R. Hoffmann

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jacoco.core.analysis.ICoverageNode
ICoverageNode.CounterEntity, ICoverageNode.ElementType
 
Field Summary
protected  CounterImpl blockCounter
          Counter for blocks.
protected  CounterImpl classCounter
          Counter for classes.
protected  CounterImpl instructionCounter
          Counter for instructions.
protected  CounterImpl lineCounter
          Counter for lines, if this element does not have lines.
protected  LinesImpl lines
          Line information if this element has lines.
protected  CounterImpl methodCounter
          Counter for methods.
 
Constructor Summary
CoverageNodeImpl(ICoverageNode.ElementType elementType, String name, boolean hasLines)
          Creates a new coverage data node.
 
Method Summary
 ICounter getBlockCounter()
          Returns the counter for blocks.
 ICounter getClassCounter()
          Returns the counter for classes.
 ICounter getCounter(ICoverageNode.CounterEntity entity)
          Generic access to the the counters.
 ICoverageNode.ElementType getElementType()
          Returns the type of element represented by this node.
 ICounter getInstructionCounter()
          Returns the counter for byte code instructions.
 ICounter getLineCounter()
          Returns the counter for lines.
 ILines getLines()
          Returns the line coverage information if this node represents a source file or a part of a source file.
 ICounter getMethodCounter()
          Returns the counter for methods.
 String getName()
          Returns the name of this node.
 ICoverageNode getPlainCopy()
          Creates a plain copy of this node.
 void increment(Collection<? extends ICoverageNode> children)
          Increments the counters by the values given by the collection of elements.
 void increment(ICoverageNode child)
          Increments the counters by the values given by another element.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

blockCounter

protected CounterImpl blockCounter
Counter for blocks.


instructionCounter

protected CounterImpl instructionCounter
Counter for instructions.


lineCounter

protected CounterImpl lineCounter
Counter for lines, if this element does not have lines.


methodCounter

protected CounterImpl methodCounter
Counter for methods.


classCounter

protected CounterImpl classCounter
Counter for classes.


lines

protected final LinesImpl lines
Line information if this element has lines.

Constructor Detail

CoverageNodeImpl

public CoverageNodeImpl(ICoverageNode.ElementType elementType,
                        String name,
                        boolean hasLines)
Creates a new coverage data node.

Parameters:
elementType - type of the element represented by this instance
name - name of this node
hasLines - true id this element has source lines
Method Detail

increment

public void increment(ICoverageNode child)
Increments the counters by the values given by another element.

Parameters:
child - counters to add

increment

public void increment(Collection<? extends ICoverageNode> children)
Increments the counters by the values given by the collection of elements.

Parameters:
children - list of nodes, which counters will be added to this node

getElementType

public ICoverageNode.ElementType getElementType()
Description copied from interface: ICoverageNode
Returns the type of element represented by this node.

Specified by:
getElementType in interface ICoverageNode
Returns:
type of this node

getName

public String getName()
Description copied from interface: ICoverageNode
Returns the name of this node.

Specified by:
getName in interface ICoverageNode
Returns:
name of this node

getInstructionCounter

public ICounter getInstructionCounter()
Description copied from interface: ICoverageNode
Returns the counter for byte code instructions.

Specified by:
getInstructionCounter in interface ICoverageNode
Returns:
counter for instructions

getBlockCounter

public ICounter getBlockCounter()
Description copied from interface: ICoverageNode
Returns the counter for blocks.

Specified by:
getBlockCounter in interface ICoverageNode
Returns:
counter for blocks

getLineCounter

public ICounter getLineCounter()
Description copied from interface: ICoverageNode
Returns the counter for lines.

Specified by:
getLineCounter in interface ICoverageNode
Returns:
counter for lines

getMethodCounter

public ICounter getMethodCounter()
Description copied from interface: ICoverageNode
Returns the counter for methods.

Specified by:
getMethodCounter in interface ICoverageNode
Returns:
counter for methods

getClassCounter

public ICounter getClassCounter()
Description copied from interface: ICoverageNode
Returns the counter for classes.

Specified by:
getClassCounter in interface ICoverageNode
Returns:
counter for classes

getCounter

public ICounter getCounter(ICoverageNode.CounterEntity entity)
Description copied from interface: ICoverageNode
Generic access to the the counters.

Specified by:
getCounter in interface ICoverageNode
Parameters:
entity - entity we're we want to have the counter for
Returns:
counter for the given entity

getLines

public ILines getLines()
Description copied from interface: ICoverageNode
Returns the line coverage information if this node represents a source file or a part of a source file.

Specified by:
getLines in interface ICoverageNode
Returns:
line coverage or null

getPlainCopy

public ICoverageNode getPlainCopy()
Description copied from interface: ICoverageNode
Creates a plain copy of this node. While ICoverageNode implementations may contain heavy data structures, the copy returned by this method is reduced to the counters only. This helps tp save memory while processing huge structures.

Specified by:
getPlainCopy in interface ICoverageNode
Returns:
copy with counters only

toString

public String toString()
Overrides:
toString in class Object