Package ej.event
Class EventQueueNatives
- java.lang.Object
-
- ej.event.EventQueueNatives
-
public class EventQueueNatives extends java.lang.ObjectNative methods of the Event Queue Foundation Library.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidendReadExtendedData()The Java listener finished to read the data from the event queue.static voidinitialize()Initializes the event queue.static intnativeAvailable()Returns the number of bytes that can be read (or skipped over).static intnativeRead(byte[] b, int off, int len)Reads up to len bytes of data and store them into the buffer array b.static booleannativeReadBoolean()Gets the next boolean of data.static bytenativeReadByte()Gets the next byte of data.static charnativeReadChar()Gets the next char of data.static doublenativeReadDouble()Gets the next double of data.static floatnativeReadFloat()Gets the next float of data.static intnativeReadInt()Gets the next integer of data.static longnativeReadLong()Gets the next long of data.static shortnativeReadShort()Gets the next short of data.static intnativeReadUnsignedByte()Gets the next unsigned byte of data.static intnativeReadUnsignedShort()Gets the next unsigned short of data.static intnativeSkipBytes(int n)Skips n bytes.static booleanofferEvent(int type, int data)Offers an event to the queue.static booleanofferExtendedEvent(int type, byte[] data, int length)Offers an extended event to the queue.static voidstartReadExtendedData(int dataLength)Starts to read an extended data.static intwaitEvent()Waits for an event from the queue and returns it.
-
-
-
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.IOExceptionGets 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.IOExceptionGets 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.IOExceptionGets 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.IOExceptionGets 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.IOExceptionGets 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.IOExceptionReads 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.IOExceptionGets 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.IOExceptionGets 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.IOExceptionGets 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.IOExceptionGets 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.IOExceptionGets 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.
-
-