Package ej.event
Interface EventDataReader
-
- All Known Implementing Classes:
EventQueueDataReader
public interface EventDataReaderAn 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)orreadFully(byte[])methods.- You will get the data in a byte array and can process it on your own in
EventQueueListener.handleExtendedEvent(int, EventDataReader).
- You will get the data in a byte array and can process it on your own in
- Read the data with the methods related to the primitive types such as
readBoolean()orreadByte().- 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 intavailable()Returns the number of bytes that can be read (or skipped over).intread(byte[] b, int off, int len)Readslenbytes of data and store them into the bufferb.booleanreadBoolean()Reads the next boolean of data.bytereadByte()Reads the next byte of data.charreadChar()Reads the next char of data.doublereadDouble()Reads the next double of data.floatreadFloat()Reads the next float of data.intreadFully(byte[] b)Reads all the bytes of data and store them into the bufferb.intreadInt()Reads the next integer of data.longreadLong()Reads the next long of data.shortreadShort()Reads the next short of data.intreadUnsignedByte()Reads the next unsigned byte of data.intreadUnsignedShort()Reads the next unsigned short of data.intskipBytes(int n)Skips over and discardnbytes of data.
-
-
-
Method Detail
-
readBoolean
boolean readBoolean() throws java.io.IOExceptionReads 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.IOExceptionReads 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.IOExceptionReads 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.IOExceptionReads 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.IOExceptionReads 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.IOExceptionReads all the bytes of data and store them into the bufferb.- 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.IOExceptionReadslenbytes of data and store them into the bufferb.- Parameters:
b- the buffer into which the data is read.off- the start offset in the bufferbat 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.IOExceptionReads 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.IOExceptionReads 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.IOExceptionReads 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.IOExceptionReads 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.IOExceptionReads 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 discardnbytes 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.
-
-