org.jacoco.core.data
Class ExecutionDataStore

java.lang.Object
  extended by org.jacoco.core.data.ExecutionDataStore
All Implemented Interfaces:
IExecutionDataVisitor

public class ExecutionDataStore
extends Object
implements IExecutionDataVisitor

In-memory data store for execution data. The data can be added through its IExecutionDataVisitor interface. If execution data is provided multiple times for the same class the data is merged, i.e. a block is marked as executed if it is reported as executed at least once. This allows to merge coverage date from multiple runs. This class is not thread safe.

Version:
$Revision: $
Author:
Marc R. Hoffmann

Constructor Summary
ExecutionDataStore()
           
 
Method Summary
 void accept(IExecutionDataVisitor visitor)
          Writes the content of the store to the given visitor interface.
 boolean[][] getData(long classid)
          Returns the coverage data for the class with the given identifier if available.
 boolean[][] getData(Long classid)
          Returns the coverage data for the class with the given identifier if available.
 String getName(long classid)
          Returns the vm name of the class with the given id.
 String getName(Long classid)
          Returns the vm name of the class with the given id.
 void put(long classid, String name, boolean[][] blockdata)
          Adds the given block data structure into the store.
 void put(Long classid, String name, boolean[][] blockdata)
          Adds the given block data structure into the store.
 void reset()
          Resets all execution data structures, i.e. marks them as not executed.
 void visitClassExecution(long classid, String name, boolean[][] blockdata)
          Provides execution data for the class with the given id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExecutionDataStore

public ExecutionDataStore()
Method Detail

put

public void put(Long classid,
                String name,
                boolean[][] blockdata)
Adds the given block data structure into the store. If there is already a data structure for this class ID, this structure is merged with the given one. In this case a IllegalStateException is thrown, if both executions data structure do have different bloc sizes.

Parameters:
classid - unique class identifier
name - VM name of the class
blockdata - execution data

put

public void put(long classid,
                String name,
                boolean[][] blockdata)
Adds the given block data structure into the store. If there is already a data structure for this class ID, this structure is merged with the given one. In this case a IllegalStateException is thrown, if both executions data structure do have different bloc sizes.

Parameters:
classid - unique class identifier
name - VM name of the class
blockdata - execution data

getData

public boolean[][] getData(long classid)
Returns the coverage data for the class with the given identifier if available.

Parameters:
classid - class identifier
Returns:
coverage data or null

getData

public boolean[][] getData(Long classid)
Returns the coverage data for the class with the given identifier if available.

Parameters:
classid - class identifier
Returns:
coverage data or null

getName

public String getName(long classid)
Returns the vm name of the class with the given id.

Parameters:
classid - class identifier
Returns:
vm name or null

getName

public String getName(Long classid)
Returns the vm name of the class with the given id.

Parameters:
classid - class identifier
Returns:
vm name or null

reset

public void reset()
Resets all execution data structures, i.e. marks them as not executed. The data structures itself are not deleted.


accept

public void accept(IExecutionDataVisitor visitor)
Writes the content of the store to the given visitor interface.

Parameters:
visitor - interface to write content to

visitClassExecution

public void visitClassExecution(long classid,
                                String name,
                                boolean[][] blockdata)
Description copied from interface: IExecutionDataVisitor
Provides execution data for the class with the given id. The first dimension of the array corresponds to the method id the second to the block id as provided with the structure data for this class. A value of true indicates that a block has been executed, i.e. its last instruction was called.

Specified by:
visitClassExecution in interface IExecutionDataVisitor
Parameters:
classid - id of the class
name - VM name of the class
blockdata - coverage data for the class