Package ej.event

Class Event


  • public class Event
    extends java.lang.Object
    Event is the object that is sent through the Event Queue. It is either a simple or an extended event. It provides utility methods to read the extended data from an event.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int TYPE_MASK  
    • Constructor Summary

      Constructors 
      Constructor Description
      Event​(boolean isExtended, int type, int data, byte[] extendedData, int extendedDataLength)
      Event constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()
      Returns the number of bytes that can be read (or skipped over) from extendedData.
      int getMessage()  
      boolean isExtended()
      Gets the isExtended.
      int read​(byte[] b, int off, int len)
      Reads len bytes of data from extendedData and store them into the buffer array b.
      long readEightBytes()
      Gets the next long (8 bytes) of data from extendedData.
      int readFourBytes()
      Gets the next integer (4 bytes) of data from extendedData.
      int readFully​(byte[] b)
      Reads all the bytes of data from extendedData and store them into the buffer array b.
      byte readOneByte()
      Gets the next byte of data from extendedData.
      int readTwoBytes()
      Gets the next short (2 bytes) of data from extendedData.
      int skipBytes​(int n)
      Skips n bytes from extendedData.
      void startRead()
      Starts to read an extended data.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Event

        public Event​(boolean isExtended,
                     int type,
                     int data,
                     byte[] extendedData,
                     int extendedDataLength)
        Event constructor.
        Parameters:
        isExtended - the kind of event that is sent. Equal to true if it is an extended event.
        type - the type of the event.
        data - the data of the event. Equal to 0 if it is an extended event.
        extendedData - the extended data of the event. Empty if it is a classic event.
        extendedDataLength - the number of bytes in extendedData.
    • Method Detail

      • isExtended

        public boolean isExtended()
        Gets the isExtended.
        Returns:
        the isExtended.
      • getMessage

        public int getMessage()
      • startRead

        public void startRead()
        Starts to read an extended data. The offset is set to 0.
      • readOneByte

        public byte readOneByte()
                         throws java.io.IOException
        Gets the next byte of data from extendedData. This method is taking C structure alignment into account.
        Returns:
        the byte value.
        Throws:
        java.io.IOException - if there is no byte remaining in the data of the extended event.
      • readTwoBytes

        public int readTwoBytes()
                         throws java.io.IOException
        Gets the next short (2 bytes) of data from extendedData. This method is taking C structure alignment into account.
        Returns:
        the short value.
        Throws:
        java.io.IOException - if there is less than 2 bytes remaining in the data of the extended event.
      • readFourBytes

        public int readFourBytes()
                          throws java.io.IOException
        Gets the next integer (4 bytes) of data from extendedData. This method is taking C structure alignment into account.
        Returns:
        the integer value.
        Throws:
        java.io.IOException - if there is less than 4 bytes remaining in the data of the extended event.
      • readEightBytes

        public long readEightBytes()
                            throws java.io.IOException
        Gets the next long (8 bytes) of data from extendedData. This method is taking C structure alignment into account.
        Returns:
        the long value.
        Throws:
        java.io.IOException - if there is less than 8 bytes remaining in the data of the extended event.
      • readFully

        public int readFully​(byte[] b)
                      throws java.io.IOException
        Reads all the bytes of data from extendedData and store them into the buffer array 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

        public int read​(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
        Reads len bytes of data from extendedData and store them into the buffer array b.
        Parameters:
        b - the buffer into which the data is read.
        off - the start offset in array b at which the data is written.
        len - the maximum 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.
      • skipBytes

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

        public int available()
        Returns the number of bytes that can be read (or skipped over) from extendedData.
        Returns:
        the number of bytes available in the remaining extended data.