Build 1.0_r1(from source)

java.nio.channels
Class SelectionKey

java.lang.Object
  extended by java.nio.channels.SelectionKey
Direct Known Subclasses:
AbstractSelectionKey

public abstract class SelectionKey
extends Object

A key that representing the relationship of a channel and the selector.


Field Summary
static int OP_ACCEPT
          Interesting operation mask bit for socket-accept operations.
static int OP_CONNECT
          Interesting operation mask bit for socket-connect operations.
static int OP_READ
          Interesting operation mask bit for read operations.
static int OP_WRITE
          Interesting operation mask bit for write operations.
 
Constructor Summary
protected SelectionKey()
          The constructor.
 
Method Summary
 Object attach(Object anObject)
          Attaches an object to the key.
 Object attachment()
          Gets the attached object.
abstract  void cancel()
          Cancels this key.
abstract  SelectableChannel channel()
          Gets the channel of this key.
abstract  int interestOps()
          Gets the interesting operation of this key.
abstract  SelectionKey interestOps(int operations)
          Sets the interesting operation for this key.
 boolean isAcceptable()
          Tells whether the channel of this key is interested in accept operation and ready for acceptation.
 boolean isConnectable()
          Tells whether the channel of this key is interested in connect operation and ready for connection.
 boolean isReadable()
          Tells whether the channel of this key is interested in read operation and ready for reading.
abstract  boolean isValid()
          Tells whether the key is valid.
 boolean isWritable()
          Tells whether the channel of this key is interested in write operation and ready for writing.
abstract  int readyOps()
          Gets the ready operation.
abstract  Selector selector()
          Gets the related selector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OP_ACCEPT

public static final int OP_ACCEPT
Interesting operation mask bit for socket-accept operations.

See Also:
Constant Field Values

OP_CONNECT

public static final int OP_CONNECT
Interesting operation mask bit for socket-connect operations.

See Also:
Constant Field Values

OP_READ

public static final int OP_READ
Interesting operation mask bit for read operations.

See Also:
Constant Field Values

OP_WRITE

public static final int OP_WRITE
Interesting operation mask bit for write operations.

See Also:
Constant Field Values
Constructor Detail

SelectionKey

protected SelectionKey()
The constructor.

Method Detail

attach

public final Object attach(Object anObject)
Attaches an object to the key.

Parameters:
anObject - the object to attach
Returns:
the last attached object

attachment

public final Object attachment()
Gets the attached object.

Returns:
the attached object or null if no object has been attached

cancel

public abstract void cancel()
Cancels this key.


channel

public abstract SelectableChannel channel()
Gets the channel of this key.

Returns:
the channel of this key

interestOps

public abstract int interestOps()
Gets the interesting operation of this key.

Returns:
the interesting operation of this key
Throws:
CancelledKeyException - If the key has been cancelled already

interestOps

public abstract SelectionKey interestOps(int operations)
Sets the interesting operation for this key.

Parameters:
operations - the interesting operation to set
Returns:
this key
Throws:
IllegalArgumentException - if the given operation is not in the key's interesting operation set
CancelledKeyException - If the key has been cancelled already

isAcceptable

public final boolean isAcceptable()
Tells whether the channel of this key is interested in accept operation and ready for acceptation.

Returns:
true if the channel is interested in accept operation and ready for acceptation
Throws:
CancelledKeyException - If the key has been cancelled already

isConnectable

public final boolean isConnectable()
Tells whether the channel of this key is interested in connect operation and ready for connection.

Returns:
true if the channel is interested in connect operation and ready for connection
Throws:
CancelledKeyException - If the key has been cancelled already

isReadable

public final boolean isReadable()
Tells whether the channel of this key is interested in read operation and ready for reading.

Returns:
true if the channel is interested in read operation and ready for reading
Throws:
CancelledKeyException - If the key has been cancelled already

isValid

public abstract boolean isValid()
Tells whether the key is valid.

Returns:
true if the key has not been cancelled

isWritable

public final boolean isWritable()
Tells whether the channel of this key is interested in write operation and ready for writing.

Returns:
true if the channel is interested in write operation and ready for writing
Throws:
CancelledKeyException - If the key has been cancelled already

readyOps

public abstract int readyOps()
Gets the ready operation.

Returns:
the ready operation
Throws:
CancelledKeyException - If the key has been cancelled already

selector

public abstract Selector selector()
Gets the related selector.

Returns:
the related selector

Build 1.0_r1(from source)

Please submit a feedback, bug or feature