Android
java.nio.channels
public abstract class

java.nio.channels.SelectableChannel

java.lang.Object
java.nio.channels.spi.AbstractInterruptibleChannel Channel InterruptibleChannel
java.nio.channels.SelectableChannel Channel

A channel that can be detected by a selector. The channel can be registered with some selectors, and when invoke select method of the selectors, the channel can be checked if it is readable, writable, connectable or acceptable according to its interesting operation.

Known Direct Subclasses
Known Indirect Subclasses

Summary

Protected Constructors

            SelectableChannel()
Default constructor, can be overridden.

Public Methods

abstract          Object  blockingLock()
Gets the blocking lock which synchronizes the configureBlocking and register methods.
abstract          SelectableChannel  configureBlocking(boolean block)
Sets blocking mode of the channel.
abstract          boolean  isBlocking()
Returns if channel is in blocking mode.
abstract          boolean  isRegistered()
Returns if channel is registered.
abstract          SelectionKey  keyFor(Selector sel)
Gets the selection key for the channel with the given selector.
abstract          SelectorProvider  provider()
Gets the provider of the channel.
abstract          SelectionKey  register(Selector sel, int ops, Object att)
Registers with the given selector with a certain interesting operation and an attached object.
    final      SelectionKey  register(Selector selector, int operations)
Registers with the given selector with a certain interesting operation.
abstract          int  validOps()
Gets the possible interesting operation of the channel.
Methods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel
Methods inherited from class java.lang.Object
Methods inherited from interface java.io.Closeable
Methods inherited from interface java.nio.channels.Channel
Methods inherited from interface java.nio.channels.InterruptibleChannel

Details

Protected Constructors

protected SelectableChannel()

Default constructor, can be overridden.

Public Methods

public abstract Object blockingLock()

Gets the blocking lock which synchronizes the configureBlocking and register methods.

Returns

  • the blocking object as lock

public abstract SelectableChannel configureBlocking(boolean block)

Sets blocking mode of the channel.

Parameters

block true as blocking, false as non-blocking

Returns

  • this channel

Throws

ClosedChannelException If this channel has been closed
IllegalBlockingModeException If the channel has been registered
IOException if I/O error occurs

public abstract boolean isBlocking()

Returns if channel is in blocking mode.

Returns

  • true if channel is blocking

public abstract boolean isRegistered()

Returns if channel is registered.

Returns

  • true if channel is registered

public abstract SelectionKey keyFor(Selector sel)

Gets the selection key for the channel with the given selector.

Parameters

sel the selector with which this channel may register

Returns

  • the selection key for the channel according to the given selector

public abstract SelectorProvider provider()

Gets the provider of the channel.

Returns

  • the provider of the channel

public abstract SelectionKey register(Selector sel, int ops, Object att)

Registers with the given selector with a certain interesting operation and an attached object.

Parameters

sel the selector with which this channel shall be registered
ops the interesting operation
att The attached object, which can be null

Returns

  • the selection key indicates the channel

Throws

ClosedChannelException if the channel is closed
IllegalBlockingModeException If the channel is in blocking mode
IllegalSelectorException If this channel does not have the same provider with the given selector
CancelledKeyException If this channel is registered but its key has been cancelled
IllegalArgumentException If the operation given is unsupported by this channel

public final SelectionKey register(Selector selector, int operations)

Registers with the given selector with a certain interesting operation.

Parameters

selector the selector with which this channel shall be registered
operations the interesting operation

Returns

  • the selection key indicates the channel

Throws

ClosedChannelException if the channel is closed
IllegalBlockingModeException If the channel is in blocking mode
IllegalSelectorException If this channel does not have the same provider as the given selector
CancelledKeyException If this channel is registered but its key has been cancelled
IllegalArgumentException If the operation given is unsupported by this channel

public abstract int validOps()

Gets the possible interesting operation of the channel.

Returns

  • the possible interesting operation of the channel
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:48