Package ej.event

Class EventQueueNatives


  • public class EventQueueNatives
    extends java.lang.Object
    Native methods of the Event Queue Foundation Library.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void endReadExtendedData()
      The Java listener finished to read the data from the event queue.
      static void initialize()
      Initializes the event queue.
      static int nativeAvailable()
      Returns the number of bytes that can be read (or skipped over).
      static int nativeRead​(byte[] b, int off, int len)
      Reads up to len bytes of data and store them into the buffer array b.
      static boolean nativeReadBoolean()
      Gets the next boolean of data.
      static byte nativeReadByte()
      Gets the next byte of data.
      static char nativeReadChar()
      Gets the next char of data.
      static double nativeReadDouble()
      Gets the next double of data.
      static float nativeReadFloat()
      Gets the next float of data.
      static int nativeReadInt()
      Gets the next integer of data.
      static long nativeReadLong()
      Gets the next long of data.
      static short nativeReadShort()
      Gets the next short of data.
      static int nativeReadUnsignedByte()
      Gets the next unsigned byte of data.
      static int nativeReadUnsignedShort()
      Gets the next unsigned short of data.
      static int nativeSkipBytes​(int n)
      Skips n bytes.
      static boolean offerEvent​(int type, int data)
      Offers an event to the queue.
      static boolean offerExtendedEvent​(int type, byte[] data, int length)
      Offers an extended event to the queue.
      static void startReadExtendedData​(int dataLength)
      Starts to read an extended data.
      static int waitEvent()
      Waits for an event from the queue and returns it.
      • Methods inherited from class java.lang.Object

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

      • initialize

        public static void initialize()
        Initializes the event queue.
      • offerEvent

        public static boolean offerEvent​(int type,
                                         int data)
        Offers an event to the queue.
        Parameters:
        type - the type of the event.
        data - the data of the event.
        Returns:
        true if the message has been sent, false otherwise.
      • offerExtendedEvent

        public static boolean offerExtendedEvent​(int type,
                                                 byte[] data,
                                                 int length)
        Offers an extended event to the queue.
        Parameters:
        type - the type of the event.
        data - the data of the event.
        length - the number of bytes in the data.
        Returns:
        true if the message has been sent, false otherwise.
      • waitEvent

        public static int waitEvent()
        Waits for an event from the queue and returns it.
        Returns:
        the read event.
      • startReadExtendedData

        public static void startReadExtendedData​(int dataLength)
        Starts to read an extended data.
        Parameters:
        dataLength - the number of bytes of the extended data.
      • endReadExtendedData

        public static void endReadExtendedData()
        The Java listener finished to read the data from the event queue. If there is any left data left in the queue, purge it.
      • nativeReadBoolean

        public static boolean nativeReadBoolean()
                                         throws java.io.IOException
        Gets the next boolean of data.
        Returns:
        the boolean value.
        Throws:
        java.io.IOException - if there is no boolean remaining in the data of the extended event.
      • nativeReadByte

        public static byte nativeReadByte()
                                   throws java.io.IOException
        Gets the next byte of data.
        Returns:
        the byte value.
        Throws:
        java.io.IOException - if there is no byte remaining in the data of the extended event.
      • nativeReadChar

        public static char nativeReadChar()
                                   throws java.io.IOException
        Gets the next char of data.
        Returns:
        the char value.
        Throws:
        java.io.IOException - if there is no char remaining in the data of the extended event.
      • nativeReadDouble

        public static double nativeReadDouble()
                                       throws java.io.IOException
        Gets the next double of data.
        Returns:
        the double value.
        Throws:
        java.io.IOException - if there is no double remaining in the data of the extended event.
      • nativeReadFloat

        public static float nativeReadFloat()
                                     throws java.io.IOException
        Gets the next float of data.
        Returns:
        the float value.
        Throws:
        java.io.IOException - if there is no float remaining in the data of the extended event.
      • nativeRead

        public static int nativeRead​(byte[] b,
                                     int off,
                                     int len)
                              throws java.io.IOException
        Reads up to len bytes of data 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 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.
      • nativeReadInt

        public static int nativeReadInt()
                                 throws java.io.IOException
        Gets the next integer of data.
        Returns:
        the integer value.
        Throws:
        java.io.IOException - if there is no integer remaining in the data of the extended event.
      • nativeReadLong

        public static long nativeReadLong()
                                   throws java.io.IOException
        Gets the next long of data.
        Returns:
        the long value.
        Throws:
        java.io.IOException - if there is no long remaining in the data of the extended event.
      • nativeReadShort

        public static short nativeReadShort()
                                     throws java.io.IOException
        Gets the next short of data.
        Returns:
        the short value.
        Throws:
        java.io.IOException - if there is no short remaining in the data of the extended event.
      • nativeReadUnsignedByte

        public static int nativeReadUnsignedByte()
                                          throws java.io.IOException
        Gets the next unsigned byte of data.
        Returns:
        the unsigned byte value.
        Throws:
        java.io.IOException - if there is no unsigned byte remaining in the data of the extended event.
      • nativeReadUnsignedShort

        public static int nativeReadUnsignedShort()
                                           throws java.io.IOException
        Gets the next unsigned short of data.
        Returns:
        the unsigned short value.
        Throws:
        java.io.IOException - if there is no unsigned short remaining in the data of the extended event.
      • nativeSkipBytes

        public static int nativeSkipBytes​(int n)
        Skips n bytes.
        Parameters:
        n - the number of bytes to skip.
        Returns:
        0 if OK and -1 if an error occurs.
      • nativeAvailable

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