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 Details

    • 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:
    • BLOCK_HEADER

      public static final byte BLOCK_HEADER
      Block identifier for file headers.
      See Also:
    • BLOCK_SESSIONINFO

      public static final byte BLOCK_SESSIONINFO
      Block identifier for session information.
      See Also:
    • BLOCK_EXECUTIONDATA

      public static final byte BLOCK_EXECUTIONDATA
      Block identifier for execution data of a single class.
      See Also:
    • out

      protected final CompactDataOutput out
      Underlying data output
  • Constructor Details

    • ExecutionDataWriter

      public ExecutionDataWriter(OutputStream output) throws 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:
      IOException - if the header can't be written
  • Method Details

    • writeHeader

      private void writeHeader() throws IOException
      Writes an file header to identify the stream and its protocol version.
      Throws:
      IOException - if the header can't be written
    • flush

      public void flush() throws IOException
      Flushes the underlying stream.
      Throws:
      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