sofya.ed.structural
Class CoverageTrace

java.lang.Object
  extended by sofya.ed.structural.CoverageTrace
Direct Known Subclasses:
BlockCoverageTrace, BranchCoverageTrace

public abstract class CoverageTrace
extends java.lang.Object

A coverage traces records the coverage of structural program entities (basic blocks or branches) observed through execution of an instrumented program by a ProgramEventDispatcher.

Version:
03/03/2006
Author:
Alex Kinneer
See Also:
Instrumentor, TraceHandler, ProgramEventDispatcher, TraceViewer

Field Summary
protected  int highestId
          Highest structural entity number found in the method.
protected  java.util.BitSet traceVector
          Bit vector which records program entities hit during execution.
 
Constructor Summary
protected CoverageTrace(int highestId)
          Default constructor, creates a trace with the specified number of structural entities.
 
Method Summary
 void clear()
          Clears the covered status for every entity in the method.
abstract  CoverageTrace copy()
           
 boolean equals(java.lang.Object obj)
          Tests whether this trace object is equal to another trace.
 int getHighestId()
          Gets the highest entity ID present in the method.
 boolean query(int id)
          Queries whether an entity was covered during execution.
 void set(int id)
          Marks that an entity was covered during execution.
 java.lang.String toString()
          Returns a string representation of this trace.
 CoverageTrace union(CoverageTrace tr)
          Creates a trace that is the union of this trace and another trace.
 void unset(int id)
          Marks that an entity was not covered during execution.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

traceVector

protected java.util.BitSet traceVector
Bit vector which records program entities hit during execution.


highestId

protected int highestId
Highest structural entity number found in the method.

Constructor Detail

CoverageTrace

protected CoverageTrace(int highestId)
Default constructor, creates a trace with the specified number of structural entities.

Parameters:
highestId - Highest possible entity number in the method; cannot be changed after instantiation.
Method Detail

getHighestId

public int getHighestId()
Gets the highest entity ID present in the method.

Returns:
The highest ID of any entity found in the method.

set

public void set(int id)
Marks that an entity was covered during execution.

Parameters:
id - ID of the entity that was covered.

query

public boolean query(int id)
Queries whether an entity was covered during execution.

Parameters:
id - ID of the method entity to be queried.
Returns:
true if the entity was covered during execution, false otherwise.

unset

public void unset(int id)
Marks that an entity was not covered during execution.

Parameters:
id - ID of the entity for which covered status is being cleared.

clear

public void clear()
Clears the covered status for every entity in the method.


copy

public abstract CoverageTrace copy()

equals

public boolean equals(java.lang.Object obj)
Tests whether this trace object is equal to another trace.

Two trace objects are considered equal if their entity counts and trace bit vectors are equivalent.

Overrides:
equals in class java.lang.Object
Parameters:
obj - Trace to which this trace should be compared for equality.
Returns:
true if the specified trace is equal to this trace, false otherwise.

union

public CoverageTrace union(CoverageTrace tr)
Creates a trace that is the union of this trace and another trace.

The specified trace must have the same number of method entities as this trace. The method will then take the logical union of the bit vectors in the two traces. The resulting trace will be an entirely new object, neither the current trace or the specified trace will be modified by this method.

Parameters:
tr - Trace for which the union should be taken with this trace.
Returns:
An entirely new trace object, representing the union of this trace and the specified trace.

toString

public java.lang.String toString()
Returns a string representation of this trace.

This method simply calls the toString() method of the underlying BitSet and returns the result. Typically this is a list of the bits in the BitSet using vector notation (e.g. [ 0 1 1 0 ... 1 ]).

Overrides:
toString in class java.lang.Object
Returns:
String representation of this trace object.