de.uka.ipd.sdq.ByCounter.parsing
Class LineNumberRange

java.lang.Object
  extended by de.uka.ipd.sdq.ByCounter.parsing.LineNumberRange
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<LineNumberRange>

public final class LineNumberRange
extends java.lang.Object
implements java.lang.Comparable<LineNumberRange>, java.io.Serializable

Denotes a range of source code line numbers which should be measured with BytecodeCounter. Source code line numbers may have another order in the source code file than in the compiled Bytecode. If there is more than one Bytecode block containing referencing a source code line, all blocks containing a reference will be counted. In general, LineNumberRangefrom x to y means that all Bytecode blocks B are counted for which { B | x <= ReferencedLineNumber(B) <= y } holds. Additionally, all blocks B_{hull} = {B_h | NoReferencedLineNumber(B_h) and \exists B_j \in B: JumpFromTo(B_j,B_h)} are counted which do not reference a line number but for which a jump from any of the blocks in B exist. This enables correct counting of for-each-loops.

Author:
Martin Krogmann, groenda
See Also:
Serialized Form

Field Summary
 int firstLine
          The first line number included in the range.
 int lastLine
          The last line number included in the range.
 
Constructor Summary
LineNumberRange(int firstLine, int lastLine)
          A new line number range with the given parameters.
 
Method Summary
 int compareTo(LineNumberRange o)
           
static LineNumberRange findLineInRanges(LineNumberRange[] codeAreasToInstrument, int l)
          Searches an array for a LineNumberRange starting at a given line.
static java.util.Comparator<? super LineNumberRange> getComparator()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

firstLine

public int firstLine
The first line number included in the range.


lastLine

public int lastLine
The last line number included in the range.

Constructor Detail

LineNumberRange

public LineNumberRange(int firstLine,
                       int lastLine)
A new line number range with the given parameters.

Parameters:
firstLine - The first included source code line number.
lastLine - The last included source code line number.
Method Detail

getComparator

public static java.util.Comparator<? super LineNumberRange> getComparator()
Returns:
A Comparator implementation for LineNumberRanges. The comparison is based on the first line only. E.g.: A range r1 is smaller than r2 if r1.firstLine is smaller than r2.firstLine.

findLineInRanges

public static LineNumberRange findLineInRanges(LineNumberRange[] codeAreasToInstrument,
                                               int l)
Searches an array for a LineNumberRange starting at a given line.

Parameters:
codeAreasToInstrument - List of LineNumberRanges to search.
l - Line to analyse.
Returns:
When l is in the range of specified code areas: A code area that includes line l. Null otherwise.

compareTo

public int compareTo(LineNumberRange o)
Specified by:
compareTo in interface java.lang.Comparable<LineNumberRange>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object