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 java.lang.Object implements ISessionInfoVisitor, IExecutionDataVisitor
Serialization of execution data into binary streams.
-
-
Field Summary
Fields Modifier and Type Field Description static byteBLOCK_EXECUTIONDATABlock identifier for execution data of a single class.static byteBLOCK_HEADERBlock identifier for file headers.static byteBLOCK_SESSIONINFOBlock identifier for session information.static charFORMAT_VERSIONFile format version, will be incremented for each incompatible change.static charMAGIC_NUMBERMagic number in header for file format identification.protected CompactDataOutputoutUnderlying data output
-
Constructor Summary
Constructors Constructor Description ExecutionDataWriter(java.io.OutputStream output)Creates a new writer based on the given output stream.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidflush()Flushes the underlying stream.static byte[]getFileHeader()Returns the first bytes of a file that represents a valid execution data file.voidvisitClassExecution(ExecutionData data)Provides execution data for a class.voidvisitSessionInfo(SessionInfo info)Provides session information for the subsequent execution data calls.
-
-
-
Field Detail
-
FORMAT_VERSION
public static final char FORMAT_VERSION
File format version, will be incremented for each incompatible change.
-
MAGIC_NUMBER
public static final char MAGIC_NUMBER
Magic number in header for file format identification.- See Also:
- Constant Field Values
-
BLOCK_HEADER
public static final byte BLOCK_HEADER
Block identifier for file headers.- See Also:
- Constant Field Values
-
BLOCK_SESSIONINFO
public static final byte BLOCK_SESSIONINFO
Block identifier for session information.- See Also:
- Constant Field Values
-
BLOCK_EXECUTIONDATA
public static final byte BLOCK_EXECUTIONDATA
Block identifier for execution data of a single class.- See Also:
- Constant Field Values
-
out
protected final CompactDataOutput out
Underlying data output
-
-
Constructor Detail
-
ExecutionDataWriter
public ExecutionDataWriter(java.io.OutputStream output) throws java.io.IOExceptionCreates 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:
java.io.IOException- if the header can't be written
-
-
Method Detail
-
flush
public void flush() throws java.io.IOExceptionFlushes the underlying stream.- Throws:
java.io.IOException- if the underlying stream can't be flushed
-
visitSessionInfo
public void visitSessionInfo(SessionInfo info)
Description copied from interface:ISessionInfoVisitorProvides session information for the subsequent execution data calls. In case of merged sessions this method might be called multiple times.- Specified by:
visitSessionInfoin interfaceISessionInfoVisitor- Parameters:
info- session information
-
visitClassExecution
public void visitClassExecution(ExecutionData data)
Description copied from interface:IExecutionDataVisitorProvides execution data for a class.- Specified by:
visitClassExecutionin 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
-
-