java.nio.channels

Class SelectableChannel

public abstract class SelectableChannel extends AbstractInterruptibleChannel

Since: 1.4

Constructor Summary
protected SelectableChannel()
Initializes the channel.
Method Summary
abstract ObjectblockingLock()
Returns the lock of this channel.
abstract SelectableChannelconfigureBlocking(boolean block)
Adjusts this channel's blocking mode.
abstract booleanisBlocking()
Tells whether this channel is blocking or not.
abstract booleanisRegistered()
Tells whether or not this channel is currently registered with any selectors.
abstract SelectionKeykeyFor(Selector sel)
Retrieves the key representing the channel's registration with the given selector.
abstract SelectorProviderprovider()
Returns the provider that created this channel.
SelectionKeyregister(Selector sel, int ops)
Registers this channel with the given selector, returning a selection key.
abstract SelectionKeyregister(Selector sel, int ops, Object att)
Registers this channel with the given selector, returning a selection key.
abstract intvalidOps()
Returns a set of valid operations on this channel.

Constructor Detail

SelectableChannel

protected SelectableChannel()
Initializes the channel.

Method Detail

blockingLock

public abstract Object blockingLock()
Returns the lock of this channel.

configureBlocking

public abstract SelectableChannel configureBlocking(boolean block)
Adjusts this channel's blocking mode.

Throws: ClosedChannelException If this channel is closed. IllegalBlockingModeException If block is true and this channel is registered with one or more selectors. IOException If an error occurs.

isBlocking

public abstract boolean isBlocking()
Tells whether this channel is blocking or not.

isRegistered

public abstract boolean isRegistered()
Tells whether or not this channel is currently registered with any selectors.

keyFor

public abstract SelectionKey keyFor(Selector sel)
Retrieves the key representing the channel's registration with the given selector.

provider

public abstract SelectorProvider provider()
Returns the provider that created this channel.

register

public final SelectionKey register(Selector sel, int ops)
Registers this channel with the given selector, returning a selection key.

Throws: CancelledKeyException If this channel is currently registered with the given selector but the corresponding key has already been cancelled ClosedChannelException If this channel is closed. IllegalArgumentException If a bit in ops does not correspond to an operation that is supported by this channel, that is, if set & ~validOps() != 0. IllegalBlockingModeException If block is true and this channel is registered with one or more selectors. IllegalSelectorException If this channel was not created by the same provider as the given selector.

register

public abstract SelectionKey register(Selector sel, int ops, Object att)
Registers this channel with the given selector, returning a selection key.

Throws: CancelledKeyException If this channel is currently registered with the given selector but the corresponding key has already been cancelled. ClosedChannelException If this channel is closed. IllegalArgumentException If a bit in ops does not correspond to an operation that is supported by this channel, that is, if set & ~validOps() != 0. IllegalBlockingModeException If block is true and this channel is registered with one or more selectors. IllegalSelectorException If this channel was not created by the same provider as the given selector.

validOps

public abstract int validOps()
Returns a set of valid operations on this channel.