# AbstractSelectionKey

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Inherited Constants](https://developer.android.com/reference/java/nio/channels/spi/AbstractSelectionKey#inhconstants)\|[Protected Ctors](https://developer.android.com/reference/java/nio/channels/spi/AbstractSelectionKey#proctors)\|[Methods](https://developer.android.com/reference/java/nio/channels/spi/AbstractSelectionKey#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/java/nio/channels/spi/AbstractSelectionKey#inhmethods)  

# AbstractSelectionKey

`
public


abstract
class
AbstractSelectionKey
`  
`


``

extends `[SelectionKey](https://developer.android.com/reference/java/nio/channels/SelectionKey)`


``


`

|---|---|--------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [java.nio.channels.SelectionKey](https://developer.android.com/reference/java/nio/channels/SelectionKey) ||
|   | ↳ | java.nio.channels.spi.AbstractSelectionKey |

<br />

*** ** * ** ***

Base implementation class for selection keys.

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

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                                                       ### Inherited constants                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From class[java.nio.channels.SelectionKey](https://developer.android.com/reference/java/nio/channels/SelectionKey) |-------|--------------------------------------------------------------------------------------------------------------------------------------------------| | `int` | [OP_ACCEPT](https://developer.android.com/reference/java/nio/channels/SelectionKey#OP_ACCEPT) Operation-set bit for socket-accept operations.    | | `int` | [OP_CONNECT](https://developer.android.com/reference/java/nio/channels/SelectionKey#OP_CONNECT) Operation-set bit for socket-connect operations. | | `int` | [OP_READ](https://developer.android.com/reference/java/nio/channels/SelectionKey#OP_READ) Operation-set bit for read operations.                 | | `int` | [OP_WRITE](https://developer.android.com/reference/java/nio/channels/SelectionKey#OP_WRITE) Operation-set bit for write operations.              | |

|                                                                               ### Protected constructors                                                                               ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[AbstractSelectionKey](https://developer.android.com/reference/java/nio/channels/spi/AbstractSelectionKey#AbstractSelectionKey())`() ` Initializes a new instance of this class. |

|                                                                            ### Public methods                                                                             ||
|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` final void`    | ` `[cancel](https://developer.android.com/reference/java/nio/channels/spi/AbstractSelectionKey#cancel())`() ` Cancels this key.                         |
| ` final boolean` | ` `[isValid](https://developer.android.com/reference/java/nio/channels/spi/AbstractSelectionKey#isValid())`() ` Tells whether or not this key is valid. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.nio.channels.SelectionKey](https://developer.android.com/reference/java/nio/channels/SelectionKey)` ` |--------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` final `[Object](https://developer.android.com/reference/java/lang/Object)                                  | ` `[attach](https://developer.android.com/reference/java/nio/channels/SelectionKey#attach(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` ob) ` Attaches the given object to this key.                           | | ` final `[Object](https://developer.android.com/reference/java/lang/Object)                                  | ` `[attachment](https://developer.android.com/reference/java/nio/channels/SelectionKey#attachment())`() ` Retrieves the current attachment.                                                                                                               | | ` abstract void`                                                                                             | ` `[cancel](https://developer.android.com/reference/java/nio/channels/SelectionKey#cancel())`() ` Requests that the registration of this key's channel with its selector be cancelled.                                                                    | | ` abstract `[SelectableChannel](https://developer.android.com/reference/java/nio/channels/SelectableChannel) | ` `[channel](https://developer.android.com/reference/java/nio/channels/SelectionKey#channel())`() ` Returns the channel for which this key was created.                                                                                                   | | ` abstract int`                                                                                              | ` `[interestOps](https://developer.android.com/reference/java/nio/channels/SelectionKey#interestOps())`() ` Retrieves this key's interest set.                                                                                                            | | ` abstract `[SelectionKey](https://developer.android.com/reference/java/nio/channels/SelectionKey)           | ` `[interestOps](https://developer.android.com/reference/java/nio/channels/SelectionKey#interestOps(int))`(int ops) ` Sets this key's interest set to the given value.                                                                                    | | ` int`                                                                                                       | ` `[interestOpsAnd](https://developer.android.com/reference/java/nio/channels/SelectionKey#interestOpsAnd(int))`(int ops) ` Atomically sets this key's interest set to the bitwise intersection ("and") of the existing interest set and the given value. | | ` int`                                                                                                       | ` `[interestOpsOr](https://developer.android.com/reference/java/nio/channels/SelectionKey#interestOpsOr(int))`(int ops) ` Atomically sets this key's interest set to the bitwise union ("or") of the existing interest set and the given value.           | | ` final boolean`                                                                                             | ` `[isAcceptable](https://developer.android.com/reference/java/nio/channels/SelectionKey#isAcceptable())`() ` Tests whether this key's channel is ready to accept a new socket connection.                                                                | | ` final boolean`                                                                                             | ` `[isConnectable](https://developer.android.com/reference/java/nio/channels/SelectionKey#isConnectable())`() ` Tests whether this key's channel has either finished, or failed to finish, its socket-connection operation.                               | | ` final boolean`                                                                                             | ` `[isReadable](https://developer.android.com/reference/java/nio/channels/SelectionKey#isReadable())`() ` Tests whether this key's channel is ready for reading.                                                                                          | | ` abstract boolean`                                                                                          | ` `[isValid](https://developer.android.com/reference/java/nio/channels/SelectionKey#isValid())`() ` Tells whether or not this key is valid.                                                                                                               | | ` final boolean`                                                                                             | ` `[isWritable](https://developer.android.com/reference/java/nio/channels/SelectionKey#isWritable())`() ` Tests whether this key's channel is ready for writing.                                                                                          | | ` abstract int`                                                                                              | ` `[readyOps](https://developer.android.com/reference/java/nio/channels/SelectionKey#readyOps())`() ` Retrieves this key's ready-operation set.                                                                                                           | | ` abstract `[Selector](https://developer.android.com/reference/java/nio/channels/Selector)                   | ` `[selector](https://developer.android.com/reference/java/nio/channels/SelectionKey#selector())`() ` Returns the selector for which this key was created.                                                                                                | ||
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Protected constructors

### AbstractSelectionKey

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected AbstractSelectionKey ()
```

Initializes a new instance of this class.

<br />

## Public methods

### cancel

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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 />

<br />

### isValid

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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 />

<br />

|                          Returns                           ||
|-----------|-------------------------------------------------|
| `boolean` | `true`if, and only if, this key is valid <br /> |