# AbstractSelectionKey

public abstract class **AbstractSelectionKey** extends [SelectionKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html)  
Base implementation class for selection keys.

This class tracks the validity of the key and implements cancellation.

### Inherited Constant Summary

From class [java.nio.channels.SelectionKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html)

|---|---|---|
| int | [OP_ACCEPT](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html#OP_ACCEPT) | Operation-set bit for socket-accept operations. |
| int | [OP_CONNECT](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html#OP_CONNECT) | Operation-set bit for socket-connect operations. |
| int | [OP_READ](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html#OP_READ) | Operation-set bit for read operations. |
| int | [OP_WRITE](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html#OP_WRITE) | Operation-set bit for write operations. |

### Protected Constructor Summary

|---|---|
|   | [AbstractSelectionKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectionKey.html#AbstractSelectionKey())() Initializes a new instance of this class. |

### Public Method Summary

|---|---|
| final void | [cancel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectionKey.html#cancel())() Cancels this key. |
| final boolean | [isValid](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectionKey.html#isValid())() Tells whether or not this key is valid. |

### Inherited Method Summary

From class [java.nio.channels.SelectionKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html)

|---|---|
| final [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [attach](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html#attach(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) ob) Attaches the given object to this key. |
| final [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [attachment](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html#attachment())() Retrieves the current attachment. |
| abstract void | [cancel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html#cancel())() Requests that the registration of this key's channel with its selector be cancelled. |
| abstract [SelectableChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html) | [channel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html#channel())() Returns the channel for which this key was created. |
| abstract int | [interestOps](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html#interestOps())() Retrieves this key's interest set. |
| abstract [SelectionKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html) | [interestOps](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html#interestOps(int))(int ops) Sets this key's interest set to the given value. |
| final boolean | [isAcceptable](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html#isAcceptable())() Tests whether this key's channel is ready to accept a new socket connection. |
| final boolean | [isConnectable](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html#isConnectable())() Tests whether this key's channel has either finished, or failed to finish, its socket-connection operation. |
| final boolean | [isReadable](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html#isReadable())() Tests whether this key's channel is ready for reading. |
| abstract boolean | [isValid](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html#isValid())() Tells whether or not this key is valid. |
| final boolean | [isWritable](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html#isWritable())() Tests whether this key's channel is ready for writing. |
| abstract int | [readyOps](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html#readyOps())() Retrieves this key's ready-operation set. |
| abstract [Selector](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Selector.html) | [selector](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectionKey.html#selector())() Returns the selector for which this key was created. |

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

## Protected Constructors

#### protected
**AbstractSelectionKey**
()

Initializes a new instance of this class.

## Public Methods

#### public final void
**cancel**
()

Cancels this key.

If this key has not yet been cancelled then it is added to its
selector's cancelled-key set while synchronized on that set.

<br />

#### public final boolean
**isValid**
()

Tells whether or not this key is valid.

A key is valid upon creation and remains so until it is cancelled,
its channel is closed, or its selector is closed.

<br />

##### Returns

- true if, and only if, this key is valid