Android
java.nio.channels
public abstract class

java.nio.channels.SelectionKey

java.lang.Object
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.  0x00000008 
int  OP_READ  Interesting operation mask bit for read operations.  0x00000001 
int  OP_WRITE  Interesting operation mask bit for write operations.  0x00000004 

Protected Constructors

            SelectionKey()
The constructor.

Public Methods

    final      Object  attach(Object anObject)
Attaches an object to the key.
    final      Object  attachment()
Gets the attached object.
abstract          void  cancel()
Cancels this key.
abstract          SelectableChannel  channel()
Gets the channel of this key.
abstract          SelectionKey  interestOps(int operations)
Sets the interesting operation for this key.
abstract          int  interestOps()
Gets the interesting operation of this key.
    final      boolean  isAcceptable()
Tells whether the channel of this key is interested in accept operation and ready for acceptation.
    final      boolean  isConnectable()
Tells whether the channel of this key is interested in connect operation and ready for connection.
    final      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.
    final      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

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

Returns

  • the last attached object

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.

public abstract SelectableChannel channel()

Gets the channel of this key.

Returns

  • 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

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

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

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

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

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

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

Throws

CancelledKeyException If the key has been cancelled already

public abstract int readyOps()

Gets the ready operation.

Returns

  • the ready operation

Throws

CancelledKeyException If the key has been cancelled already

public abstract Selector selector()

Gets the related selector.

Returns

  • the related selector
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56