java.nio.channels
Class Selector

java.lang.Object
  extended by java.nio.channels.Selector
Direct Known Subclasses:
AbstractSelector

public abstract class Selector
extends Object

Since:
1.4

Constructor Summary
protected Selector()
          Initializes the selector.
 
Method Summary
abstract  void close()
          Closes the selector.
abstract  boolean isOpen()
          Tells whether the selector is open or not.
abstract  Set<SelectionKey> keys()
          Returns this selector's key set.
static Selector open()
          Opens a selector.
abstract  SelectorProvider provider()
          Returns the SelectorProvider that created the selector.
abstract  int select()
          Selects a set of keys whose corresponding channels are ready for I/O operations.
abstract  int select(long timeout)
          Selects a set of keys whose corresponding channels are ready for I/O operations.
abstract  Set<SelectionKey> selectedKeys()
          Returns this selector's selected-key set.
abstract  int selectNow()
          Selects a set of keys whose corresponding channels are ready for I/O operations.
abstract  Selector wakeup()
          Causes the first selection operation that has not yet returned to return immediately.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Selector

protected Selector()
Initializes the selector.

Method Detail

open

public static Selector open()
                     throws IOException
Opens a selector.

Throws:
IOException - If an error occurs

close

public abstract void close()
                    throws IOException
Closes the selector.

Throws:
IOException - If an error occurs

isOpen

public abstract boolean isOpen()
Tells whether the selector is open or not.


keys

public abstract Set<SelectionKey> keys()
Returns this selector's key set.

Throws:
ClosedSelectorException - If this selector is closed.

provider

public abstract SelectorProvider provider()
Returns the SelectorProvider that created the selector.


select

public abstract int select()
                    throws IOException
Selects a set of keys whose corresponding channels are ready for I/O operations.

Throws:
ClosedSelectorException - If this selector is closed.
IOException - If an error occurs

select

public abstract int select(long timeout)
                    throws IOException
Selects a set of keys whose corresponding channels are ready for I/O operations.

Parameters:
timeout - The timeout to use.
Throws:
ClosedSelectorException - If this selector is closed.
IllegalArgumentException - If the timeout value is negative.
IOException - If an error occurs

selectedKeys

public abstract Set<SelectionKey> selectedKeys()
Returns this selector's selected-key set.

Throws:
ClosedSelectorException - If this selector is closed.

selectNow

public abstract int selectNow()
                       throws IOException
Selects a set of keys whose corresponding channels are ready for I/O operations.

Throws:
ClosedSelectorException - If this selector is closed.
IOException - If an error occurs

wakeup

public abstract Selector wakeup()
Causes the first selection operation that has not yet returned to return immediately.