Package org.jacoco.core.data
Class ExecutionDataStore
- java.lang.Object
-
- org.jacoco.core.data.ExecutionDataStore
-
- All Implemented Interfaces:
IExecutionDataVisitor
public final class ExecutionDataStore extends java.lang.Object implements IExecutionDataVisitor
In-memory data store for execution data. The data can be added through itsIExecutionDataVisitor
interface. If execution data is provided multiple times for the same class the data is merged, i.e. a probe is marked as executed if it is reported as executed at least once. This allows to merge coverage date from multiple runs. A instance of this class is not thread safe.
-
-
Constructor Summary
Constructors Constructor Description ExecutionDataStore()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(IExecutionDataVisitor visitor)
Writes the content of the store to the given visitor interface.boolean
contains(java.lang.String name)
Checks whether execution data for classes with the given name are contained in the store.ExecutionData
get(long id)
Returns theExecutionData
entry with the given id if it exists in this store.ExecutionData
get(java.lang.Long id, java.lang.String name, int probecount)
Returns the coverage data for the class with the given identifier.java.util.Collection<ExecutionData>
getContents()
Returns a collection that represents current contents of the store.void
put(ExecutionData data)
Adds the givenExecutionData
object into the store.void
reset()
Resets all execution data probes, i.e.void
subtract(ExecutionData data)
Subtracts the probes in the givenExecutionData
object from the store.void
subtract(ExecutionDataStore store)
Subtracts all probes in the given execution data store from this store.void
visitClassExecution(ExecutionData data)
Provides execution data for a class.
-
-
-
Method Detail
-
put
public void put(ExecutionData data) throws java.lang.IllegalStateException
Adds the givenExecutionData
object into the store. If there is already execution data with this same class id, this structure is merged with the given one.- Parameters:
data
- execution data to add or merge- Throws:
java.lang.IllegalStateException
- if the givenExecutionData
object is not compatible to a corresponding one, that is already contained- See Also:
ExecutionData.assertCompatibility(long, String, int)
-
subtract
public void subtract(ExecutionData data) throws java.lang.IllegalStateException
Subtracts the probes in the givenExecutionData
object from the store. I.e. for all set probes in the given data object the corresponding probes in this store will be unset. If there is no execution data with id of the given data object this operation will have no effect.- Parameters:
data
- execution data to subtract- Throws:
java.lang.IllegalStateException
- if the givenExecutionData
object is not compatible to a corresponding one, that is already contained- See Also:
ExecutionData.assertCompatibility(long, String, int)
-
subtract
public void subtract(ExecutionDataStore store)
Subtracts all probes in the given execution data store from this store.- Parameters:
store
- execution data store to subtract- See Also:
subtract(ExecutionData)
-
get
public ExecutionData get(long id)
Returns theExecutionData
entry with the given id if it exists in this store.- Parameters:
id
- class id- Returns:
- execution data or
null
-
contains
public boolean contains(java.lang.String name)
Checks whether execution data for classes with the given name are contained in the store.- Parameters:
name
- VM name- Returns:
true
if at least one class with the name is contained.
-
get
public ExecutionData get(java.lang.Long id, java.lang.String name, int probecount)
Returns the coverage data for the class with the given identifier. If there is no data available under the given id a new entry is created.- Parameters:
id
- class identifiername
- VM name of the classprobecount
- probe data length- Returns:
- execution data
-
reset
public void reset()
Resets all execution data probes, i.e. marks them as not executed. The execution data objects itself are not removed.
-
getContents
public java.util.Collection<ExecutionData> getContents()
Returns a collection that represents current contents of the store.- Returns:
- current contents
-
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(ExecutionData data)
Description copied from interface:IExecutionDataVisitor
Provides execution data for a class.- Specified by:
visitClassExecution
in interfaceIExecutionDataVisitor
- Parameters:
data
- execution data for a class
-
-