Package org.jacoco.core.internal.analysis

## Class SourceNodeImpl

- java.lang.Object
- - org.jacoco.core.analysis.CoverageNodeImpl
  - - org.jacoco.core.internal.analysis.SourceNodeImpl

All Implemented Interfaces:
  `ICoverageNode`, `ISourceNode`

Direct Known Subclasses:
  `ClassCoverageImpl`, `MethodCoverageImpl`, `SourceFileCoverageImpl`

    public class SourceNodeImpl
    extends CoverageNodeImpl
    implements ISourceNode

Implementation of `ISourceNode`.

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.jacoco.core.analysis.ICoverageNode

`ICoverageNode.CounterEntity, ICoverageNode.ElementType`

### Field Summary

### Fields inherited from class org.jacoco.core.analysis.CoverageNodeImpl

`branchCounter, classCounter, complexityCounter, instructionCounter, lineCounter, methodCounter`

### Fields inherited from interface org.jacoco.core.analysis.ISourceNode

`UNKNOWN_LINE`

### Constructor Summary

Constructors
`SourceNodeImpl​(ICoverageNode.ElementType elementType, java.lang.String name)` Create a new source node implementation instance.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `ensureCapacity​(int first, int last)` Make sure that the internal buffer can keep lines from first to last.
`int` `getFirstLine()` The number of the first line coverage information is available for.
`int` `getLastLine()` The number of the last line coverage information is available for.
`LineImpl` `getLine​(int nr)` Returns the line information for given line.
`void` `increment​(ICounter instructions, ICounter branches, int line)` Increments instructions and branches by the given counter values.
`void` `increment​(ISourceNode child)` Increments all counters by the values of the given child.

### Methods inherited from class org.jacoco.core.analysis.CoverageNodeImpl

`containsCode, getBranchCounter, getClassCounter, getComplexityCounter, getCounter, getElementType, getInstructionCounter, getLineCounter, getMethodCounter, getName, getPlainCopy, increment, increment, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.jacoco.core.analysis.ICoverageNode

`containsCode, getBranchCounter, getClassCounter, getComplexityCounter, getCounter, getElementType, getInstructionCounter, getLineCounter, getMethodCounter, getName, getPlainCopy`

### Constructor Detail

#### SourceNodeImpl

    public SourceNodeImpl​(ICoverageNode.ElementType elementType,
                          java.lang.String name)

Create a new source node implementation instance.

Parameters:
  `elementType` - element type
  `name` - name of the element

### Method Detail

#### ensureCapacity

    public void ensureCapacity​(int first,
                               int last)

Make sure that the internal buffer can keep lines from first to last. While the buffer is also incremented automatically, this method allows optimization in case the total range is known in advance.

Parameters:
  `first` - first line number or `ISourceNode.UNKNOWN_LINE`
  `last` - last line number or `ISourceNode.UNKNOWN_LINE`

#### increment

    public void increment​(ISourceNode child)

Increments all counters by the values of the given child. When incrementing the line counter it is assumed that the child refers to the same source file.

Parameters:
  `child` - child node to add

#### increment

    public void increment​(ICounter instructions,
                          ICounter branches,
                          int line)

Increments instructions and branches by the given counter values. If a optional line number is specified the instructions and branches are added to the given line. The line counter is incremented accordingly.

Parameters:
  `instructions` - instructions to add
  `branches` - branches to add
  `line` - optional line number or `ISourceNode.UNKNOWN_LINE`

#### getFirstLine

    public int getFirstLine()

Description copied from interface: `ISourceNode`
The number of the first line coverage information is available for. If no line is contained, the method returns -1.

Specified by:
  `getFirstLine` in interface `ISourceNode`
Returns:
  number of the first line or `ISourceNode.UNKNOWN_LINE`

#### getLastLine

    public int getLastLine()

Description copied from interface: `ISourceNode`
The number of the last line coverage information is available for. If no line is contained, the method returns -1.

Specified by:
  `getLastLine` in interface `ISourceNode`
Returns:
  number of the last line or `ISourceNode.UNKNOWN_LINE`

#### getLine

    public LineImpl getLine​(int nr)

Description copied from interface: `ISourceNode`
Returns the line information for given line.

Specified by:
  `getLine` in interface `ISourceNode`
Parameters:
  `nr` - line number of interest
Returns:
  line information