Package ej.event
Class Event
- java.lang.Object
-
- ej.event.Event
-
public class Event extends java.lang.ObjectEvent 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 intTYPE_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 intavailable()Returns the number of bytes that can be read (or skipped over) fromextendedData.intgetMessage()booleanisExtended()Gets the isExtended.intread(byte[] b, int off, int len)Reads len bytes of data fromextendedDataand store them into the buffer array b.longreadEightBytes()Gets the next long (8 bytes) of data fromextendedData.intreadFourBytes()Gets the next integer (4 bytes) of data fromextendedData.intreadFully(byte[] b)Reads all the bytes of data fromextendedDataand store them into the buffer array b.bytereadOneByte()Gets the next byte of data fromextendedData.intreadTwoBytes()Gets the next short (2 bytes) of data fromextendedData.intskipBytes(int n)Skips n bytes fromextendedData.voidstartRead()Starts to read an extended data.
-
-
-
Field Detail
-
TYPE_MASK
public static final int TYPE_MASK
- See Also:
- Constant Field Values
-
-
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.IOExceptionGets the next byte of data fromextendedData. 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.IOExceptionGets the next short (2 bytes) of data fromextendedData. 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.IOExceptionGets the next integer (4 bytes) of data fromextendedData. 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.IOExceptionGets the next long (8 bytes) of data fromextendedData. 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.IOExceptionReads all the bytes of data fromextendedDataand 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.IOExceptionReads len bytes of data fromextendedDataand 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 fromextendedData.- 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) fromextendedData.- Returns:
- the number of bytes available in the remaining extended data.
-
-