Index: java/nio/channels/DatagramChannel.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/channels/DatagramChannel.java,v
retrieving revision 1.11
diff -u -r1.11 DatagramChannel.java
--- java/nio/channels/DatagramChannel.java 3 Mar 2003 07:09:20 -0000 1.11
+++ java/nio/channels/DatagramChannel.java 8 Apr 2004 20:58:51 -0000
@@ -1,4 +1,4 @@
-/* DatagramChannel.java --
+/* DatagramChannel.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,19 +44,19 @@
import java.nio.channels.spi.AbstractSelectableChannel;
import java.nio.channels.spi.SelectorProvider;
+
/**
* @since 1.4
*/
-public abstract class DatagramChannel
- extends AbstractSelectableChannel
+public abstract class DatagramChannel extends AbstractSelectableChannel
implements ByteChannel, ScatteringByteChannel, GatheringByteChannel
{
/**
* Initializes the channel.
*/
- protected DatagramChannel (SelectorProvider provider)
+ protected DatagramChannel(SelectorProvider provider)
{
- super (provider);
+ super(provider);
}
/**
@@ -64,40 +64,40 @@
*
* @exception IOException If an error occurs
*/
- public static DatagramChannel open () throws IOException
+ public static DatagramChannel open() throws IOException
{
- return SelectorProvider.provider ().openDatagramChannel ();
+ return SelectorProvider.provider().openDatagramChannel();
}
-
+
/**
* Reads data from this channel.
*/
- public final long read (ByteBuffer[] dsts) throws IOException
+ public final long read(ByteBuffer[] dsts) throws IOException
{
long b = 0;
-
+
for (int i = 0; i < dsts.length; i++)
- b += read (dsts[i]);
-
+ b += read(dsts[i]);
+
return b;
}
-
+
/**
* Writes data to this channel.
*
* @exception IOException If an error occurs
* @exception NotYetConnectedException The channel's socket is not connected.
*/
- public final long write (ByteBuffer[] srcs) throws IOException
+ public final long write(ByteBuffer[] srcs) throws IOException
{
long b = 0;
-
- for (int i = 0;i < srcs.length; i++)
- b += write (srcs[i]);
-
+
+ for (int i = 0; i < srcs.length; i++)
+ b += write(srcs[i]);
+
return b;
}
-
+
/**
* Connects this channel's socket.
*
@@ -111,7 +111,7 @@
* @exception SecurityException If a security manager has been installed and
* it does not permit datagrams to be sent to the given address.
*/
- public abstract DatagramChannel connect (SocketAddress remote)
+ public abstract DatagramChannel connect(SocketAddress remote)
throws IOException;
/**
@@ -119,7 +119,7 @@
*
* @exception IOException If an error occurs
*/
- public abstract DatagramChannel disconnect () throws IOException;
+ public abstract DatagramChannel disconnect() throws IOException;
/**
* Tells whether or not this channel's socket is connected.
@@ -127,22 +127,22 @@
* @exception IOException If an error occurs.
* @exception NotYetConnectedException The channel's socket is not connected.
*/
- public abstract boolean isConnected ();
-
+ public abstract boolean isConnected();
+
/**
* Reads data from this channel.
*/
- public abstract int read (ByteBuffer dst) throws IOException;
-
+ public abstract int read(ByteBuffer dst) throws IOException;
+
/**
* Reads data from this channel.
*
* @exception IOException If an error occurs.
* @exception NotYetConnectedException The channel's socket is not connected.
*/
- public abstract long read (ByteBuffer[] dsts, int offset, int length)
+ public abstract long read(ByteBuffer[] dsts, int offset, int length)
throws IOException;
-
+
/**
* Receives a datagram via this channel.
*
@@ -156,8 +156,9 @@
* @exception SecurityException If a security manager has been installed and
* it does not permit datagrams to be sent to the given address.
*/
- public abstract SocketAddress receive (ByteBuffer dst) throws IOException;
-
+ public abstract SocketAddress receive(ByteBuffer dst)
+ throws IOException;
+
/**
* Sends a datagram via this channel.
*
@@ -171,29 +172,29 @@
* @exception SecurityException If a security manager has been installed and
* it does not permit datagrams to be sent to the given address.
*/
- public abstract int send (ByteBuffer src, SocketAddress target)
+ public abstract int send(ByteBuffer src, SocketAddress target)
throws IOException;
-
+
/**
* Retrieves the channel's socket.
*/
- public abstract DatagramSocket socket ();
-
+ public abstract DatagramSocket socket();
+
/**
* Writes data to this channel.
*
* @exception IOException If an error occurs.
* @exception NotYetConnectedException The channel's socket is not connected.
*/
- public abstract int write (ByteBuffer src) throws IOException;
-
+ public abstract int write(ByteBuffer src) throws IOException;
+
/**
* Writes data to this channel.
*
* @exception IOException If an error occurs.
* @exception NotYetConnectedException The channel's socket is not connected.
*/
- public abstract long write (ByteBuffer[] srcs, int offset, int length)
+ public abstract long write(ByteBuffer[] srcs, int offset, int length)
throws IOException;
/**
@@ -202,8 +203,8 @@
* @exception IOException If an error occurs.
* @exception NotYetConnectedException The channel's socket is not connected.
*/
- public final int validOps ()
+ public final int validOps()
{
return SelectionKey.OP_READ | SelectionKey.OP_WRITE;
- }
+ }
}
Index: java/nio/channels/FileChannel.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/channels/FileChannel.java,v
retrieving revision 1.12
diff -u -r1.12 FileChannel.java
--- java/nio/channels/FileChannel.java 27 Feb 2004 11:19:23 -0000 1.12
+++ java/nio/channels/FileChannel.java 8 Apr 2004 20:58:51 -0000
@@ -1,4 +1,4 @@
-/* FileChannel.java --
+/* FileChannel.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,6 +42,7 @@
import java.nio.MappedByteBuffer;
import java.nio.channels.spi.AbstractInterruptibleChannel;
+
/**
* @author Michael Koch
* @since 1.4
@@ -52,10 +53,9 @@
public static class MapMode
{
int m;
-
- public static final MapMode READ_ONLY = new MapMode(0);
+ public static final MapMode READ_ONLY = new MapMode(0);
public static final MapMode READ_WRITE = new MapMode(1);
- public static final MapMode PRIVATE = new MapMode(2);
+ public static final MapMode PRIVATE = new MapMode(2);
/**
* Initializes the MapMode.
@@ -68,12 +68,12 @@
/**
* Returns a string representation of the MapMode
object.
*/
- public String toString()
+ public String toString()
{
if (this == READ_ONLY)
- return "READ_ONLY";
+ return "READ_ONLY";
else if (this == READ_WRITE)
- return "READ_WRITE";
+ return "READ_WRITE";
return "PRIVATE";
}
@@ -82,7 +82,7 @@
/**
* Initializes the channel.
*/
- protected FileChannel ()
+ protected FileChannel()
{
}
@@ -102,34 +102,32 @@
/**
* Return the size of the file thus far
- *
+ *
* @exception ClosedChannelException If this channel is closed.
*/
public abstract long size() throws IOException;
-
+
/**
* Writes data to the channel.
*
* @exception IOException If an I/O error occurs.
*/
- public final long write (ByteBuffer[] srcs) throws IOException
+ public final long write(ByteBuffer[] srcs) throws IOException
{
long result = 0;
-
+
for (int i = 0; i < srcs.length; i++)
- {
- result += write (srcs[i]);
- }
-
+ result += write(srcs[i]);
+
return result;
}
-
+
/**
* Writes data to the channel.
*
* @exception IOException If an I/O error occurs.
*/
- public abstract int write (ByteBuffer src) throws IOException;
+ public abstract int write(ByteBuffer src) throws IOException;
/**
* Writes data to the channel.
@@ -145,7 +143,8 @@
* @exception NonWritableChannelException If this channel was not opened for
* writing.
*/
- public abstract int write (ByteBuffer srcs, long position) throws IOException;
+ public abstract int write(ByteBuffer srcs, long position)
+ throws IOException;
/**
* Writes data to the channel.
@@ -154,13 +153,13 @@
*/
public abstract long write(ByteBuffer[] srcs, int offset, int length)
throws IOException;
-
+
/**
* Reads data from the channel.
*
* @exception IOException If an I/O error occurs.
*/
- public abstract long read (ByteBuffer[] dsts, int offset, int length)
+ public abstract long read(ByteBuffer[] dsts, int offset, int length)
throws IOException;
/**
@@ -168,14 +167,12 @@
*
* @exception IOException If an I/O error occurs.
*/
- public final long read (ByteBuffer[] dsts) throws IOException
+ public final long read(ByteBuffer[] dsts) throws IOException
{
long result = 0;
-
+
for (int i = 0; i < dsts.length; i++)
- {
- read (dsts [i]);
- }
+ read(dsts[i]);
return result;
}
@@ -186,7 +183,7 @@
* @exception IOException If an I/O error occurs.
*/
public abstract int read(ByteBuffer dst) throws IOException;
-
+
/**
* Reads data from the channel.
*
@@ -201,8 +198,9 @@
* @exception NonReadableChannelException If this channel was not opened for
* reading.
*/
- public abstract int read(ByteBuffer dst, long position) throws IOException;
-
+ public abstract int read(ByteBuffer dst, long position)
+ throws IOException;
+
/**
* Closes the channel.
*
@@ -238,9 +236,9 @@
* another thread is already blocked in this method and is attempting to lock
* an overlapping region.
*/
- public final FileLock lock () throws IOException
+ public final FileLock lock() throws IOException
{
- return lock (0, Long.MAX_VALUE, false);
+ return lock(0, Long.MAX_VALUE, false);
}
/**
@@ -263,7 +261,7 @@
* @exception NonWritableChannelException If shared is false and this channel
* was not opened for writing.
*/
- public abstract FileLock lock (long position, long size, boolean shared)
+ public abstract FileLock lock(long position, long size, boolean shared)
throws IOException;
/**
@@ -276,9 +274,9 @@
* another thread is already blocked in this method and is attempting to lock
* an overlapping region.
*/
- public final FileLock tryLock () throws IOException
+ public final FileLock tryLock() throws IOException
{
- return tryLock (0, Long.MAX_VALUE, false);
+ return tryLock(0, Long.MAX_VALUE, false);
}
/**
@@ -293,7 +291,7 @@
* another thread is already blocked in this method and is attempting to lock
* an overlapping region.
*/
- public abstract FileLock tryLock (long position, long size, boolean shared)
+ public abstract FileLock tryLock(long position, long size, boolean shared)
throws IOException;
/**
@@ -302,7 +300,7 @@
* @exception ClosedChannelException If this channel is closed.
* @exception IOException If an I/O error occurs.
*/
- public abstract long position () throws IOException;
+ public abstract long position() throws IOException;
/**
* Sets the position of the channel on the assoziated file.
@@ -311,7 +309,8 @@
* @exception IllegalArgumentException If newPosition is negative.
* @exception IOException If an I/O error occurs.
*/
- public abstract FileChannel position (long newPosition) throws IOException;
+ public abstract FileChannel position(long newPosition)
+ throws IOException;
/**
* Transfers bytes from this channel's file to the given writable byte
@@ -331,8 +330,8 @@
* @exception NonWritableChannelException If the target channel was not
* opened for writing.
*/
- public abstract long transferTo (long position, long count,
- WritableByteChannel target)
+ public abstract long transferTo(long position, long count,
+ WritableByteChannel target)
throws IOException;
/**
@@ -352,8 +351,8 @@
* @exception NonWritableChannelException If this channel was not opened for
* writing.
*/
- public abstract long transferFrom (ReadableByteChannel src, long position,
- long count) throws IOException;
+ public abstract long transferFrom(ReadableByteChannel src, long position,
+ long count) throws IOException;
/**
* Truncates the channel's file at size
.
@@ -364,5 +363,5 @@
* @exception NonWritableChannelException If this channel was not opened for
* writing.
*/
- public abstract FileChannel truncate (long size) throws IOException;
+ public abstract FileChannel truncate(long size) throws IOException;
}
Index: java/nio/channels/FileLock.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/channels/FileLock.java,v
retrieving revision 1.6
diff -u -r1.6 FileLock.java
--- java/nio/channels/FileLock.java 18 May 2003 06:36:35 -0000 1.6
+++ java/nio/channels/FileLock.java 8 Apr 2004 20:58:51 -0000
@@ -1,4 +1,4 @@
-/* FileLock.java --
+/* FileLock.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,6 +39,7 @@
import java.io.IOException;
+
/**
* @since 1.4
*/
@@ -48,42 +49,41 @@
long position;
long size;
boolean shared;
-
+
/**
* Initializes the file lock.
*
* @exception IllegalArgumentException If the preconditions on the parameters do not hold
*/
- protected FileLock (FileChannel channel, long position, long size,
- boolean shared)
+ protected FileLock(FileChannel channel, long position, long size,
+ boolean shared)
{
- if (position < 0 ||
- size < 0)
- throw new IllegalArgumentException ();
+ if (position < 0 || size < 0)
+ throw new IllegalArgumentException();
this.channel = channel;
this.position = position;
this.size = size;
this.shared = shared;
}
-
+
/**
* Tells whether or not this lock is valid.
*/
public abstract boolean isValid();
-
+
/**
* Releases this lock.
*
* @exception IOException If an error occurs
* @exception ClosedChannelException If the locked channel is no longer open.
*/
- public abstract void release () throws IOException;
-
+ public abstract void release() throws IOException;
+
/**
* Returns the file channel upon whose file this lock is held.
*/
- public final FileChannel channel ()
+ public final FileChannel channel()
{
return channel;
}
@@ -91,15 +91,15 @@
/**
* Tells whether this lock is shared.
*/
- public final boolean isShared ()
+ public final boolean isShared()
{
return shared;
- }
+ }
/**
* Tells whether or not this lock overlaps the given lock range.
*/
- public final boolean overlaps (long position, long size)
+ public final boolean overlaps(long position, long size)
{
if (position > this.position + this.size)
return false;
@@ -114,15 +114,15 @@
* Returns the position within the file of the first byte of the
* locked region.
*/
- public final long position ()
+ public final long position()
{
return position;
}
-
+
/**
* Returns the size of the locked region in bytes.
*/
- public final long size ()
+ public final long size()
{
return size;
}
@@ -130,7 +130,7 @@
/**
* Returns a string describing the range, type, and validity of this lock.
*/
- public final String toString ()
+ public final String toString()
{
return "file-lock:pos=" + position + "size=" + size;
}
Index: java/nio/channels/Pipe.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/channels/Pipe.java,v
retrieving revision 1.6
diff -u -r1.6 Pipe.java
--- java/nio/channels/Pipe.java 21 Dec 2002 11:42:37 -0000 1.6
+++ java/nio/channels/Pipe.java 8 Apr 2004 20:58:51 -0000
@@ -1,4 +1,4 @@
-/* Pipe.java --
+/* Pipe.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,22 +41,22 @@
import java.nio.channels.spi.AbstractSelectableChannel;
import java.nio.channels.spi.SelectorProvider;
+
/**
* @author Michael Koch
* @since 1.4
*/
public abstract class Pipe
{
- public abstract static class SinkChannel
- extends AbstractSelectableChannel
+ public abstract static class SinkChannel extends AbstractSelectableChannel
implements WritableByteChannel, GatheringByteChannel
{
/**
* Initializes the channel.
*/
- protected SinkChannel (SelectorProvider provider)
+ protected SinkChannel(SelectorProvider provider)
{
- super (provider);
+ super(provider);
}
/**
@@ -64,22 +64,21 @@
*
* The only valid operation on this channel is @see SelectionKey.OP_WRITE.
*/
- public final int validOps ()
+ public final int validOps()
{
return SelectionKey.OP_WRITE;
}
}
- public abstract static class SourceChannel
- extends AbstractSelectableChannel
+ public abstract static class SourceChannel extends AbstractSelectableChannel
implements ReadableByteChannel, ScatteringByteChannel
{
/**
* Initializes the channel.
*/
- protected SourceChannel (SelectorProvider provider)
+ protected SourceChannel(SelectorProvider provider)
{
- super (provider);
+ super(provider);
}
/**
@@ -87,7 +86,7 @@
*
* The only valid operation on this channel is @see SelectionKey.OP_READ.
*/
- public final int validOps ()
+ public final int validOps()
{
return SelectionKey.OP_READ;
}
@@ -102,12 +101,12 @@
/**
* Opens a pipe.
- *
+ *
* @exception IOException If an error occurs
*/
public static Pipe open() throws IOException
{
- return SelectorProvider.provider ().openPipe();
+ return SelectorProvider.provider().openPipe();
}
/**
@@ -118,5 +117,5 @@
/**
* Returns a pipe's source channel
*/
- public abstract Pipe.SourceChannel source();
+ public abstract Pipe.SourceChannel source();
}
Index: java/nio/channels/ServerSocketChannel.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/channels/ServerSocketChannel.java,v
retrieving revision 1.9
diff -u -r1.9 ServerSocketChannel.java
--- java/nio/channels/ServerSocketChannel.java 26 Jun 2003 19:52:43 -0000 1.9
+++ java/nio/channels/ServerSocketChannel.java 8 Apr 2004 20:58:52 -0000
@@ -1,4 +1,4 @@
-/* ServerSocketChannel.java --
+/* ServerSocketChannel.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,29 +35,28 @@
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package java.nio.channels;
-import java.nio.channels.spi.AbstractSelectableChannel;
-import java.nio.channels.spi.SelectorProvider;
import java.io.IOException;
import java.net.ServerSocket;
+import java.nio.channels.spi.AbstractSelectableChannel;
+import java.nio.channels.spi.SelectorProvider;
+
/**
* @author Michael Koch
* @since 1.4
*/
-public abstract class ServerSocketChannel
- extends AbstractSelectableChannel
+public abstract class ServerSocketChannel extends AbstractSelectableChannel
{
/**
* Initializes this channel.
*/
- protected ServerSocketChannel (SelectorProvider provider)
+ protected ServerSocketChannel(SelectorProvider provider)
{
- super (provider);
+ super(provider);
}
-
+
/**
* Accepts a connection made to this channel's socket.
*
@@ -72,28 +71,28 @@
* @exception SecurityException If a security manager has been installed and
* it does not permit access to the remote endpoint of the new connection.
*/
- public abstract SocketChannel accept () throws IOException;
-
+ public abstract SocketChannel accept() throws IOException;
+
/**
* Retrieves the channels socket.
*/
- public abstract ServerSocket socket ();
-
+ public abstract ServerSocket socket();
+
/**
* Opens a server socket channel.
*
* @exception IOException If an error occurs
*/
- public static ServerSocketChannel open () throws IOException
+ public static ServerSocketChannel open() throws IOException
{
- return SelectorProvider.provider ().openServerSocketChannel ();
+ return SelectorProvider.provider().openServerSocketChannel();
}
/**
* Retrieves the valid operations for this channel.
*/
- public final int validOps ()
+ public final int validOps()
{
return SelectionKey.OP_ACCEPT;
- }
+ }
}
Index: java/nio/channels/SocketChannel.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/channels/SocketChannel.java,v
retrieving revision 1.10
diff -u -r1.10 SocketChannel.java
--- java/nio/channels/SocketChannel.java 27 Feb 2004 11:19:23 -0000 1.10
+++ java/nio/channels/SocketChannel.java 8 Apr 2004 20:58:52 -0000
@@ -1,4 +1,4 @@
-/* SocketChannel.java --
+/* SocketChannel.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,38 +37,39 @@
package java.nio.channels;
-import java.nio.channels.spi.AbstractSelectableChannel;
-import java.nio.channels.spi.SelectorProvider;
-import java.nio.ByteBuffer;
import java.io.IOException;
import java.net.Socket;
import java.net.SocketAddress;
+import java.nio.ByteBuffer;
+import java.nio.channels.spi.AbstractSelectableChannel;
+import java.nio.channels.spi.SelectorProvider;
+
/**
* @author Michael Koch
* @since 1.4
*/
-abstract public class SocketChannel extends AbstractSelectableChannel
+public abstract class SocketChannel extends AbstractSelectableChannel
implements ByteChannel, ScatteringByteChannel, GatheringByteChannel
{
/**
* Initializes this socket.
*/
- protected SocketChannel (SelectorProvider provider)
+ protected SocketChannel(SelectorProvider provider)
{
- super (provider);
+ super(provider);
}
-
+
/**
* Opens a socket channel.
*
* @exception IOException If an error occurs
*/
- public static SocketChannel open () throws IOException
+ public static SocketChannel open() throws IOException
{
- return SelectorProvider.provider ().openSocketChannel ();
+ return SelectorProvider.provider().openSocketChannel();
}
-
+
/**
* Opens a channel and connects it to a remote address.
*
@@ -84,55 +85,53 @@
* @exception UnsupportedAddressTypeException If the type of the given remote
* address is not supported.
*/
- public static SocketChannel open (SocketAddress remote) throws IOException
+ public static SocketChannel open(SocketAddress remote)
+ throws IOException
{
- SocketChannel ch = open ();
+ SocketChannel ch = open();
ch.connect(remote);
return ch;
}
-
+
/**
* Reads data from the channel.
*
* @exception IOException If an error occurs
* @exception NotYetConnectedException If this channel is not yet connected.
*/
- public final long read (ByteBuffer[] dsts) throws IOException
+ public final long read(ByteBuffer[] dsts) throws IOException
{
long b = 0;
-
+
for (int i = 0; i < dsts.length; i++)
- {
- b += read (dsts [i]);
- }
-
+ b += read(dsts[i]);
+
return b;
}
-
+
/**
* Writes data to the channel.
*
* @exception IOException If an error occurs
* @exception NotYetConnectedException If this channel is not yet connected.
*/
- public final long write (ByteBuffer[] dsts) throws IOException
+ public final long write(ByteBuffer[] dsts) throws IOException
{
long b = 0;
- for (int i= 0; i < dsts.length; i++)
- {
- b += write (dsts [i]);
- }
-
+ for (int i = 0; i < dsts.length; i++)
+ b += write(dsts[i]);
+
return b;
- }
-
+ }
+
/**
* Retrieves the valid operations for this channel.
*/
- public final int validOps ()
+ public final int validOps()
{
- return SelectionKey.OP_CONNECT | SelectionKey.OP_READ | SelectionKey.OP_WRITE;
+ return SelectionKey.OP_CONNECT | SelectionKey.OP_READ
+ | SelectionKey.OP_WRITE;
}
/**
@@ -141,7 +140,7 @@
* @exception IOException If an error occurs
* @exception NotYetConnectedException If this channel is not yet connected.
*/
- public abstract int read (ByteBuffer dst) throws IOException;
+ public abstract int read(ByteBuffer dst) throws IOException;
/**
* Connects the channel's socket to the remote address.
@@ -162,8 +161,9 @@
* @exception UnsupportedAddressTypeException If the type of the given remote
* address is not supported.
*/
- public abstract boolean connect (SocketAddress remote) throws IOException;
-
+ public abstract boolean connect(SocketAddress remote)
+ throws IOException;
+
/**
* Finishes the process of connecting a socket channel.
*
@@ -176,46 +176,46 @@
* @exception NoConnectionPendingException If this channel is not connected
* and a connection operation has not been initiated.
*/
- public abstract boolean finishConnect () throws IOException;
-
+ public abstract boolean finishConnect() throws IOException;
+
/**
* Tells whether or not the channel's socket is connected.
*/
- public abstract boolean isConnected ();
-
+ public abstract boolean isConnected();
+
/**
* Tells whether or not a connection operation is in progress on this channel.
*/
- public abstract boolean isConnectionPending ();
-
+ public abstract boolean isConnectionPending();
+
/**
* Reads data from the channel.
*
* @exception IOException If an error occurs
* @exception NotYetConnectedException If this channel is not yet connected.
*/
- public abstract long read (ByteBuffer[] dsts, int offset, int length)
+ public abstract long read(ByteBuffer[] dsts, int offset, int length)
throws IOException;
-
+
/**
* Retrieves the channel's socket.
*/
- public abstract Socket socket ();
-
+ public abstract Socket socket();
+
/**
* Writes data to the channel.
*
* @exception IOException If an error occurs
* @exception NotYetConnectedException If this channel is not yet connected.
*/
- public abstract int write (ByteBuffer src) throws IOException;
-
+ public abstract int write(ByteBuffer src) throws IOException;
+
/**
* Writes data to the channel.
*
* @exception IOException If an error occurs
* @exception NotYetConnectedException If this channel is not yet connected.
*/
- public abstract long write (ByteBuffer[] srcs, int offset, int length)
+ public abstract long write(ByteBuffer[] srcs, int offset, int length)
throws IOException;
}
Index: java/nio/channels/spi/AbstractInterruptibleChannel.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/channels/spi/AbstractInterruptibleChannel.java,v
retrieving revision 1.7
diff -u -r1.7 AbstractInterruptibleChannel.java
--- java/nio/channels/spi/AbstractInterruptibleChannel.java 17 Feb 2004 21:16:28 -0000 1.7
+++ java/nio/channels/spi/AbstractInterruptibleChannel.java 8 Apr 2004 20:58:52 -0000
@@ -1,4 +1,4 @@
-/* AbstractInterruptibleChannel.java --
+/* AbstractInterruptibleChannel.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,6 +42,7 @@
import java.nio.channels.Channel;
import java.nio.channels.InterruptibleChannel;
+
/**
* @author Michael Koch
* @since 1.4
@@ -54,25 +55,25 @@
/**
* Initializes the channel.
*/
- protected AbstractInterruptibleChannel ()
+ protected AbstractInterruptibleChannel()
{
}
/**
* Marks the beginning of an I/O operation that might block indefinitely.
*/
- protected final void begin ()
+ protected final void begin()
{
}
-
+
/**
* Closes the channel.
- *
+ *
* @exception IOException If an error occurs
*/
- public final void close () throws IOException
+ public final void close() throws IOException
{
- if (!closed)
+ if (! closed)
{
closed = true;
implCloseChannel();
@@ -81,29 +82,35 @@
/**
* Marks the end of an I/O operation that might block indefinitely.
- *
+ *
+ * @param completed true if the task completed successfully,
+ * false otherwise
+ *
+ * @exception IOException if an error occurs
* @exception AsynchronousCloseException If the channel was asynchronously
* closed.
* @exception ClosedByInterruptException If the thread blocked in the
* I/O operation was interrupted.
*/
- protected final void end (boolean completed)
+ protected final void end(boolean completed)
throws AsynchronousCloseException
{
- }
+ }
/**
* Closes the channel.
- *
+ *
* @exception IOException If an error occurs
*/
- protected abstract void implCloseChannel () throws IOException;
+ protected abstract void implCloseChannel() throws IOException;
/**
* Tells whether or not this channel is open.
+ *
+ * @return true if the channel is open, false otherwise
*/
- public final boolean isOpen ()
+ public final boolean isOpen()
{
- return !closed;
+ return ! closed;
}
}
Index: java/nio/channels/spi/AbstractSelectableChannel.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/channels/spi/AbstractSelectableChannel.java,v
retrieving revision 1.14
diff -u -r1.14 AbstractSelectableChannel.java
--- java/nio/channels/spi/AbstractSelectableChannel.java 19 Mar 2004 21:22:24 -0000 1.14
+++ java/nio/channels/spi/AbstractSelectableChannel.java 8 Apr 2004 20:58:52 -0000
@@ -43,9 +43,9 @@
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.util.LinkedList;
-import java.util.List;
import java.util.ListIterator;
+
public abstract class AbstractSelectableChannel extends SelectableChannel
{
private boolean blocking = true;
@@ -55,8 +55,10 @@
/**
* Initializes the channel
+ *
+ * @param provider the provider that created this channel
*/
- protected AbstractSelectableChannel (SelectorProvider provider)
+ protected AbstractSelectableChannel(SelectorProvider provider)
{
this.provider = provider;
}
@@ -64,27 +66,35 @@
/**
* Retrieves the object upon which the configureBlocking and register
* methods synchronize.
+ *
+ * @return the blocking lock
*/
- public final Object blockingLock ()
+ public final Object blockingLock()
{
return LOCK;
}
-
+
/**
* Adjusts this channel's blocking mode.
+ *
+ * @param blocking true if blocking should be enabled, false otherwise
+ *
+ * @return this channel
+ *
+ * @exception IOException If an error occurs
*/
- public final SelectableChannel configureBlocking (boolean blocking)
+ public final SelectableChannel configureBlocking(boolean blocking)
throws IOException
{
synchronized (blockingLock())
{
- if (this.blocking != blocking)
- {
- implConfigureBlocking(blocking);
- this.blocking = blocking;
- }
+ if (this.blocking != blocking)
+ {
+ implConfigureBlocking(blocking);
+ this.blocking = blocking;
+ }
}
-
+
return this;
}
@@ -93,25 +103,34 @@
*
* @exception IOException If an error occurs
*/
- protected final void implCloseChannel () throws IOException
+ protected final void implCloseChannel() throws IOException
{
- implCloseSelectableChannel ();
+ implCloseSelectableChannel();
}
/**
* Closes this selectable channel.
+ *
+ * @exception IOException If an error occurs
*/
- protected abstract void implCloseSelectableChannel () throws IOException;
-
+ protected abstract void implCloseSelectableChannel()
+ throws IOException;
+
/**
* Adjusts this channel's blocking mode.
+ *
+ * @param blocking true if blocking should be enabled, false otherwise
+ *
+ * @exception IOException If an error occurs
*/
- protected abstract void implConfigureBlocking (boolean block)
+ protected abstract void implConfigureBlocking(boolean blocking)
throws IOException;
/**
* Tells whether or not every I/O operation on this channel will block
* until it completes.
+ *
+ * @return true of this channel is blocking, false otherwise
*/
public final boolean isBlocking()
{
@@ -121,66 +140,80 @@
/**
* Tells whether or not this channel is currently registered with
* any selectors.
+ *
+ * @return true if this channel is registered, false otherwise
*/
public final boolean isRegistered()
{
- return !keys.isEmpty();
+ return ! keys.isEmpty();
}
/**
* Retrieves the key representing the channel's registration with the
* given selector.
+ *
+ * @param selector the selector to get a selection key for
+ *
+ * @return the selection key this channel is registered with
*/
public final SelectionKey keyFor(Selector selector)
{
if (! isOpen())
return null;
-
+
try
{
- synchronized(blockingLock())
+ synchronized (blockingLock())
{
- return locate (selector);
+ return locate(selector);
}
}
catch (Exception e)
{
- return null;
+ return null;
}
}
/**
* Returns the provider that created this channel.
+ *
+ * @return the selector provider that created this channel
*/
- public final SelectorProvider provider ()
+ public final SelectorProvider provider()
{
return provider;
}
- private SelectionKey locate (Selector selector)
+ private SelectionKey locate(Selector selector)
{
- ListIterator it = keys.listIterator ();
-
- while (it.hasNext ())
+ ListIterator it = keys.listIterator();
+
+ while (it.hasNext())
{
- SelectionKey key = (SelectionKey) it.next();
-
- if (key.selector() == selector)
- return key;
+ SelectionKey key = (SelectionKey) it.next();
+
+ if (key.selector() == selector)
+ return key;
}
-
+
return null;
}
/**
* Registers this channel with the given selector, returning a selection key.
*
+ * @param selin the seletor to use
+ * @param ops the interested operations
+ * @param att an attachment for the returned selection key
+ *
+ * @return the registered selection key
+ *
* @exception ClosedChannelException If the channel is already closed.
*/
- public final SelectionKey register (Selector selin, int ops, Object att)
+ public final SelectionKey register(Selector selin, int ops, Object att)
throws ClosedChannelException
{
- if (!isOpen ())
+ if (! isOpen())
throw new ClosedChannelException();
SelectionKey key = null;
@@ -188,20 +221,20 @@
synchronized (blockingLock())
{
- key = locate (selector);
+ key = locate(selector);
- if (key != null)
- {
+ if (key != null)
+ {
if (att != null)
- key.attach (att);
- }
- else
- {
- key = selector.register (this, ops, att);
-
- if (key != null)
- addSelectionKey (key);
- }
+ key.attach(att);
+ }
+ else
+ {
+ key = selector.register(this, ops, att);
+
+ if (key != null)
+ addSelectionKey(key);
+ }
}
return key;
Index: java/nio/channels/spi/AbstractSelectionKey.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/channels/spi/AbstractSelectionKey.java,v
retrieving revision 1.7
diff -u -r1.7 AbstractSelectionKey.java
--- java/nio/channels/spi/AbstractSelectionKey.java 19 Mar 2004 21:22:24 -0000 1.7
+++ java/nio/channels/spi/AbstractSelectionKey.java 8 Apr 2004 20:58:52 -0000
@@ -1,4 +1,4 @@
-/* AbstractSelectionKey.java --
+/* AbstractSelectionKey.java --
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,38 +39,40 @@
import java.nio.channels.SelectionKey;
+
/**
* @since 1.4
*/
-public abstract class AbstractSelectionKey
- extends SelectionKey
+public abstract class AbstractSelectionKey extends SelectionKey
{
- private boolean cancelled = false;
+ private boolean cancelled;
/**
* Initializes the key.
*/
- protected AbstractSelectionKey ()
+ protected AbstractSelectionKey()
{
}
/**
* Cancels this key.
*/
- public final void cancel ()
+ public final void cancel()
{
if (isValid())
{
((AbstractSelector) selector()).cancelKey(this);
- cancelled = true;
+ cancelled = true;
}
}
/**
* Tells whether this key is valid or not.
+ *
+ * @return true if this key is valid, false otherwise
*/
- public final boolean isValid ()
+ public final boolean isValid()
{
- return !cancelled;
+ return ! cancelled;
}
}
Index: java/nio/channels/spi/AbstractSelector.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/channels/spi/AbstractSelector.java,v
retrieving revision 1.9
diff -u -r1.9 AbstractSelector.java
--- java/nio/channels/spi/AbstractSelector.java 19 Mar 2004 21:22:24 -0000 1.9
+++ java/nio/channels/spi/AbstractSelector.java 8 Apr 2004 20:58:52 -0000
@@ -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 @@
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 @@
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 @@
/**
* 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 @@
/**
* 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);
}
Index: java/nio/channels/spi/SelectorProvider.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/channels/spi/SelectorProvider.java,v
retrieving revision 1.8
diff -u -r1.8 SelectorProvider.java
--- java/nio/channels/spi/SelectorProvider.java 12 Oct 2003 16:56:00 -0000 1.8
+++ java/nio/channels/spi/SelectorProvider.java 8 Apr 2004 20:58:52 -0000
@@ -44,6 +44,7 @@
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
+
/**
* @author Michael Koch
* @since 1.4
@@ -51,76 +52,99 @@
public abstract class SelectorProvider
{
private static SelectorProvider systemDefaultProvider;
-
+
/**
* Initializes the selector provider.
*
* @exception SecurityException If a security manager has been installed and
* it denies @see RuntimePermission ("selectorProvider").
*/
- protected SelectorProvider ()
+ protected SelectorProvider()
{
- SecurityManager sm = System.getSecurityManager ();
+ SecurityManager sm = System.getSecurityManager();
if (sm != null)
- sm.checkPermission (new RuntimePermission ("selectorProvider"));
+ sm.checkPermission(new RuntimePermission("selectorProvider"));
}
-
+
/**
* Opens a datagram channel.
+ *
+ * @return a new datagram channel object
+ *
+ * @exception IOException if an error occurs
*/
- public abstract DatagramChannel openDatagramChannel () throws IOException;
-
+ public abstract DatagramChannel openDatagramChannel()
+ throws IOException;
+
/**
* Opens a pipe.
+ *
+ * @return a new pipe object
+ *
+ * @exception IOException if an error occurs
*/
- public abstract Pipe openPipe () throws IOException;
-
+ public abstract Pipe openPipe() throws IOException;
+
/**
* Opens a selector.
+ *
+ * @return a new selector object
+ *
+ * @exception IOException if an error occurs
*/
- public abstract AbstractSelector openSelector () throws IOException;
-
+ public abstract AbstractSelector openSelector() throws IOException;
+
/**
* Opens a server socket channel.
+ *
+ * @return a new server socket channel object
+ *
+ * @exception IOException if an error occurs
*/
- public abstract ServerSocketChannel openServerSocketChannel ()
+ public abstract ServerSocketChannel openServerSocketChannel()
throws IOException;
-
+
/**
* Opens a socket channel.
+ *
+ * @return a new socket channel object
+ *
+ * @exception IOException if an error occurs
*/
- public abstract SocketChannel openSocketChannel () throws IOException;
-
+ public abstract SocketChannel openSocketChannel() throws IOException;
+
/**
* Returns the system-wide default selector provider for this invocation
* of the Java virtual machine.
+ *
+ * @return the default seletor provider
*/
- public static synchronized SelectorProvider provider ()
+ public static synchronized SelectorProvider provider()
{
if (systemDefaultProvider == null)
{
- String propertyValue =
- System.getProperty ("java.nio.channels.spi.SelectorProvider");
+ String propertyValue =
+ System.getProperty("java.nio.channels.spi.SelectorProvider");
- if (propertyValue == null
- || propertyValue.equals (""))
- systemDefaultProvider = new SelectorProviderImpl();
- else
- {
- try
- {
- systemDefaultProvider = (SelectorProvider) Class.forName
- (propertyValue).newInstance();
- }
- catch (Exception e)
- {
- System.err.println ("Could not instantiate class: "
- + propertyValue);
- systemDefaultProvider = new SelectorProviderImpl();
- }
- }
+ if (propertyValue == null || propertyValue.equals(""))
+ systemDefaultProvider = new SelectorProviderImpl();
+ else
+ {
+ try
+ {
+ systemDefaultProvider =
+ (SelectorProvider) Class.forName(propertyValue)
+ .newInstance();
+ }
+ catch (Exception e)
+ {
+ System.err.println("Could not instantiate class: "
+ + propertyValue);
+ systemDefaultProvider = new SelectorProviderImpl();
+ }
+ }
}
-
+
return systemDefaultProvider;
}
}