Package ej.event

Interface EventDataReader

  • All Known Implementing Classes:
    EventQueueDataReader

    public interface EventDataReader
    An EventDataReader contains the methods to read the data of an extended event.

    EventDataReaders are created by the system and passed to extended events listeners when calling EventQueueListener.handleExtendedEvent(int, EventDataReader) method.

    There are two ways to read the data of an extended event:

    • Read the data with read(byte[], int, int) or readFully(byte[]) methods.
    • Read the data with the methods related to the primitive types such as readBoolean() or readByte().
      • This is useful when the extended data you send through the Event Queue is a C structure with multiple fields.
      • To use the methods, your fields must follow this alignment:
        • A boolean (1 byte) will be 1-byte aligned.
        • A byte (1 byte) will be 1-byte aligned.
        • A char (2 bytes) will be 2-byte aligned.
        • A double (8 bytes) will be 8-byte aligned.
        • A float (4 bytes) will be 4-byte aligned.
        • An int (4 bytes) will be 4-byte aligned.
        • A long (8 bytes) will be 8-byte aligned.
        • A short (2 bytes) will be 2-byte aligned.
        • An unsigned byte (1 byte) will be 1-byte aligned.
        • A unsigned short (2 bytes) will be 2-byte aligned.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      int available()
      Returns the number of bytes that can be read (or skipped over).
      int read​(byte[] b, int off, int len)
      Reads len bytes of data and store them into the buffer b.
      boolean readBoolean()
      Reads the next boolean of data.
      byte readByte()
      Reads the next byte of data.
      char readChar()
      Reads the next char of data.
      double readDouble()
      Reads the next double of data.
      float readFloat()
      Reads the next float of data.
      int readFully​(byte[] b)
      Reads all the bytes of data and store them into the buffer b.
      int readInt()
      Reads the next integer of data.
      long readLong()
      Reads the next long of data.
      short readShort()
      Reads the next short of data.
      int readUnsignedByte()
      Reads the next unsigned byte of data.
      int readUnsignedShort()
      Reads the next unsigned short of data.
      int skipBytes​(int n)
      Skips over and discard n bytes of data.
    • Method Detail

      • readBoolean

        boolean readBoolean()
                     throws java.io.IOException
        Reads the next boolean of data.
        Returns:
        the next boolean of data.
        Throws:
        java.io.IOException - if there is no boolean remaining in the data of the extended event.
      • readByte

        byte readByte()
               throws java.io.IOException
        Reads the next byte of data.
        Returns:
        the next byte of data.
        Throws:
        java.io.IOException - if there is no byte remaining in the data of the extended event.
      • readChar

        char readChar()
               throws java.io.IOException
        Reads the next char of data.
        Returns:
        the next char of data.
        Throws:
        java.io.IOException - if there is no char remaining in the data of the extended event.
      • readDouble

        double readDouble()
                   throws java.io.IOException
        Reads the next double of data.
        Returns:
        the next double of data.
        Throws:
        java.io.IOException - if there is no double remaining in the data of the extended event.
      • readFloat

        float readFloat()
                 throws java.io.IOException
        Reads the next float of data.
        Returns:
        the next float of data.
        Throws:
        java.io.IOException - if there is no float remaining in the data of the extended event.
      • readFully

        int readFully​(byte[] b)
               throws java.io.IOException
        Reads all the bytes of data and store them into the buffer b.
        Parameters:
        b - the buffer into which the data is read.
        Returns:
        the total number of bytes read into the buffer.
        Throws:
        java.io.IOException - if there is no byte remaining in the data of the extended event or if the buffer is too small to store the event data.
      • read

        int read​(byte[] b,
                 int off,
                 int len)
          throws java.io.IOException
        Reads len bytes of data and store them into the buffer b.
        Parameters:
        b - the buffer into which the data is read.
        off - the start offset in the buffer b at which the data is written.
        len - the number of bytes to read.
        Returns:
        the total number of bytes read into the buffer.
        Throws:
        java.io.IOException - if there are not enough bytes remaining in the data of the extended event or if the buffer is too small to store the event data.
      • readInt

        int readInt()
             throws java.io.IOException
        Reads the next integer of data.
        Returns:
        the next integer of data.
        Throws:
        java.io.IOException - if there is no integer remaining in the data of the extended event.
      • readLong

        long readLong()
               throws java.io.IOException
        Reads the next long of data.
        Returns:
        the next long of data.
        Throws:
        java.io.IOException - if there is no long remaining in the data of the extended event.
      • readShort

        short readShort()
                 throws java.io.IOException
        Reads the next short of data.
        Returns:
        the next short of data.
        Throws:
        java.io.IOException - if there is no short remaining in the data of the extended event.
      • readUnsignedByte

        int readUnsignedByte()
                      throws java.io.IOException
        Reads the next unsigned byte of data.
        Returns:
        the next unsigned byte of data.
        Throws:
        java.io.IOException - if there is no unsigned byte remaining in the data of the extended event.
      • readUnsignedShort

        int readUnsignedShort()
                       throws java.io.IOException
        Reads the next unsigned short of data.
        Returns:
        the next unsigned short of data.
        Throws:
        java.io.IOException - if there is no unsigned short remaining in the data of the extended event.
      • skipBytes

        int skipBytes​(int n)
        Skips over and discard n bytes of data.
        Parameters:
        n - the number of bytes to skip.
        Returns:
        0 if OK and -1 if an error occurs.
      • available

        int available()
        Returns the number of bytes that can be read (or skipped over).
        Returns:
        the number of available data bytes.