pyrasun.eio
Class EIOEvent

java.lang.Object
  extended bypyrasun.eio.EIOEvent

public class EIOEvent
extends java.lang.Object

Describes a single event-type that can be handled by the EmberIO system. Events include things like READ (there's data available to read from an Endpoint), WRITE (you might be able to squeeze out a few bytes writing to an endpoint), PROCESS (there's data available to process from the Endpoint), etc. You can (will be able to...) define your own EIOEvents if you want to define something of our own outside of NIO. The are only a few constraints on this:


       - The ID for a user-defined event must fall between USER_BITS_LOW and
         USER_BITS_HIGH, inclusive.
       - The ID _must_ be a single bit e.g. (1 << USER_BITS_LOW) would
         be acceptable, USER_BITS_LOW+5 would not be.
   


Field Summary
static EIOEvent ACCEPT
          An accept event.
static EIOEvent CONNECT
          A connect event - currently not supported.
static int NIO_RESERVED_IDS
          IDs reserved for now and future NIO use.
static int NIO_SELECTOR_EVENTS
          Event ID bit mask for all events that may be used within an NIO Selector.
static EIOEvent PROCESS
          A Process event.
static EIOEvent READ
          A read event, indicating that data maybe available to read from an Endpoint.
static int USER_BITS_HIGH
          High end of User ID bit-space.
static int USER_BITS_LOW
          Low end of User ID bit-space.
static EIOEvent WRITE
          A write event - you may be able to write some data out to an endpoint.
 
Constructor Summary
EIOEvent(java.lang.String eventName, int id)
          Create a new EIOEvent
 
Method Summary
 int bit()
          Get the bit number for this event's ID e.g. an ID of 1 would return 0, 2 returns 1, 4 returns 2, 8 returns 3, etc.
static int bitFor(int flag)
          Given an EIOEvent flag ID value, returns the bit number for it.
 boolean equals(java.lang.Object obj)
           
 java.lang.String getEventName()
          Get the wetware readable name of this event.
 java.lang.Integer getID()
          Get the ID of this event as an Integer
static int getNIOSelectorEvents()
          Get the complete bitmask for all events that are selectable via an NIO Selector
 int hashCode()
           
 int id()
          Get the ID of this event as an int
static boolean isNIOSelectorEvent(EIOEvent event)
          Returns true if the event passed in are selectable via an NIO Selector.
static boolean isNIOSelectorEvent(int event)
          Returns true if the event (or events) passed in are selectable via an NIO Selector.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NIO_RESERVED_IDS

public static final int NIO_RESERVED_IDS
IDs reserved for now and future NIO use.

See Also:
Constant Field Values

READ

public static final EIOEvent READ
A read event, indicating that data maybe available to read from an Endpoint.


WRITE

public static final EIOEvent WRITE
A write event - you may be able to write some data out to an endpoint. Note that this is only advisory. If you're in blocking mode, you may block (even for one little byte), and in non-blocking mode you might not be able to write anything.


CONNECT

public static final EIOEvent CONNECT
A connect event - currently not supported.


ACCEPT

public static final EIOEvent ACCEPT
An accept event. This means you have something like a SocketServer and somone is trying to connect to you - hence, accept is ready.


PROCESS

public static final EIOEvent PROCESS
A Process event. This means one or more objects have been read in from the endpoint and are now available for processing.


USER_BITS_LOW

public static final int USER_BITS_LOW
Low end of User ID bit-space.

See Also:
Constant Field Values

USER_BITS_HIGH

public static final int USER_BITS_HIGH
High end of User ID bit-space.

See Also:
Constant Field Values

NIO_SELECTOR_EVENTS

public static final int NIO_SELECTOR_EVENTS
Event ID bit mask for all events that may be used within an NIO Selector.

Constructor Detail

EIOEvent

public EIOEvent(java.lang.String eventName,
                int id)
Create a new EIOEvent

Parameters:
eventName - The name of the event in wetware-readable form
id - The ID of the event. This _must_ be a single bit!!
Method Detail

isNIOSelectorEvent

public static boolean isNIOSelectorEvent(int event)
Returns true if the event (or events) passed in are selectable via an NIO Selector.

Parameters:
event - Event bitmask
Returns:
true if at least one event here is selectable.

isNIOSelectorEvent

public static boolean isNIOSelectorEvent(EIOEvent event)
Returns true if the event passed in are selectable via an NIO Selector.

Parameters:
event - - the event yuse want to know if it is like NIO Selectable.
Returns:
true if the event is selectable

getNIOSelectorEvents

public static int getNIOSelectorEvents()
Get the complete bitmask for all events that are selectable via an NIO Selector


getEventName

public java.lang.String getEventName()
Get the wetware readable name of this event.


getID

public java.lang.Integer getID()
Get the ID of this event as an Integer


id

public int id()
Get the ID of this event as an int


bit

public int bit()
Get the bit number for this event's ID e.g. an ID of 1 would return 0, 2 returns 1, 4 returns 2, 8 returns 3, etc.


bitFor

public static int bitFor(int flag)
Given an EIOEvent flag ID value, returns the bit number for it. You want a laugh, look up the source for this method.


equals

public boolean equals(java.lang.Object obj)

hashCode

public int hashCode()

toString

public java.lang.String toString()


Pyrasun EmberIO