This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: java.nio - javadoc and coding style fixes
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Tue, 20 Apr 2004 17:28:13 +0200
- Subject: Patch: java.nio - javadoc and coding style fixes
Hi list,
I just commited the attached patch to fix javadoc and coding style all
over java.nio.
Michael
2004-04-20 Michael Koch <konqueror@gmx.de>
* java/nio/Buffer.java,
java/nio/channels/AlreadyConnectedException.java,
java/nio/channels/AsynchronousCloseException.java,
java/nio/channels/ByteChannel.java,
java/nio/channels/CancelledKeyException.java,
java/nio/channels/Channel.java,
java/nio/channels/Channels.java,
java/nio/channels/ClosedByInterruptException.java,
java/nio/channels/ClosedChannelException.java,
java/nio/channels/ClosedSelectorException.java,
java/nio/channels/ConnectionPendingException.java,
java/nio/channels/DatagramChannel.java,
java/nio/channels/FileChannel.java,
java/nio/channels/FileLock.java,
java/nio/channels/FileLockInterruptionException.java,
java/nio/channels/GatheringByteChannel.java,
java/nio/channels/IllegalBlockingModeException.java,
java/nio/channels/IllegalSelectorException.java,
java/nio/channels/InterruptibleChannel.java,
java/nio/channels/NoConnectionPendingException.java,
java/nio/channels/NonReadableChannelException.java,
java/nio/channels/NonWritableChannelException.java,
java/nio/channels/NotYetBoundException.java,
java/nio/channels/NotYetConnectedException.java,
java/nio/channels/OverlappingFileLockException.java,
java/nio/channels/Pipe.java,
java/nio/channels/ReadableByteChannel.java,
java/nio/channels/ScatteringByteChannel.java,
java/nio/channels/SelectableChannel.java,
java/nio/channels/SelectionKey.java,
java/nio/channels/Selector.java,
java/nio/channels/ServerSocketChannel.java,
java/nio/channels/SocketChannel.java,
java/nio/channels/UnresolvedAddressException.java,
java/nio/channels/UnsupportedAddressTypeException.java,
java/nio/channels/WritableByteChannel.java,
java/nio/channels/spi/AbstractInterruptibleChannel.java,
java/nio/channels/spi/AbstractSelectableChannel.java,
java/nio/channels/spi/AbstractSelectionKey.java,
java/nio/channels/spi/AbstractSelector.java,
java/nio/channels/spi/SelectorProvider.java,
java/nio/charset/spi/CharsetProvider.java:
Fixed javadocs and jalopied all over java.nio.
Index: java/nio/Buffer.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/Buffer.java,v
retrieving revision 1.6
diff -u -r1.6 Buffer.java
--- java/nio/Buffer.java 13 Oct 2003 04:45:03 -0000 1.6
+++ java/nio/Buffer.java 20 Apr 2004 15:26:22 -0000
@@ -45,10 +45,11 @@
int pos = 0;
int mark = -1;
- // Creates a new Buffer.
- //
- // Should be package private.
- //
+ /**
+ * Creates a new Buffer.
+ *
+ * Should be package private.
+ */
Buffer (int capacity, int limit, int position, int mark)
{
if (capacity < 0)
@@ -69,6 +70,8 @@
/**
* Retrieves the capacity of the buffer.
+ *
+ * @return the capacity of the buffer
*/
public final int capacity ()
{
@@ -77,6 +80,8 @@
/**
* Clears the buffer.
+ *
+ * @return this buffer
*/
public final Buffer clear ()
{
@@ -88,6 +93,8 @@
/**
* Flips the buffer.
+ *
+ * @return this buffer
*/
public final Buffer flip ()
{
@@ -99,6 +106,9 @@
/**
* Tells whether the buffer has remaining data to read or not.
+ *
+ * @return true if the buffer contains remaining data to read,
+ * false otherwise
*/
public final boolean hasRemaining ()
{
@@ -107,11 +117,15 @@
/**
* Tells whether this buffer is read only or not.
+ *
+ * @return true if the buffer is read only, false otherwise
*/
public abstract boolean isReadOnly ();
/**
* Retrieves the current limit of the buffer.
+ *
+ * @return the limit of the buffer
*/
public final int limit ()
{
@@ -124,6 +138,8 @@
* @param newLimit The new limit value; must be non-negative and no larger
* than this buffer's capacity.
*
+ * @return this buffer
+ *
* @exception IllegalArgumentException If the preconditions on newLimit
* do not hold.
*/
@@ -144,6 +160,8 @@
/**
* Sets this buffer's mark at its position.
+ *
+ * @return this buffer
*/
public final Buffer mark ()
{
@@ -153,6 +171,8 @@
/**
* Retrieves the current position of this buffer.
+ *
+ * @return the current position of this buffer
*/
public final int position ()
{
@@ -165,7 +185,9 @@
*
* @param newPosition The new position value; must be non-negative and no
* larger than the current limit.
- *
+ *
+ * @return this buffer
+ *
* @exception IllegalArgumentException If the preconditions on newPosition
* do not hold
*/
@@ -183,6 +205,8 @@
/**
* Returns the number of elements between the current position and the limit.
+ *
+ * @return the number of remaining elements
*/
public final int remaining()
{
@@ -191,7 +215,9 @@
/**
* Resets this buffer's position to the previously-marked position.
- *
+ *
+ * @return this buffer
+ *
* @exception InvalidMarkException If the mark has not been set.
*/
public final Buffer reset()
@@ -206,6 +232,8 @@
/**
* Rewinds this buffer. The position is set to zero and the mark
* is discarded.
+ *
+ * @this buffer
*/
public final Buffer rewind()
{
Index: java/nio/channels/AlreadyConnectedException.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/AlreadyConnectedException.java,v
retrieving revision 1.3
diff -u -r1.3 AlreadyConnectedException.java
--- java/nio/channels/AlreadyConnectedException.java 13 Nov 2002 13:52:47 -0000 1.3
+++ java/nio/channels/AlreadyConnectedException.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* AlreadyConnectedException.java --
+/* AlreadyConnectedException.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
Index: java/nio/channels/AsynchronousCloseException.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/AsynchronousCloseException.java,v
retrieving revision 1.1
diff -u -r1.1 AsynchronousCloseException.java
--- java/nio/channels/AsynchronousCloseException.java 21 Nov 2002 10:45:14 -0000 1.1
+++ java/nio/channels/AsynchronousCloseException.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* AsynchronousCloseException.java --
+/* AsynchronousCloseException.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,6 +36,7 @@
exception statement from your version. */
package java.nio.channels;
+
/**
* @author Michael Koch
Index: java/nio/channels/ByteChannel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/ByteChannel.java,v
retrieving revision 1.1
diff -u -r1.1 ByteChannel.java
--- java/nio/channels/ByteChannel.java 7 Oct 2002 07:59:12 -0000 1.1
+++ java/nio/channels/ByteChannel.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* ByteChannel.java --
+/* ByteChannel.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,7 +37,7 @@
package java.nio.channels;
-public interface ByteChannel
- extends ReadableByteChannel, WritableByteChannel
+public interface ByteChannel extends ReadableByteChannel,
+ WritableByteChannel
{
}
Index: java/nio/channels/CancelledKeyException.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/CancelledKeyException.java,v
retrieving revision 1.1
diff -u -r1.1 CancelledKeyException.java
--- java/nio/channels/CancelledKeyException.java 21 Nov 2002 10:45:14 -0000 1.1
+++ java/nio/channels/CancelledKeyException.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* CancelledKeyException.java --
+/* CancelledKeyException.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,6 +36,7 @@
exception statement from your version. */
package java.nio.channels;
+
/**
* @author Michael Koch
Index: java/nio/channels/Channel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/Channel.java,v
retrieving revision 1.2
diff -u -r1.2 Channel.java
--- java/nio/channels/Channel.java 11 Oct 2003 18:45:10 -0000 1.2
+++ java/nio/channels/Channel.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* Channel.java --
+/* Channel.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,7 @@
package java.nio.channels;
import java.io.IOException;
+
public interface Channel
{
Index: java/nio/channels/Channels.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/Channels.java,v
retrieving revision 1.7
diff -u -r1.7 Channels.java
--- java/nio/channels/Channels.java 3 Mar 2004 23:50:02 -0000 1.7
+++ java/nio/channels/Channels.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* Channels.java --
+/* Channels.java --
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,20 +42,21 @@
import gnu.java.nio.InputStreamChannel;
import gnu.java.nio.OutputStreamChannel;
import gnu.java.nio.channels.FileChannelImpl;
-import java.io.InputStream;
-import java.io.OutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
+
/**
* @since 1.4
*/
-public final class Channels
+public final class Channels
{
/**
* Constructs a stream that reads bytes from the given channel.
@@ -70,7 +71,7 @@
/**
* Constructs a stream that writes bytes to the given channel.
*/
- public static OutputStream newOutputStream(WritableByteChannel ch)
+ public static OutputStream newOutputStream(WritableByteChannel ch)
{
if (ch instanceof FileChannelImpl)
return newOutputStream((FileChannelImpl) ch);
@@ -78,8 +79,9 @@
}
static native FileInputStream newInputStream(FileChannelImpl ch);
+
static native FileOutputStream newOutputStream(FileChannelImpl ch);
-
+
/**
* Constructs a channel that reads bytes from the given stream.
*/
@@ -93,15 +95,15 @@
*/
public static WritableByteChannel newChannel(OutputStream out)
{
- return new OutputStreamChannel (out);
+ return new OutputStreamChannel(out);
}
/**
* Constructs a reader that decodes bytes from the given channel using the
* given decoder.
*/
- public static Reader newReader (ReadableByteChannel ch, CharsetDecoder dec,
- int minBufferCap)
+ public static Reader newReader(ReadableByteChannel ch, CharsetDecoder dec,
+ int minBufferCap)
{
throw new Error ("not implemented");
}
@@ -113,17 +115,17 @@
* @exception UnsupportedCharsetException If no support for the named charset
* is available in this instance of the Java virtual machine.
*/
- public static Reader newReader (ReadableByteChannel ch, String csName)
+ public static Reader newReader(ReadableByteChannel ch, String csName)
{
- return newReader (ch, Charset.forName (csName).newDecoder (), -1);
+ return newReader(ch, Charset.forName(csName).newDecoder(), -1);
}
/**
* Constructs a writer that encodes characters using the given encoder and
* writes the resulting bytes to the given channel.
*/
- public static Writer newWriter (WritableByteChannel ch, CharsetEncoder enc,
- int minBufferCap)
+ public static Writer newWriter(WritableByteChannel ch, CharsetEncoder enc,
+ int minBufferCap)
{
throw new Error ("not implemented");
}
@@ -135,9 +137,8 @@
* @exception UnsupportedCharsetException If no support for the named charset
* is available in this instance of the Java virtual machine.
*/
- public static Writer newWriter (WritableByteChannel ch,
- String csName)
+ public static Writer newWriter(WritableByteChannel ch, String csName)
{
- return newWriter (ch, Charset.forName (csName).newEncoder (), -1);
+ return newWriter(ch, Charset.forName(csName).newEncoder(), -1);
}
}
Index: java/nio/channels/ClosedByInterruptException.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/ClosedByInterruptException.java,v
retrieving revision 1.1
diff -u -r1.1 ClosedByInterruptException.java
--- java/nio/channels/ClosedByInterruptException.java 21 Nov 2002 10:45:14 -0000 1.1
+++ java/nio/channels/ClosedByInterruptException.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* ClosedByInterruptException.java --
+/* ClosedByInterruptException.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,6 +36,7 @@
exception statement from your version. */
package java.nio.channels;
+
/**
* @author Michael Koch
Index: java/nio/channels/ClosedChannelException.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/ClosedChannelException.java,v
retrieving revision 1.2
diff -u -r1.2 ClosedChannelException.java
--- java/nio/channels/ClosedChannelException.java 18 Nov 2002 13:22:55 -0000 1.2
+++ java/nio/channels/ClosedChannelException.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* ClosedChannelException.java --
+/* ClosedChannelException.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,7 @@
package java.nio.channels;
import java.io.IOException;
+
/**
* @author Michael Koch
Index: java/nio/channels/ClosedSelectorException.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/ClosedSelectorException.java,v
retrieving revision 1.1
diff -u -r1.1 ClosedSelectorException.java
--- java/nio/channels/ClosedSelectorException.java 18 Nov 2002 13:22:55 -0000 1.1
+++ java/nio/channels/ClosedSelectorException.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* ClosedSelectorException.java --
+/* ClosedSelectorException.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,6 +36,7 @@
exception statement from your version. */
package java.nio.channels;
+
/**
* @author Michael Koch
Index: java/nio/channels/ConnectionPendingException.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/ConnectionPendingException.java,v
retrieving revision 1.1
diff -u -r1.1 ConnectionPendingException.java
--- java/nio/channels/ConnectionPendingException.java 21 Nov 2002 10:45:14 -0000 1.1
+++ java/nio/channels/ConnectionPendingException.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* ConnectionPendingException.java --
+/* ConnectionPendingException.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,6 +36,7 @@
exception statement from your version. */
package java.nio.channels;
+
/**
* @author Michael Koch
Index: java/nio/channels/DatagramChannel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/DatagramChannel.java,v
retrieving revision 1.6
diff -u -r1.6 DatagramChannel.java
--- java/nio/channels/DatagramChannel.java 11 Feb 2003 06:48:53 -0000 1.6
+++ java/nio/channels/DatagramChannel.java 20 Apr 2004 15:26:22 -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: /cvs/gcc/gcc/libjava/java/nio/channels/FileChannel.java,v
retrieving revision 1.5
diff -u -r1.5 FileChannel.java
--- java/nio/channels/FileChannel.java 26 Feb 2004 19:45:51 -0000 1.5
+++ java/nio/channels/FileChannel.java 20 Apr 2004 15:26:22 -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 <code>MapMode</code> 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 <code>size</code>.
@@ -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: /cvs/gcc/gcc/libjava/java/nio/channels/FileLock.java,v
retrieving revision 1.3
diff -u -r1.3 FileLock.java
--- java/nio/channels/FileLock.java 14 May 2003 06:37:59 -0000 1.3
+++ java/nio/channels/FileLock.java 20 Apr 2004 15:26:22 -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/FileLockInterruptionException.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/FileLockInterruptionException.java,v
retrieving revision 1.1
diff -u -r1.1 FileLockInterruptionException.java
--- java/nio/channels/FileLockInterruptionException.java 21 Nov 2002 10:45:14 -0000 1.1
+++ java/nio/channels/FileLockInterruptionException.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* FileLockInterruptionException.java --
+/* FileLockInterruptionException.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,7 @@
package java.nio.channels;
import java.io.IOException;
+
/**
* @author Michael Koch
Index: java/nio/channels/GatheringByteChannel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/GatheringByteChannel.java,v
retrieving revision 1.2
diff -u -r1.2 GatheringByteChannel.java
--- java/nio/channels/GatheringByteChannel.java 11 Oct 2003 18:45:10 -0000 1.2
+++ java/nio/channels/GatheringByteChannel.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* GatheringByteChannel.java --
+/* GatheringByteChannel.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,11 +37,11 @@
package java.nio.channels;
-import java.nio.ByteBuffer;
import java.io.IOException;
+import java.nio.ByteBuffer;
-public interface GatheringByteChannel
- extends WritableByteChannel
+
+public interface GatheringByteChannel extends WritableByteChannel
{
/**
* Writes a sequence of bytes to this channel from a subsequence of
@@ -59,9 +59,9 @@
* @exception NonWritableChannelException If this channel was not opened for
* writing
*/
- long write (ByteBuffer[] srcs, int offset, int length)
+ long write(ByteBuffer[] srcs, int offset, int length)
throws IOException;
-
+
/**
* Writes a sequence of bytes to this channel from the given buffers
*
@@ -75,5 +75,5 @@
* @exception NonWritableChannelException If this channel was not opened for
* writing
*/
- long write (ByteBuffer[] srcs) throws IOException;
+ long write(ByteBuffer[] srcs) throws IOException;
}
Index: java/nio/channels/IllegalBlockingModeException.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/IllegalBlockingModeException.java,v
retrieving revision 1.1
diff -u -r1.1 IllegalBlockingModeException.java
--- java/nio/channels/IllegalBlockingModeException.java 25 Sep 2002 09:05:53 -0000 1.1
+++ java/nio/channels/IllegalBlockingModeException.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* IllegalBlockingModeException.java --
+/* IllegalBlockingModeException.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,6 +36,7 @@
exception statement from your version. */
package java.nio.channels;
+
/**
* @author Michael Koch <konqueror@gmx.de>
Index: java/nio/channels/IllegalSelectorException.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/IllegalSelectorException.java,v
retrieving revision 1.1
diff -u -r1.1 IllegalSelectorException.java
--- java/nio/channels/IllegalSelectorException.java 21 Nov 2002 10:45:14 -0000 1.1
+++ java/nio/channels/IllegalSelectorException.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* IllegalSelectorException.java --
+/* IllegalSelectorException.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,6 +36,7 @@
exception statement from your version. */
package java.nio.channels;
+
/**
* @author Michael Koch
Index: java/nio/channels/InterruptibleChannel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/InterruptibleChannel.java,v
retrieving revision 1.1
diff -u -r1.1 InterruptibleChannel.java
--- java/nio/channels/InterruptibleChannel.java 7 Oct 2002 07:59:12 -0000 1.1
+++ java/nio/channels/InterruptibleChannel.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* InterruptibleChannel.java --
+/* InterruptibleChannel.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,7 @@
package java.nio.channels;
import java.io.IOException;
+
public interface InterruptibleChannel extends Channel
{
Index: java/nio/channels/NoConnectionPendingException.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/NoConnectionPendingException.java,v
retrieving revision 1.1
diff -u -r1.1 NoConnectionPendingException.java
--- java/nio/channels/NoConnectionPendingException.java 21 Nov 2002 10:45:14 -0000 1.1
+++ java/nio/channels/NoConnectionPendingException.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* NoConnectionPendingException.java --
+/* NoConnectionPendingException.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,6 +36,7 @@
exception statement from your version. */
package java.nio.channels;
+
/**
* @author Michael Koch
Index: java/nio/channels/NonReadableChannelException.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/NonReadableChannelException.java,v
retrieving revision 1.1
diff -u -r1.1 NonReadableChannelException.java
--- java/nio/channels/NonReadableChannelException.java 21 Nov 2002 10:45:14 -0000 1.1
+++ java/nio/channels/NonReadableChannelException.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* NonReadableChannelException.java --
+/* NonReadableChannelException.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,6 +36,7 @@
exception statement from your version. */
package java.nio.channels;
+
/**
* @author Michael Koch
Index: java/nio/channels/NonWritableChannelException.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/NonWritableChannelException.java,v
retrieving revision 1.1
diff -u -r1.1 NonWritableChannelException.java
--- java/nio/channels/NonWritableChannelException.java 21 Nov 2002 10:45:14 -0000 1.1
+++ java/nio/channels/NonWritableChannelException.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* NonWritableChannelException.java --
+/* NonWritableChannelException.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,6 +36,7 @@
exception statement from your version. */
package java.nio.channels;
+
/**
* @author Michael Koch
Index: java/nio/channels/NotYetBoundException.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/NotYetBoundException.java,v
retrieving revision 1.1
diff -u -r1.1 NotYetBoundException.java
--- java/nio/channels/NotYetBoundException.java 21 Nov 2002 10:45:14 -0000 1.1
+++ java/nio/channels/NotYetBoundException.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* NotYetBoundException.java --
+/* NotYetBoundException.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,6 +36,7 @@
exception statement from your version. */
package java.nio.channels;
+
/**
* @author Michael Koch
Index: java/nio/channels/NotYetConnectedException.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/NotYetConnectedException.java,v
retrieving revision 1.1
diff -u -r1.1 NotYetConnectedException.java
--- java/nio/channels/NotYetConnectedException.java 21 Nov 2002 10:45:14 -0000 1.1
+++ java/nio/channels/NotYetConnectedException.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* NotYetConnectedException.java --
+/* NotYetConnectedException.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,6 +36,7 @@
exception statement from your version. */
package java.nio.channels;
+
/**
* @author Michael Koch
Index: java/nio/channels/OverlappingFileLockException.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/OverlappingFileLockException.java,v
retrieving revision 1.1
diff -u -r1.1 OverlappingFileLockException.java
--- java/nio/channels/OverlappingFileLockException.java 21 Nov 2002 10:45:14 -0000 1.1
+++ java/nio/channels/OverlappingFileLockException.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* OverlappingFileLockException.java --
+/* OverlappingFileLockException.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,6 +36,7 @@
exception statement from your version. */
package java.nio.channels;
+
/**
* @author Michael Koch
Index: java/nio/channels/Pipe.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/Pipe.java,v
retrieving revision 1.3
diff -u -r1.3 Pipe.java
--- java/nio/channels/Pipe.java 11 Feb 2003 06:48:53 -0000 1.3
+++ java/nio/channels/Pipe.java 20 Apr 2004 15:26:22 -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/ReadableByteChannel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/ReadableByteChannel.java,v
retrieving revision 1.2
diff -u -r1.2 ReadableByteChannel.java
--- java/nio/channels/ReadableByteChannel.java 11 Oct 2003 18:45:10 -0000 1.2
+++ java/nio/channels/ReadableByteChannel.java 20 Apr 2004 15:26:22 -0000
@@ -1,5 +1,5 @@
-/* ReadableByteChannel.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+/* ReadableByteChannel.java --
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,11 +40,16 @@
import java.io.IOException;
import java.nio.ByteBuffer;
+
public interface ReadableByteChannel extends Channel
{
/**
* Reads a sequence of bytes from this channel into the given buffer
*
+ * @param dst the buffer to put the read data into
+ *
+ * @return the numer of bytes read
+ *
* @exception AsynchronousCloseException If another thread closes this
* channel while the read operation is in progress
* @exception ClosedByInterruptException If another thread interrupts the
@@ -55,5 +60,5 @@
* @exception NonReadableChannelException If this channel was not opened for
* reading
*/
- int read (ByteBuffer dst) throws IOException;
+ int read(ByteBuffer dst) throws IOException;
}
Index: java/nio/channels/ScatteringByteChannel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/ScatteringByteChannel.java,v
retrieving revision 1.2
diff -u -r1.2 ScatteringByteChannel.java
--- java/nio/channels/ScatteringByteChannel.java 11 Oct 2003 18:45:10 -0000 1.2
+++ java/nio/channels/ScatteringByteChannel.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* ScatteringByteChannel.java --
+/* ScatteringByteChannel.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,11 +37,11 @@
package java.nio.channels;
-import java.nio.ByteBuffer;
import java.io.IOException;
+import java.nio.ByteBuffer;
+
-public interface ScatteringByteChannel
- extends ReadableByteChannel
+public interface ScatteringByteChannel extends ReadableByteChannel
{
/**
* Reads a sequence of bytes from this channel into a subsequence of the
@@ -59,7 +59,7 @@
* @exception NonReadableChannelException If this channel was not opened for
* reading
*/
- long read (ByteBuffer[] srcs, int offset, int length)
+ long read(ByteBuffer[] srcs, int offset, int length)
throws IOException;
/**
@@ -75,5 +75,5 @@
* @exception NonReadableChannelException If this channel was not opened for
* reading
*/
- long read (ByteBuffer[] srcs) throws IOException;
+ long read(ByteBuffer[] srcs) throws IOException;
}
Index: java/nio/channels/SelectableChannel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/SelectableChannel.java,v
retrieving revision 1.3
diff -u -r1.3 SelectableChannel.java
--- java/nio/channels/SelectableChannel.java 11 Feb 2003 06:48:53 -0000 1.3
+++ java/nio/channels/SelectableChannel.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* SelectableChannel.java --
+/* SelectableChannel.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,62 +41,62 @@
import java.nio.channels.spi.AbstractInterruptibleChannel;
import java.nio.channels.spi.SelectorProvider;
+
/**
* @author Michael Koch
* @since 1.4
*/
-public abstract class SelectableChannel
- extends AbstractInterruptibleChannel
+public abstract class SelectableChannel extends AbstractInterruptibleChannel
{
/**
* Initializes the channel.
*/
- protected SelectableChannel ()
+ protected SelectableChannel()
{
}
-
+
/**
* Returns the lock of this channel.
*/
- public abstract Object blockingLock ();
+ public abstract Object blockingLock();
/**
* Adjusts this channel's blocking mode.
- *
+ *
* @exception ClosedChannelException If this channel is closed.
* @exception IllegalBlockingModeException If block is true and this channel
* is registered with one or more selectors.
* @exception IOException If an error occurs.
*/
- public abstract SelectableChannel configureBlocking (boolean block)
+ public abstract SelectableChannel configureBlocking(boolean block)
throws IOException;
-
+
/**
* Tells whether this channel is blocking or not.
*/
- public abstract boolean isBlocking ();
-
+ public abstract boolean isBlocking();
+
/**
* Tells whether or not this channel is currently registered with
* any selectors.
*/
- public abstract boolean isRegistered ();
-
+ public abstract boolean isRegistered();
+
/**
* Retrieves the key representing the channel's registration with
* the given selector.
*/
- public abstract SelectionKey keyFor (Selector sel);
-
+ public abstract SelectionKey keyFor(Selector sel);
+
/**
* Returns the provider that created this channel.
*/
- public abstract SelectorProvider provider ();
-
+ public abstract SelectorProvider provider();
+
/**
* Registers this channel with the given selector,
* returning a selection key.
- *
+ *
* @exception CancelledKeyException If this channel is currently registered
* with the given selector but the corresponding key has already been cancelled
* @exception ClosedChannelException If this channel is closed.
@@ -108,12 +108,12 @@
* @exception IllegalSelectorException If this channel was not created by
* the same provider as the given selector.
*/
- public final SelectionKey register (Selector sel, int ops)
+ public final SelectionKey register(Selector sel, int ops)
throws ClosedChannelException
{
- return register (sel, ops, null);
+ return register(sel, ops, null);
}
-
+
/**
* Registers this channel with the given selector,
* returning a selection key.
@@ -130,9 +130,9 @@
* @exception IllegalSelectorException If this channel was not created by
* the same provider as the given selector.
*/
- public abstract SelectionKey register (Selector sel, int ops, Object att)
+ public abstract SelectionKey register(Selector sel, int ops, Object att)
throws ClosedChannelException;
-
+
/**
* Returns a set of valid operations on this channel.
*/
Index: java/nio/channels/SelectionKey.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/SelectionKey.java,v
retrieving revision 1.5
diff -u -r1.5 SelectionKey.java
--- java/nio/channels/SelectionKey.java 11 Feb 2003 06:50:13 -0000 1.5
+++ java/nio/channels/SelectionKey.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* SelectionKey.java --
+/* SelectionKey.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,128 +37,128 @@
package java.nio.channels;
+
/**
* @author Michael Koch
* @since 1.4
*/
public abstract class SelectionKey
{
- public static final int OP_ACCEPT = 16;
+ public static final int OP_ACCEPT = 16;
public static final int OP_CONNECT = 8;
- public static final int OP_READ = 1;
- public static final int OP_WRITE = 4;
-
+ public static final int OP_READ = 1;
+ public static final int OP_WRITE = 4;
Object attached;
-
+
/**
* Initializes the selection key.
*/
- protected SelectionKey ()
+ protected SelectionKey()
{
}
/**
* Attaches obj to the key and returns the old attached object.
*/
- public final Object attach (Object obj)
+ public final Object attach(Object obj)
{
Object old = attached;
attached = obj;
return old;
}
-
+
/**
* Returns the object attached to the key.
*/
- public final Object attachment ()
+ public final Object attachment()
{
return attached;
- }
+ }
/**
* Tests if the channel attached to this key is ready to accept
* a new socket connection.
- *
+ *
* @exception CancelledKeyException If this key has been cancelled
*/
- public final boolean isAcceptable ()
- {
- return (readyOps () & OP_ACCEPT) != 0;
+ public final boolean isAcceptable()
+ {
+ return (readyOps() & OP_ACCEPT) != 0;
}
/**
* Tests whether this key's channel has either finished,
* or failed to finish, its socket-connection operation.
- *
+ *
* @exception CancelledKeyException If this key has been cancelled
*/
- public final boolean isConnectable ()
+ public final boolean isConnectable()
{
- return (readyOps () & OP_CONNECT) != 0;
- }
-
+ return (readyOps() & OP_CONNECT) != 0;
+ }
+
/**
* Tests if the channel attached to the key is readable.
- *
+ *
* @exception CancelledKeyException If this key has been cancelled
*/
- public final boolean isReadable ()
+ public final boolean isReadable()
{
- return (readyOps () & OP_READ) != 0;
+ return (readyOps() & OP_READ) != 0;
}
-
+
/**
* Tests if the channel attached to the key is writable.
*
* @exception CancelledKeyException If this key has been cancelled
*/
- public final boolean isWritable ()
+ public final boolean isWritable()
{
- return (readyOps () & OP_WRITE) != 0;
+ return (readyOps() & OP_WRITE) != 0;
}
/**
* Requests that the registration of this key's channel with
* its selector be cancelled.
*/
- public abstract void cancel ();
-
+ public abstract void cancel();
+
/**
* return the channel attached to the key.
*/
- public abstract SelectableChannel channel ();
-
+ public abstract SelectableChannel channel();
+
/**
* Returns the key's interest set.
- *
+ *
* @exception CancelledKeyException If this key has been cancelled
*/
- public abstract int interestOps ();
-
+ public abstract int interestOps();
+
/**
* Sets this key's interest set to the given value.
- *
+ *
* @exception CancelledKeyException If this key has been cancelled
* @exception IllegalArgumentException If a bit in the set does not
* correspond to an operation that is supported by this key's channel,
* that is, if set & ~(channel().validOps()) != 0
*/
- public abstract SelectionKey interestOps (int ops);
-
+ public abstract SelectionKey interestOps(int ops);
+
/**
* Tells whether or not this key is valid.
*/
- public abstract boolean isValid ();
-
+ public abstract boolean isValid();
+
/**
* Retrieves this key's ready-operation set.
- *
+ *
* @exception CancelledKeyException If this key has been cancelled
*/
- public abstract int readyOps ();
-
+ public abstract int readyOps();
+
/**
* Returns the selector for which this key was created.
*/
- public abstract Selector selector ();
+ public abstract Selector selector();
}
Index: java/nio/channels/Selector.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/Selector.java,v
retrieving revision 1.3
diff -u -r1.3 Selector.java
--- java/nio/channels/Selector.java 18 Nov 2002 14:31:39 -0000 1.3
+++ java/nio/channels/Selector.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* Selector.java --
+/* Selector.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,7 @@
import java.nio.channels.spi.SelectorProvider;
import java.util.Set;
+
/**
* @author Michael Koch
* @since 1.4
@@ -53,81 +54,81 @@
protected Selector()
{
}
-
+
/**
* Opens a selector.
- *
+ *
* @exception IOException If an error occurs
*/
- public static Selector open () throws IOException
+ public static Selector open() throws IOException
{
- return SelectorProvider.provider ().openSelector ();
+ return SelectorProvider.provider().openSelector();
}
/**
* Closes the selector.
- *
+ *
* @exception IOException If an error occurs
*/
- public abstract void close () throws IOException;
-
+ public abstract void close() throws IOException;
+
/**
* Tells whether the selector is open or not.
*/
- public abstract boolean isOpen ();
-
+ public abstract boolean isOpen();
+
/**
* Returns this selector's key set.
- *
+ *
* @exception ClosedSelectorException If this selector is closed.
*/
- public abstract Set keys ();
-
+ public abstract Set keys();
+
/**
* Returns the SelectorProvider that created the selector.
*/
- public abstract SelectorProvider provider ();
-
+ public abstract SelectorProvider provider();
+
/**
* Selects a set of keys whose corresponding channels are ready
* for I/O operations.
- *
+ *
* @exception ClosedSelectorException If this selector is closed.
* @exception IOException If an error occurs
*/
- public abstract int select () throws IOException;
-
+ public abstract int select() throws IOException;
+
/**
* Selects a set of keys whose corresponding channels are ready
* for I/O operations.
*
* @param timeout The timeout to use.
- *
+ *
* @exception ClosedSelectorException If this selector is closed.
* @exception IllegalArgumentException If the timeout value is negative.
* @exception IOException If an error occurs
*/
- public abstract int select (long timeout) throws IOException;
-
+ public abstract int select(long timeout) throws IOException;
+
/**
* Returns this selector's selected-key set.
- *
+ *
* @exception ClosedSelectorException If this selector is closed.
*/
- public abstract Set selectedKeys ();
-
+ public abstract Set selectedKeys();
+
/**
* Selects a set of keys whose corresponding channels are ready
* for I/O operations.
- *
+ *
* @exception ClosedSelectorException If this selector is closed.
* @exception IOException If an error occurs
*/
- public abstract int selectNow () throws IOException;
-
+ public abstract int selectNow() throws IOException;
+
/**
* Causes the first selection operation that has not yet returned to
* return immediately.
*/
- public abstract Selector wakeup ();
+ public abstract Selector wakeup();
}
Index: java/nio/channels/ServerSocketChannel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/ServerSocketChannel.java,v
retrieving revision 1.8
diff -u -r1.8 ServerSocketChannel.java
--- java/nio/channels/ServerSocketChannel.java 27 Jun 2003 13:34:12 -0000 1.8
+++ java/nio/channels/ServerSocketChannel.java 20 Apr 2004 15:26:22 -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: /cvs/gcc/gcc/libjava/java/nio/channels/SocketChannel.java,v
retrieving revision 1.7
diff -u -r1.7 SocketChannel.java
--- java/nio/channels/SocketChannel.java 26 Feb 2004 19:45:51 -0000 1.7
+++ java/nio/channels/SocketChannel.java 20 Apr 2004 15:26:22 -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/UnresolvedAddressException.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/UnresolvedAddressException.java,v
retrieving revision 1.1
diff -u -r1.1 UnresolvedAddressException.java
--- java/nio/channels/UnresolvedAddressException.java 21 Nov 2002 10:45:14 -0000 1.1
+++ java/nio/channels/UnresolvedAddressException.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* UnresolvedAddressException.java --
+/* UnresolvedAddressException.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,6 +36,7 @@
exception statement from your version. */
package java.nio.channels;
+
/**
* @author Michael Koch
Index: java/nio/channels/UnsupportedAddressTypeException.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/UnsupportedAddressTypeException.java,v
retrieving revision 1.1
diff -u -r1.1 UnsupportedAddressTypeException.java
--- java/nio/channels/UnsupportedAddressTypeException.java 21 Nov 2002 10:45:14 -0000 1.1
+++ java/nio/channels/UnsupportedAddressTypeException.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* UnsupportedAddressTypeException.java --
+/* UnsupportedAddressTypeException.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,6 +36,7 @@
exception statement from your version. */
package java.nio.channels;
+
/**
* @author Michael Koch
Index: java/nio/channels/WritableByteChannel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/WritableByteChannel.java,v
retrieving revision 1.2
diff -u -r1.2 WritableByteChannel.java
--- java/nio/channels/WritableByteChannel.java 11 Oct 2003 18:45:10 -0000 1.2
+++ java/nio/channels/WritableByteChannel.java 20 Apr 2004 15:26:22 -0000
@@ -1,4 +1,4 @@
-/* WritableByteChannel.java --
+/* WritableByteChannel.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,8 +40,8 @@
import java.io.IOException;
import java.nio.ByteBuffer;
-public interface WritableByteChannel
- extends Channel
+
+public interface WritableByteChannel extends Channel
{
/**
* Writes a sequence of bytes to this channel from the given buffer
@@ -56,5 +56,5 @@
* @exception NonWritableChannelException If this channel was not opened for
* writing
*/
- int write (ByteBuffer src) throws IOException;
+ int write(ByteBuffer src) throws IOException;
}
Index: java/nio/channels/spi/AbstractInterruptibleChannel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/spi/AbstractInterruptibleChannel.java,v
retrieving revision 1.5
diff -u -r1.5 AbstractInterruptibleChannel.java
--- java/nio/channels/spi/AbstractInterruptibleChannel.java 14 Feb 2004 18:41:48 -0000 1.5
+++ java/nio/channels/spi/AbstractInterruptibleChannel.java 20 Apr 2004 15:26:22 -0000
@@ -1,5 +1,5 @@
/* AbstractInterruptibleChannel.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004 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,38 @@
/**
* 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
{
- }
+ // FIXME: check more here.
+
+ if (closed) throw new 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: /cvs/gcc/gcc/libjava/java/nio/channels/spi/AbstractSelectableChannel.java,v
retrieving revision 1.10
diff -u -r1.10 AbstractSelectableChannel.java
--- java/nio/channels/spi/AbstractSelectableChannel.java 18 Mar 2004 21:32:22 -0000 1.10
+++ java/nio/channels/spi/AbstractSelectableChannel.java 20 Apr 2004 15:26:22 -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,87 +140,104 @@
/**
* 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();
+ if ((ops & ~validOps()) != 0)
+ throw new IllegalArgumentException();
+
SelectionKey key = null;
AbstractSelector selector = (AbstractSelector) selin;
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: /cvs/gcc/gcc/libjava/java/nio/channels/spi/AbstractSelectionKey.java,v
retrieving revision 1.4
diff -u -r1.4 AbstractSelectionKey.java
--- java/nio/channels/spi/AbstractSelectionKey.java 18 Mar 2004 21:32:22 -0000 1.4
+++ java/nio/channels/spi/AbstractSelectionKey.java 20 Apr 2004 15:26:22 -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: /cvs/gcc/gcc/libjava/java/nio/channels/spi/AbstractSelector.java,v
retrieving revision 1.6
diff -u -r1.6 AbstractSelector.java
--- java/nio/channels/spi/AbstractSelector.java 18 Mar 2004 21:32:22 -0000 1.6
+++ java/nio/channels/spi/AbstractSelector.java 20 Apr 2004 15:26:22 -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: /cvs/gcc/gcc/libjava/java/nio/channels/spi/SelectorProvider.java,v
retrieving revision 1.5
diff -u -r1.5 SelectorProvider.java
--- java/nio/channels/spi/SelectorProvider.java 12 Oct 2003 13:39:07 -0000 1.5
+++ java/nio/channels/spi/SelectorProvider.java 20 Apr 2004 15:26:22 -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;
}
}
Index: java/nio/charset/spi/CharsetProvider.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/charset/spi/CharsetProvider.java,v
retrieving revision 1.3
diff -u -r1.3 CharsetProvider.java
--- java/nio/charset/spi/CharsetProvider.java 1 Nov 2002 12:03:40 -0000 1.3
+++ java/nio/charset/spi/CharsetProvider.java 20 Apr 2004 15:26:22 -0000
@@ -40,6 +40,7 @@
import java.nio.charset.Charset;
import java.util.Iterator;
+
/**
* This class allows an implementor to provide additional character sets. The
* subclass must have a nullary constructor, and be attached to charset
@@ -81,6 +82,8 @@
/**
* Returns the named charset, by canonical name or alias.
+ *
+ * @param name the name of the character
*
* @return the charset, or null if not supported
*/