summaryrefslogtreecommitdiffstats
path: root/libjava/java/nio/channels/spi/AbstractSelector.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java/nio/channels/spi/AbstractSelector.java')
-rw-r--r--libjava/java/nio/channels/spi/AbstractSelector.java61
1 files changed, 43 insertions, 18 deletions
diff --git a/libjava/java/nio/channels/spi/AbstractSelector.java b/libjava/java/nio/channels/spi/AbstractSelector.java
index b657b5ea0d9..b1e206139d0 100644
--- a/libjava/java/nio/channels/spi/AbstractSelector.java
+++ b/libjava/java/nio/channels/spi/AbstractSelector.java
@@ -1,4 +1,4 @@
-/* AbstractSelector.java --
+/* AbstractSelector.java --
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,49 +35,53 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package java.nio.channels.spi;
import java.io.IOException;
import java.nio.channels.ClosedSelectorException;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
-import java.util.Set;
import java.util.HashSet;
+import java.util.Set;
+
public abstract class AbstractSelector extends Selector
{
- private boolean closed = false;
+ private boolean closed;
private SelectorProvider provider;
private HashSet cancelledKeys;
/**
* Initializes the slector.
+ *
+ * @param provider the provider that created this selector
*/
- protected AbstractSelector (SelectorProvider provider)
+ protected AbstractSelector(SelectorProvider provider)
{
this.provider = provider;
this.cancelledKeys = new HashSet();
}
-
+
/**
* Closes the channel.
- *
+ *
* @exception IOException If an error occurs
*/
- public final synchronized void close () throws IOException
+ public final synchronized void close() throws IOException
{
if (closed)
return;
-
+
implCloseSelector();
closed = true;
}
/**
* Tells whether this channel is open or not.
+ *
+ * @return true if channel is open, false otherwise.
*/
- public final boolean isOpen ()
+ public final boolean isOpen()
{
return ! closed;
}
@@ -95,21 +99,25 @@ public abstract class AbstractSelector extends Selector
protected final void end()
{
}
-
+
/**
* Returns the provider for this selector object.
+ *
+ * @return the SelectorProvider object that created this seletor
*/
- public final SelectorProvider provider ()
+ public final SelectorProvider provider()
{
return provider;
}
/**
* Returns the cancelled keys set.
+ *
+ * @return the cancelled keys set
*/
protected final Set cancelledKeys()
{
- if (!isOpen())
+ if (! isOpen())
throw new ClosedSelectorException();
return cancelledKeys;
@@ -118,8 +126,9 @@ public abstract class AbstractSelector extends Selector
/**
* Cancels a selection key.
*/
+
// This method is only called by AbstractSelectionKey.cancel().
- final void cancelKey (AbstractSelectionKey key)
+ final void cancelKey(AbstractSelectionKey key)
{
synchronized (cancelledKeys)
{
@@ -129,13 +138,29 @@ public abstract class AbstractSelector extends Selector
/**
* Closes the channel.
+ *
+ * @exception IOException if an error occurs
*/
- protected abstract void implCloseSelector () throws IOException;
+ protected abstract void implCloseSelector() throws IOException;
- protected abstract SelectionKey register (AbstractSelectableChannel ch,
- int ops, Object att);
+ /**
+ * Registers a channel for the selection process.
+ *
+ * @param ch the channel register
+ * @param ops the interested operations
+ * @param att an attachement to the selection key
+ *
+ * @return the registered selection key
+ */
+ protected abstract SelectionKey register(AbstractSelectableChannel ch,
+ int ops, Object att);
- protected final void deregister (AbstractSelectionKey key)
+ /**
+ * Deregisters the given selection key.
+ *
+ * @param key the key to deregister
+ */
+ protected final void deregister(AbstractSelectionKey key)
{
((AbstractSelectableChannel) key.channel()).removeSelectionKey(key);
}
OpenPOWER on IntegriCloud