java.nio.channels
public
abstract
class
java.nio.channels.SelectionKey
A key that representing the relationship of a channel and the selector.
Known Direct Subclasses
Summary
Constants
|
|
|
Value |
|
int |
OP_ACCEPT |
Interesting operation mask bit for socket-accept operations. |
16 |
0x00000010 |
int |
OP_CONNECT |
Interesting operation mask bit for socket-connect operations. |
8 |
0x00000008 |
int |
OP_READ |
Interesting operation mask bit for read operations. |
1 |
0x00000001 |
int |
OP_WRITE |
Interesting operation mask bit for write operations. |
4 |
0x00000004 |
Protected Constructors
Public Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Constants
public
static
final
int
OP_ACCEPT
Interesting operation mask bit for socket-accept operations.
Constant Value:
16
(0x00000010)
public
static
final
int
OP_CONNECT
Interesting operation mask bit for socket-connect operations.
Constant Value:
8
(0x00000008)
public
static
final
int
OP_READ
Interesting operation mask bit for read operations.
Constant Value:
1
(0x00000001)
public
static
final
int
OP_WRITE
Interesting operation mask bit for write operations.
Constant Value:
4
(0x00000004)
Protected Constructors
protected
SelectionKey()
The constructor.
Public Methods
public
final
Object
attach(Object anObject)
Attaches an object to the key.
Parameters
anObject
| the object to attach |
public
final
Object
attachment()
Gets the attached object.
Returns
- the attached object or null if no object has been attached
public
abstract
void
cancel()
Cancels this key.
Gets the channel of this key.
public
abstract
SelectionKey
interestOps(int operations)
Sets the interesting operation for this key.
Parameters
operations
| the interesting operation to set |
public
abstract
int
interestOps()
Gets the interesting operation of this key.
Returns
- the interesting operation of this key
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
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
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
public
abstract
boolean
isValid()
Tells whether the key is valid.
Returns
- true if the key has not been cancelled
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
public
abstract
int
readyOps()
Gets the ready operation.
public
abstract
Selector
selector()
Gets the related selector.