Top Description Fields Constructors Methods
sun.nio.ch

public final Class SelectionKeyImpl

extends AbstractSelectionKey
Class Inheritance
Imports
java.io.FileDescriptor, java.lang.invoke.ConstantBootstraps, .MethodHandles, .VarHandle, java.nio.channels.CancelledKeyException, .SelectableChannel, .SelectionKey, .Selector, java.nio.channels.spi.AbstractSelectionKey

An implementation of SelectionKey.

Field Summary

Modifier and TypeField and Description
private final SelChImpl
private int
private static final VarHandle
private volatile int
pack-priv int
private volatile int
private int
private volatile boolean
private final SelectorImpl

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public SelectableChannel
channel()

Implements abstract java.nio.channels.SelectionKey.channel.

Returns the channel for which this key was created.

private void
pack-priv boolean
getAndClearReset()

Clears the reset flag, returning the previous value of the flag

pack-priv FileDescriptor
pack-priv int
pack-priv int
public int
interestOps()

Implements abstract java.nio.channels.SelectionKey.interestOps.

Retrieves this key's interest set.

public SelectionKey
interestOps(int
The new interest set
ops
)

Implements abstract java.nio.channels.SelectionKey.interestOps.

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

public int
interestOpsAnd(int
The interest set to apply
ops
)

Overrides java.nio.channels.SelectionKey.interestOpsAnd.

Atomically sets this key's interest set to the bitwise intersection ("and") of the existing interest set and the given value.

public int
interestOpsOr(int
The interest set to apply
ops
)

Overrides java.nio.channels.SelectionKey.interestOpsOr.

Atomically sets this key's interest set to the bitwise union ("or") of the existing interest set and the given value.

public SelectionKey
nioInterestOps(int ops)

public int
public void
nioReadyOps(int ops)

public int
public int
readyOps()

Implements abstract java.nio.channels.SelectionKey.readyOps.

Retrieves this key's ready-operation set.

pack-priv void
registeredEvents(int events)

pack-priv int
pack-priv void
reset()

Sets the reset flag, re-queues the key, and wakeups up the Selector

public Selector
selector()

Implements abstract java.nio.channels.SelectionKey.selector.

Returns the selector for which this key was created.

pack-priv void
setIndex(int i)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

pack-priv boolean
pack-priv boolean
pack-priv int
Inherited from java.nio.channels.spi.AbstractSelectionKey:
cancelisValid

Field Detail

channelback to summary
private final SelChImpl channel
indexback to summary
private int index
INTERESTOPSback to summary
private static final VarHandle INTERESTOPS
interestOpsback to summary
private volatile int interestOps
lastPolledback to summary
pack-priv int lastPolled
readyOpsback to summary
private volatile int readyOps
registeredEventsback to summary
private int registeredEvents
resetback to summary
private volatile boolean reset
selectorback to summary
private final SelectorImpl selector

Constructor Detail

SelectionKeyImplback to summary
pack-priv SelectionKeyImpl(SelChImpl ch, SelectorImpl sel)

Method Detail

channelback to summary
public SelectableChannel channel()

Implements abstract java.nio.channels.SelectionKey.channel.

Doc from java.nio.channels.SelectionKey.channel.

Returns the channel for which this key was created. This method will continue to return the channel even after the key is cancelled.

Returns:SelectableChannel

This key's channel

Annotations
@Override
ensureValidback to summary
private void ensureValid()
getAndClearResetback to summary
pack-priv boolean getAndClearReset()

Clears the reset flag, returning the previous value of the flag

getFDback to summary
pack-priv FileDescriptor getFD()
getFDValback to summary
pack-priv int getFDVal()
getIndexback to summary
pack-priv int getIndex()
interestOpsback to summary
public int interestOps()

Implements abstract java.nio.channels.SelectionKey.interestOps.

Doc from java.nio.channels.SelectionKey.interestOps.

Retrieves this key's interest set.

It is guaranteed that the returned set will only contain operation bits that are valid for this key's channel.

Returns:int

This key's interest set

Annotations
@Override
interestOpsback to summary
public SelectionKey interestOps(int ops)

Implements abstract java.nio.channels.SelectionKey.interestOps.

Doc from java.nio.channels.SelectionKey.interestOps.

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

This method may be invoked at any time. If this method is invoked while a selection operation is in progress then it has no effect upon that operation; the change to the key's interest set will be seen by the next selection operation.

Parameters
ops:int

The new interest set

Returns:SelectionKey

This selection key

Annotations
@Override
interestOpsAndback to summary
public int interestOpsAnd(int ops)

Overrides java.nio.channels.SelectionKey.interestOpsAnd.

Doc from java.nio.channels.SelectionKey.interestOpsAnd.

Atomically sets this key's interest set to the bitwise intersection ("and") of the existing interest set and the given value. This method is guaranteed to be atomic with respect to other concurrent calls to this method or to interestOpsOr(int).

This method may be invoked at any time. If this method is invoked while a selection operation is in progress then it has no effect upon that operation; the change to the key's interest set will be seen by the next selection operation.

Parameters
ops:int

The interest set to apply

Returns:int

The previous interest set

Annotations
@Override
interestOpsOrback to summary
public int interestOpsOr(int ops)

Overrides java.nio.channels.SelectionKey.interestOpsOr.

Doc from java.nio.channels.SelectionKey.interestOpsOr.

Atomically sets this key's interest set to the bitwise union ("or") of the existing interest set and the given value. This method is guaranteed to be atomic with respect to other concurrent calls to this method or to interestOpsAnd(int).

This method may be invoked at any time. If this method is invoked while a selection operation is in progress then it has no effect upon that operation; the change to the key's interest set will be seen by the next selection operation.

Parameters
ops:int

The interest set to apply

Returns:int

The previous interest set

Annotations
@Override
nioInterestOpsback to summary
public SelectionKey nioInterestOps(int ops)
nioInterestOpsback to summary
public int nioInterestOps()
nioReadyOpsback to summary
public void nioReadyOps(int ops)
nioReadyOpsback to summary
public int nioReadyOps()
readyOpsback to summary
public int readyOps()

Implements abstract java.nio.channels.SelectionKey.readyOps.

Doc from java.nio.channels.SelectionKey.readyOps.

Retrieves this key's ready-operation set.

It is guaranteed that the returned set will only contain operation bits that are valid for this key's channel.

Returns:int

This key's ready-operation set

Annotations
@Override
registeredEventsback to summary
pack-priv void registeredEvents(int events)
registeredEventsback to summary
pack-priv int registeredEvents()
resetback to summary
pack-priv void reset()

Sets the reset flag, re-queues the key, and wakeups up the Selector

selectorback to summary
public Selector selector()

Implements abstract java.nio.channels.SelectionKey.selector.

Doc from java.nio.channels.SelectionKey.selector.

Returns the selector for which this key was created. This method will continue to return the selector even after the key is cancelled.

Returns:Selector

This key's selector

Annotations
@Override
setIndexback to summary
pack-priv void setIndex(int i)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
translateAndSetReadyOpsback to summary
pack-priv boolean translateAndSetReadyOps(int ops)
translateAndUpdateReadyOpsback to summary
pack-priv boolean translateAndUpdateReadyOps(int ops)
translateInterestOpsback to summary
pack-priv int translateInterestOps()