Package org.jacoco.core.data
Class ExecutionDataWriter
java.lang.Object
org.jacoco.core.data.ExecutionDataWriter
- All Implemented Interfaces:
IExecutionDataVisitor
,ISessionInfoVisitor
- Direct Known Subclasses:
RemoteControlWriter
public class ExecutionDataWriter
extends Object
implements ISessionInfoVisitor, IExecutionDataVisitor
Serialization of execution data into binary streams.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byte
Block identifier for execution data of a single class.static final byte
Block identifier for file headers.static final byte
Block identifier for session information.static final char
File format version, will be incremented for each incompatible change.static final char
Magic number in header for file format identification.protected final CompactDataOutput
Underlying data output -
Constructor Summary
ConstructorsConstructorDescriptionExecutionDataWriter
(OutputStream output) Creates a new writer based on the given output stream. -
Method Summary
Modifier and TypeMethodDescriptionvoid
flush()
Flushes the underlying stream.static final byte[]
Returns the first bytes of a file that represents a valid execution data file.void
Provides execution data for a class.void
visitSessionInfo
(SessionInfo info) Provides session information for the subsequent execution data calls.private void
Writes an file header to identify the stream and its protocol version.
-
Field Details
-
FORMAT_VERSION
public static final char FORMAT_VERSIONFile format version, will be incremented for each incompatible change. -
MAGIC_NUMBER
public static final char MAGIC_NUMBERMagic number in header for file format identification.- See Also:
-
BLOCK_HEADER
public static final byte BLOCK_HEADERBlock identifier for file headers.- See Also:
-
BLOCK_SESSIONINFO
public static final byte BLOCK_SESSIONINFOBlock identifier for session information.- See Also:
-
BLOCK_EXECUTIONDATA
public static final byte BLOCK_EXECUTIONDATABlock identifier for execution data of a single class.- See Also:
-
out
Underlying data output
-
-
Constructor Details
-
ExecutionDataWriter
Creates a new writer based on the given output stream. Depending on the nature of the underlying stream output should be buffered as most data is written in single bytes.- Parameters:
output
- binary stream to write execution data to- Throws:
IOException
- if the header can't be written
-
-
Method Details
-
writeHeader
Writes an file header to identify the stream and its protocol version.- Throws:
IOException
- if the header can't be written
-
flush
Flushes the underlying stream.- Throws:
IOException
- if the underlying stream can't be flushed
-
visitSessionInfo
Description copied from interface:ISessionInfoVisitor
Provides session information for the subsequent execution data calls. In case of merged sessions this method might be called multiple times.- Specified by:
visitSessionInfo
in interfaceISessionInfoVisitor
- Parameters:
info
- session information
-
visitClassExecution
Description copied from interface:IExecutionDataVisitor
Provides execution data for a class.- Specified by:
visitClassExecution
in interfaceIExecutionDataVisitor
- Parameters:
data
- execution data for a class
-
getFileHeader
public static final byte[] getFileHeader()Returns the first bytes of a file that represents a valid execution data file. In any case every execution data file starts with the three bytes0x01 0xC0 0xC0
.- Returns:
- first bytes of a execution data file
-