Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.nio.channels

Class SelectionKey

java.lang.Object
|
+--java.nio.channels.SelectionKey


public abstract class SelectionKey

extends Object

Since:Author:

Field Summary

static intOP_ACCEPT

static intOP_CONNECT

static intOP_READ

static intOP_WRITE

Constructor Summary

SelectionKey()

Initializes the selection key.

Method Summary

java.lang.Objectattach(java.lang.Object obj)

Attaches obj to the key and returns the old attached object.
java.lang.Objectattachment()

Returns the object attached to the key.
voidcancel()

Requests that the registration of this key's channel with its selector be cancelled.
java.nio.channels.SelectableChannelchannel()

return the channel attached to the key.
intinterestOps()

Returns the key's interest set.
java.nio.channels.SelectionKeyinterestOps(int ops)

Sets this key's interest set to the given value.
booleanisAcceptable()

Tests if the channel attached to this key is ready to accept a new socket connection.
booleanisConnectable()

Tests whether this key's channel has either finished, or failed to finish, its socket-connection operation.
booleanisReadable()

Tests if the channel attached to the key is readable.
booleanisValid()

Tells whether or not this key is valid.
booleanisWritable()

Tests if the channel attached to the key is writable.
intreadyOps()

Retrieves this key's ready-operation set.
java.nio.channels.Selectorselector()

Returns the selector for which this key was created.

Field Details

OP_ACCEPT

public static final int OP_ACCEPT

Since:Author:

OP_CONNECT

public static final int OP_CONNECT


OP_READ

public static final int OP_READ


OP_WRITE

public static final int OP_WRITE


Constructor Details

SelectionKey

protected SelectionKey()

Initializes the selection key.


Method Details

attach

public final Object attach(java.lang.Object obj)

Attaches obj to the key and returns the old attached object.

Parameters:


attachment

public final Object attachment()

Returns the object attached to the key.


cancel

public void cancel()

Requests that the registration of this key's channel with its selector be cancelled.


channel

public SelectableChannel channel()

return the channel attached to the key.


interestOps

public int interestOps()

Returns the key's interest set.

Throws:


interestOps

public SelectionKey interestOps(int ops)

Sets this key's interest set to the given value.

Parameters:

Throws:


isAcceptable

public final boolean isAcceptable()

Tests if the channel attached to this key is ready to accept a new socket connection.

Throws:


isConnectable

public final boolean isConnectable()

Tests whether this key's channel has either finished, or failed to finish, its socket-connection operation.

Throws:


isReadable

public final boolean isReadable()

Tests if the channel attached to the key is readable.

Throws:


isValid

public boolean isValid()

Tells whether or not this key is valid.


isWritable

public final boolean isWritable()

Tests if the channel attached to the key is writable.

Throws:


readyOps

public int readyOps()

Retrieves this key's ready-operation set.

Throws:


selector

public Selector selector()

Returns the selector for which this key was created.