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
`static byte` `BLOCK_EXECUTIONDATA` Block identifier for execution data of a single class.
`static byte` `BLOCK_HEADER` Block identifier for file headers.
`static byte` `BLOCK_SESSIONINFO` Block identifier for session information.
`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.
`protected CompactDataOutput` `out` Underlying data output

### Constructor Summary

Constructors
`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
`void` `flush()` Flushes the underlying stream.
`static byte[]` `getFileHeader()` Returns the first bytes of a file that represents a valid execution data file.
`void` `visitClassExecution​(ExecutionData data)` Provides execution data for a class.
`void` `visitSessionInfo​(SessionInfo info)` Provides session information for the subsequent execution data calls.

### 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.

#### 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.IOException

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:
  `java.io.IOException` - if the header can't be written

### Method Detail

#### flush

    public void flush()
               throws java.io.IOException

Flushes 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: `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 interface `ISessionInfoVisitor`
Parameters:
  `info` - session information

#### visitClassExecution

    public void visitClassExecution​(ExecutionData data)

Description copied from interface: `IExecutionDataVisitor`
Provides execution data for a class.

Specified by:
  `visitClassExecution` in interface `IExecutionDataVisitor`
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 bytes `0x01 0xC0 0xC0`.

Returns:
  first bytes of a execution data file