org.jacoco.core.data
Class ExecutionDataWriter

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

public class ExecutionDataWriter
extends Object
implements IExecutionDataVisitor

Serialization of execution data into binary streams.

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

Field Summary
static byte BLOCK_EXECUTIONDATA
          Block identifier for execution data of a single class.
static byte BLOCK_HEADER
          Block identifier for file headers.
static char FORMAT_VERSION
          File format version, will be incremented for each incompatible change.
static char MAGIC_NUMBER
          Magic number in header for file format identification.
 
Constructor Summary
ExecutionDataWriter(OutputStream output)
          Creates a new writer based on the given output stream.
 
Method Summary
static byte[] getFileHeader()
          Returns the first bytes of a file that represents a valid execution data file.
 void visitClassExecution(long id, String name, boolean[][] blockdata)
          Provides execution data for the class with the given id.
 void writeHeader()
          Writes an file header to identify the stream and its protocol version.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FORMAT_VERSION

public static final char FORMAT_VERSION
File format version, will be incremented for each incompatible change.

See Also:
Constant Field Values

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_EXECUTIONDATA

public static final byte BLOCK_EXECUTIONDATA
Block identifier for execution data of a single class.

See Also:
Constant Field Values
Constructor Detail

ExecutionDataWriter

public ExecutionDataWriter(OutputStream output)
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
Method Detail

writeHeader

public void writeHeader()
                 throws IOException
Writes an file header to identify the stream and its protocol version.

Throws:
IOException

visitClassExecution

public void visitClassExecution(long id,
                                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:
id - id of the class
name - VM name of the class
blockdata - coverage data for the 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 bytes 0x01 0xC0 0xC0.

Returns:
first bytes of a execution data file