Android
java.nio.channels.spi
public abstract class

java.nio.channels.spi.AbstractSelectableChannel

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

Abstract class for selectable channels.

In this class, there are methods about registering/deregistering a channel, about channel closing. It realize the multi-thread safe.

Known Direct Subclasses

Summary

Protected Constructors

            AbstractSelectableChannel(SelectorProvider selectorProvider)
Constructor for this class.

Public Methods

    final      Object  blockingLock()
Gets the blocking lock which synchronizes the configureBlocking and register methods.
    final      SelectableChannel  configureBlocking(boolean blockingMode)
Set the blocking mode of this channel.
    final      boolean  isBlocking()
Returns if channel is in blocking mode.
  synchronized  final      boolean  isRegistered()
Returns if channel is registered.
  synchronized  final      SelectionKey  keyFor(Selector selector)
Gets the selection key for the channel with the given selector.
    final      SelectorProvider  provider()
Answer the SelectorProvider of this channel.
    final      SelectionKey  register(Selector selector, int interestSet, Object attachment)
Realize the register function.

Protected Methods

  synchronized  final      void  implCloseChannel()
Implement the closing function.
abstract          void  implCloseSelectableChannel()
Implement the closing function of the SelectableChannel.
abstract          void  implConfigureBlocking(boolean blockingMode)
Implement the setting of blocking mode.
Methods inherited from class java.nio.channels.SelectableChannel
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 AbstractSelectableChannel(SelectorProvider selectorProvider)

Constructor for this class.

Parameters

selectorProvider A instance of SelectorProvider

Public Methods

public final Object blockingLock()

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

Returns

  • the blocking object as lock

See Also

public final SelectableChannel configureBlocking(boolean blockingMode)

Set the blocking mode of this channel.

Parameters

blockingMode true for blocking mode; false for non-blocking mode.

Returns

  • this channel

Throws

IOException

public final boolean isBlocking()

Returns if channel is in blocking mode.

Returns

  • true if channel is blocking

See Also

public final synchronized boolean isRegistered()

Returns if channel is registered.

Returns

  • true if channel is registered

See Also

public final synchronized SelectionKey keyFor(Selector selector)

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

Parameters

selector the selector with which this channel may register

Returns

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

public final SelectorProvider provider()

Answer the SelectorProvider of this channel.

Returns

  • The provider of this channel.

See Also

public final SelectionKey register(Selector selector, int interestSet, Object attachment)

Realize the register function.

It registers current channel to the selector, then answer the selection key. The channel must be open and the interest op set must be valid. If the current channel is already registered to the selector, the method only set the new interest op set; otherwise it will call the register in selector, and add the relative key to the key set of the current channel.

Parameters

selector the selector with which this channel shall be registered
interestSet the interesting operation
attachment The attached object, which can be null

Returns

  • the selection key indicates the channel

Protected Methods

protected final synchronized void implCloseChannel()

Implement the closing function.

Throws

IOException

protected abstract void implCloseSelectableChannel()

Implement the closing function of the SelectableChannel.

Throws

IOException If some I/O exception occurred.

protected abstract void implConfigureBlocking(boolean blockingMode)

Implement the setting of blocking mode.

Parameters

blockingMode true for blocking mode; false for non-blocking mode.

Throws

IOException If some I/O exception occurred.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56