harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r587508 [1/4] - in /harmony/enhanced/classlib/trunk/modules/nio/src/main/java: common/java/nio/ common/java/nio/channels/ common/java/nio/channels/spi/ common/org/apache/harmony/nio/ common/org/apache/harmony/nio/internal/ unix/org/apache/h...
Date Tue, 23 Oct 2007 13:54:40 GMT
Author: tellison
Date: Tue Oct 23 06:54:37 2007
New Revision: 587508

URL: http://svn.apache.org/viewvc?rev=587508&view=rev
Log:
Reformatting a number of NIO files, mostly replacing tabs with spaces.

Modified:
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/DoubleBuffer.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/AlreadyConnectedException.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/AsynchronousCloseException.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ByteChannel.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/CancelledKeyException.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/Channel.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/Channels.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ClosedByInterruptException.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ClosedChannelException.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ClosedSelectorException.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ConnectionPendingException.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/DatagramChannel.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/FileChannel.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/FileLock.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/FileLockInterruptionException.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/GatheringByteChannel.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/IllegalBlockingModeException.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/IllegalSelectorException.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/InterruptibleChannel.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NoConnectionPendingException.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NonReadableChannelException.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NonWritableChannelException.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NotYetBoundException.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NotYetConnectedException.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/OverlappingFileLockException.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ReadableByteChannel.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ScatteringByteChannel.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/SelectableChannel.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ServerSocketChannel.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/SocketChannel.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/UnresolvedAddressException.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/UnsupportedAddressTypeException.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/WritableByteChannel.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelectionKey.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/AddressUtil.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/FileChannelFactory.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileLockImpl.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/IOUtil.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ReadOnlyFileChannel.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ReadWriteFileChannel.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorProviderImpl.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/WriteOnlyFileChannel.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/unix/org/apache/harmony/nio/internal/EpollSelectionKeyImpl.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/unix/org/apache/harmony/nio/internal/EpollSelectorImpl.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/unix/org/apache/harmony/nio/internal/EpollSelectorProviderImpl.java

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/DoubleBuffer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/DoubleBuffer.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/DoubleBuffer.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/DoubleBuffer.java Tue Oct 23 06:54:37 2007
@@ -568,7 +568,7 @@
         buf.append(capacity());
         buf.append(" position="); //$NON-NLS-1$
         buf.append(position());
-        buf.append(" limit="); //$NON-NLS-1$	
+        buf.append(" limit="); //$NON-NLS-1$
         buf.append(limit());
         return buf.toString();
     }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/AlreadyConnectedException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/AlreadyConnectedException.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/AlreadyConnectedException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/AlreadyConnectedException.java Tue Oct 23 06:54:37 2007
@@ -16,19 +16,18 @@
 
 package java.nio.channels;
 
-
 /**
- * Thrown when an attempt is made to connect a SocketChannel that is already connected.
- * 
+ * Thrown when an attempt is made to connect a SocketChannel that is already
+ * connected.
  */
 public class AlreadyConnectedException extends IllegalStateException {
 
-	private static final long serialVersionUID = -7331895245053773357L;
+    private static final long serialVersionUID = -7331895245053773357L;
 
-	/**
-	 * Default constructor.
-	 */
-	public AlreadyConnectedException() {
-		super();
-	}
+    /**
+     * Default constructor.
+     */
+    public AlreadyConnectedException() {
+        super();
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/AsynchronousCloseException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/AsynchronousCloseException.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/AsynchronousCloseException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/AsynchronousCloseException.java Tue Oct 23 06:54:37 2007
@@ -16,20 +16,18 @@
 
 package java.nio.channels;
 
-
 /**
- * Thrown when the underlying channel for an IO operation is closed by another thread.
- * 
+ * Thrown when the underlying channel for an IO operation is closed by another
+ * thread.
  */
 public class AsynchronousCloseException extends ClosedChannelException {
 
-	private static final long serialVersionUID = 6891178312432313966L;
-
-	/**
-	 * Default constructor
-	 */
-	public AsynchronousCloseException() {
-		super();
-	}
+    private static final long serialVersionUID = 6891178312432313966L;
 
+    /**
+     * Default constructor
+     */
+    public AsynchronousCloseException() {
+        super();
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ByteChannel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ByteChannel.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ByteChannel.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ByteChannel.java Tue Oct 23 06:54:37 2007
@@ -16,15 +16,13 @@
 
 package java.nio.channels;
 
-
 /**
  * A ByteChannel is both readable and writable.
  * <p>
  * The methods for the byte channel are precisely those defined by readable and
  * writable byte channels.
  * </p>
- * 
  */
 public interface ByteChannel extends ReadableByteChannel, WritableByteChannel {
-	// No methods defined.
+    // No methods defined.
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/CancelledKeyException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/CancelledKeyException.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/CancelledKeyException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/CancelledKeyException.java Tue Oct 23 06:54:37 2007
@@ -16,23 +16,20 @@
 
 package java.nio.channels;
 
-
 /**
  * Thrown when an invalid selection key is used.
- * 
  */
 public class CancelledKeyException extends IllegalStateException {
 
-	/**
-	 * Version ID for serialization.
-	 */
-	private static final long serialVersionUID = -8438032138028814268L;
+    /**
+     * Version ID for serialization.
+     */
+    private static final long serialVersionUID = -8438032138028814268L;
 
-	/**
-	 * Default constructor.
-	 *
-	 */
-	public CancelledKeyException() {
-		super();
-	}
+    /**
+     * Default constructor.
+     */
+    public CancelledKeyException() {
+        super();
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/Channel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/Channel.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/Channel.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/Channel.java Tue Oct 23 06:54:37 2007
@@ -16,7 +16,6 @@
 
 package java.nio.channels;
 
-
 import java.io.Closeable;
 import java.io.IOException;
 
@@ -33,35 +32,34 @@
  * Particular implementations or sub-interfaces of Channel dictate whether they
  * are thread-safe or not.
  * </p>
- * 
  */
 public interface Channel extends Closeable {
 
-	/**
-	 * Answers whether this channel is open or not.
-	 * 
-	 * @return true if the channel is open, otherwise answers false.
-	 */
-	public boolean isOpen();
+    /**
+     * Answers whether this channel is open or not.
+     * 
+     * @return true if the channel is open, otherwise answers false.
+     */
+    public boolean isOpen();
 
-	/**
-	 * Closes an open channel.
-	 * 
-	 * If the channel is already closed this method has no effect. If there is a
-	 * problem with closing the channel then the method throws an IOException
-	 * and the exception contains reasons for the failure.
-	 * <p>
-	 * If an attempt is made to perform an operation on a closed channel then a
-	 * <code>ClosedChannelException</code> will be thrown on that attempt.
-	 * </p>
-	 * <p>
-	 * If multiple threads attempts to simultaneously close a channel, then only
-	 * one thread will run the closure code, and others will be blocked until the
-	 * first returns.
-	 * </p>
-	 * 
-	 * @throws IOException
-	 *             if a problem occurs closing the channel.
-	 */
-	public void close() throws IOException;
+    /**
+     * Closes an open channel.
+     * 
+     * If the channel is already closed this method has no effect. If there is a
+     * problem with closing the channel then the method throws an IOException
+     * and the exception contains reasons for the failure.
+     * <p>
+     * If an attempt is made to perform an operation on a closed channel then a
+     * <code>ClosedChannelException</code> will be thrown on that attempt.
+     * </p>
+     * <p>
+     * If multiple threads attempts to simultaneously close a channel, then only
+     * one thread will run the closure code, and others will be blocked until
+     * the first returns.
+     * </p>
+     * 
+     * @throws IOException
+     *             if a problem occurs closing the channel.
+     */
+    public void close() throws IOException;
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/Channels.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/Channels.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/Channels.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/Channels.java Tue Oct 23 06:54:37 2007
@@ -32,13 +32,9 @@
 
 /**
  * This class provides several utilities to get I/O streams from channels.
- * 
  */
 public final class Channels {
 
-    // -------------------------------------------------------------------
-    // Constructor
-    // -------------------------------------------------------------------
     /*
      * Not intended to be instantiated.
      */
@@ -46,10 +42,6 @@
         super();
     }
 
-    // -------------------------------------------------------------------
-    // Public Methods
-    // -------------------------------------------------------------------
-
     /**
      * Answers an input stream on the given channel
      * 
@@ -107,8 +99,7 @@
      */
     public static Reader newReader(ReadableByteChannel channel,
             CharsetDecoder decoder, int minBufferCapacity) {
-        return new ByteChannelReader(
-                new ReaderInputStream(channel), decoder,
+        return new ByteChannelReader(new ReaderInputStream(channel), decoder,
                 minBufferCapacity);
     }
 
@@ -159,9 +150,6 @@
         return newWriter(channel, Charset.forName(charsetName).newEncoder(), -1);
     }
 
-    // -------------------------------------------------------------------
-    // share routine
-    // -------------------------------------------------------------------
     /*
      * wrap a byte array to a ByteBuffer
      */
@@ -174,136 +162,125 @@
         return buffer;
     }
 
-    // -------------------------------------------------------------------
-    // Wrapper classes
-    // -------------------------------------------------------------------
-
     private static class ChannelInputStream extends InputStream {
 
-		protected ReadableByteChannel channel;
+        protected ReadableByteChannel channel;
+
+        public ChannelInputStream(ReadableByteChannel aChannel) {
+            super();
+            channel = aChannel;
+        }
+
+        /**
+         * @see java.io.InputStream#read()
+         */
+        @Override
+        public synchronized int read() throws IOException {
+            byte[] oneByte = new byte[1];
+            int n = read(oneByte);
+            if (n == 1) {
+                // reads a single byte 0-255
+                return oneByte[0] & 0xff;
+            }
+            return -1;
+        }
+
+        /**
+         * @see java.io.InputStream#close()
+         */
+        @Override
+        public synchronized void close() throws IOException {
+            channel.close();
+        }
+    }
+
+    /*
+     * Wrapper class used for newInputStream(ReadableByteChannel channel)
+     */
+    private static class ReadableByteChannelInputStream extends
+            ChannelInputStream {
+
+        public ReadableByteChannelInputStream(ReadableByteChannel aChannel) {
+            super(aChannel);
+        }
+
+        /**
+         * @see java.io.InputStream#read(byte[], int, int)
+         */
+        @Override
+        public synchronized int read(byte[] target, int offset, int length)
+                throws IOException {
+            // avoid int overflow, check null target
+            if (length + offset > target.length || length < 0 || offset < 0) {
+                throw new ArrayIndexOutOfBoundsException();
+            }
+            if (0 == length) {
+                return 0;
+            }
+            if (channel instanceof SelectableChannel) {
+                if (!((SelectableChannel) channel).isBlocking()) {
+                    throw new IllegalBlockingModeException();
+                }
+            }
+            ByteBuffer buffer = ByteBuffer.wrap(target, offset, length);
+            return channel.read(buffer);
+        }
+    }
+
+    /*
+     * Wrapper class used for newReader(ReadableByteChannel channel,
+     * CharsetDecoder decoder, int minBufferCapacity)
+     */
+    private static class ReaderInputStream extends ChannelInputStream {
 
-		public ChannelInputStream(ReadableByteChannel aChannel) {
-			super();
-			channel = aChannel;
-		}
-
-		/*
-		 * @see java.io.InputStream#read()
-		 */
-		@Override
-		public synchronized int read() throws IOException {
-			byte[] oneByte = new byte[1];
-			int n = read(oneByte);
-			if (n == 1) {
-				// reads a single byte 0-255
-				return oneByte[0] & 0xff;
-			}
-			return -1;
-		}
-
-		/*
-		 * @see java.io.InputStream#close()
-		 */
-		@Override
-		public synchronized void close() throws IOException {
-			channel.close();
-		}
-	}
-
-	/*
-	 * Wrapper class used for newInputStream(ReadableByteChannel channel)
-	 */
-	private static class ReadableByteChannelInputStream extends
-			ChannelInputStream {
-
-		/*
-		 * @param someChannel
-		 */
-		public ReadableByteChannelInputStream(ReadableByteChannel aChannel) {
-			super(aChannel);
-		}
-
-		/*
-		 * @see java.io.InputStream#read(byte[], int, int)
-		 */
-		@Override
-		public synchronized int read(byte[] target, int offset, int length)
-				throws IOException {
-			// avoid int overflow, check null target
-			if (length + offset > target.length || length < 0 || offset < 0) {
-				throw new ArrayIndexOutOfBoundsException();
-			}
-			if (0 == length) {
-				return 0;
-			}
-			if (channel instanceof SelectableChannel) {
-				if (!((SelectableChannel) channel).isBlocking()) {
-					throw new IllegalBlockingModeException();
-				}
-			}
-			ByteBuffer buffer = ByteBuffer.wrap(target, offset, length);
-			return channel.read(buffer);
-		}
-	}
-
-	/*
-	 * Wrapper class used for newReader(ReadableByteChannel channel,
-	 * CharsetDecoder decoder, int minBufferCapacity)
-	 */
-	private static class ReaderInputStream extends ChannelInputStream {
-
-		/*
-		 * @param someChannel
-		 */
-		public ReaderInputStream(ReadableByteChannel aChannel) {
-			super(aChannel);
-		}
-
-		/*
-		 * @see java.io.InputStream#read(byte[], int, int)
-		 */
-		@Override
-		public synchronized int read(byte[] target, int offset, int length)
-				throws IOException {
-			// avoid int overflow, check null target
-			if (length + offset > target.length || length < 0 || offset < 0) {
-				throw new ArrayIndexOutOfBoundsException();
-			}
-			if (0 == length) {
-				return 0;
-			}
-			ByteBuffer buffer = ByteBuffer.wrap(target, offset, length);
-			return channel.read(buffer);
-		}
-	}
+        public ReaderInputStream(ReadableByteChannel aChannel) {
+            super(aChannel);
+        }
+
+        /**
+         * @see java.io.InputStream#read(byte[], int, int)
+         */
+        @Override
+        public synchronized int read(byte[] target, int offset, int length)
+                throws IOException {
+            // avoid int overflow, check null target
+            if (length + offset > target.length || length < 0 || offset < 0) {
+                throw new ArrayIndexOutOfBoundsException();
+            }
+            if (0 == length) {
+                return 0;
+            }
+            ByteBuffer buffer = ByteBuffer.wrap(target, offset, length);
+            return channel.read(buffer);
+        }
+    }
 
     /*
-	 * Wrapper class used for newOutputStream(WritableByteChannel channel)
-	 */
+     * Wrapper class used for newOutputStream(WritableByteChannel channel)
+     */
     private static class WritableByteChannelOutputStream extends OutputStream {
 
         private WritableByteChannel channel;
 
-        /*
-		 * @param someChannel
-		 */
         public WritableByteChannelOutputStream(WritableByteChannel aChannel) {
             super();
             channel = aChannel;
         }
 
-        /*
+        /**
          * @see java.io.OutputStream#write(int)
          */
+        @Override
         public synchronized void write(int oneByte) throws IOException {
             byte[] wrappedByte = new byte[1];
             wrappedByte[0] = (byte) oneByte;
             write(wrappedByte);
         }
 
-        /*
+        /**
          * @see java.io.OutputStream#write(byte[], int, int)
          */
+        @Override
         public synchronized void write(byte[] source, int offset, int length)
                 throws IOException {
             // avoid int overflow, check null source
@@ -322,9 +299,10 @@
             channel.write(buffer);
         }
 
-        /*
+        /**
          * @see java.io.OutputStream#close()
          */
+        @Override
         public synchronized void close() throws IOException {
             channel.close();
         }
@@ -342,7 +320,7 @@
             inputStream = aInputStream;
         }
 
-        /*
+        /**
          * @see java.nio.channels.ReadableByteChannel#read(java.nio.ByteBuffer)
          */
         public synchronized int read(ByteBuffer target) throws IOException {
@@ -364,9 +342,10 @@
             return readCount;
         }
 
-        /*
+        /**
          * @see java.nio.channels.spi.AbstractInterruptibleChannel#implCloseChannel()
          */
+        @Override
         protected void implCloseChannel() throws IOException {
             inputStream.close();
         }
@@ -384,7 +363,7 @@
             outputStream = aOutputStream;
         }
 
-        /*
+        /**
          * @see java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer)
          */
         public synchronized int write(ByteBuffer source) throws IOException {
@@ -406,9 +385,10 @@
             return bytesRemain;
         }
 
-        /*
+        /**
          * @see java.nio.channels.spi.AbstractInterruptibleChannel#implCloseChannel()
          */
+        @Override
         protected void implCloseChannel() throws IOException {
             outputStream.close();
         }
@@ -430,9 +410,6 @@
 
         CharBuffer chars;
 
-        /*
-         * @param inputStream @param dec @param minBufferCapacity
-         */
         public ByteChannelReader(InputStream aInputStream,
                 CharsetDecoder aDecoder, int minBufferCapacity) {
             super(aInputStream);
@@ -445,9 +422,10 @@
             chars.limit(0);
         }
 
-        /*
+        /**
          * @see java.io.Reader#close()
          */
+        @Override
         public void close() throws IOException {
             synchronized (lock) {
                 decoder = null;
@@ -458,9 +436,10 @@
             }
         }
 
-        /*
+        /**
          * @see java.io.Reader#ready()
          */
+        @Override
         public boolean ready() {
             synchronized (lock) {
                 if (null == inputStream) {
@@ -475,20 +454,22 @@
             }
         }
 
-        /*
+        /**
          * @see java.io.Reader#read()
          */
+        @Override
         public int read() throws IOException {
-            return IOUtil.readInputStreamReader(inputStream,
-                    bytes, chars, decoder, lock);
+            return IOUtil.readInputStreamReader(inputStream, bytes, chars,
+                    decoder, lock);
         }
 
-        /*
+        /**
          * @see java.io.Reader#read(char[], int, int)
          */
+        @Override
         public int read(char[] buf, int offset, int length) throws IOException {
-            return IOUtil.readInputStreamReader(buf, offset,
-                    length, inputStream, bytes, chars, decoder, lock);
+            return IOUtil.readInputStreamReader(buf, offset, length,
+                    inputStream, bytes, chars, decoder, lock);
         }
     }
 
@@ -506,8 +487,10 @@
 
         private ByteBuffer byteBuf;
 
-        /*
-         * @param outputStream @param enc @param minBufferCap
+        /**
+         * @param outputStream
+         * @param enc
+         * @param minBufferCap
          */
         public ByteChannelWriter(OutputStream aOutputStream,
                 CharsetEncoder aEncoder, int minBufferCap) {
@@ -518,9 +501,10 @@
             encoder = aEncoder;
         }
 
-        /*
+        /**
          * @see java.io.Writer#close()
          */
+        @Override
         public void close() throws IOException {
             synchronized (lock) {
                 if (encoder != null) {
@@ -533,37 +517,41 @@
             }
         }
 
-        /*
+        /**
          * @see java.io.Writer#flush()
          */
+        @Override
         public void flush() throws IOException {
-            IOUtil.flushOutputStreamWriter(outputStream,
-                    byteBuf, encoder, lock);
+            IOUtil
+                    .flushOutputStreamWriter(outputStream, byteBuf, encoder,
+                            lock);
         }
 
-        /*
+        /**
          * @see java.io.Writer#write(char[], int, int)
          */
+        @Override
         public void write(char[] buf, int offset, int count) throws IOException {
-            IOUtil.writeOutputStreamWriter(buf, offset, count,
-                    outputStream, byteBuf, encoder, lock);
+            IOUtil.writeOutputStreamWriter(buf, offset, count, outputStream,
+                    byteBuf, encoder, lock);
         }
 
-        /*
+        /**
          * @see java.io.Writer#write(int)
          */
+        @Override
         public void write(int oneChar) throws IOException {
-            IOUtil.writeOutputStreamWriter(oneChar,
-                    outputStream, byteBuf, encoder, lock);
+            IOUtil.writeOutputStreamWriter(oneChar, outputStream, byteBuf,
+                    encoder, lock);
         }
 
-        /*
+        /**
          * @see java.io.Writer#write(java.lang.String, int, int)
          */
+        @Override
         public void write(String str, int offset, int count) throws IOException {
-            IOUtil.writeOutputStreamWriter(str, offset, count,
-                    outputStream, byteBuf, encoder, lock);
+            IOUtil.writeOutputStreamWriter(str, offset, count, outputStream,
+                    byteBuf, encoder, lock);
         }
     }
-
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ClosedByInterruptException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ClosedByInterruptException.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ClosedByInterruptException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ClosedByInterruptException.java Tue Oct 23 06:54:37 2007
@@ -16,24 +16,21 @@
 
 package java.nio.channels;
 
-
 /**
  * Thrown when a thread is interrupted in a blocking IO operation.
  * <p>
- * When the thread is interrupted by a call to <code>interrupt()</code>
- * it will close the channel, set the interrupt status of the thread to true,
- * and throw a <code>ClosedByInterruptException</code>.
- * 
+ * When the thread is interrupted by a call to <code>interrupt()</code> it
+ * will close the channel, set the interrupt status of the thread to true, and
+ * throw a <code>ClosedByInterruptException</code>.
  */
 public class ClosedByInterruptException extends AsynchronousCloseException {
 
-	private static final long serialVersionUID = -4488191543534286750L;
+    private static final long serialVersionUID = -4488191543534286750L;
 
-	/**
-	 * Default constructor.
-	 *
-	 */
-	public ClosedByInterruptException() {
-		super();
-	}
+    /**
+     * Default constructor.
+     */
+    public ClosedByInterruptException() {
+        super();
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ClosedChannelException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ClosedChannelException.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ClosedChannelException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ClosedChannelException.java Tue Oct 23 06:54:37 2007
@@ -16,23 +16,20 @@
 
 package java.nio.channels;
 
-
 import java.io.IOException;
 
 /**
  * This exception is thrown when a channel is closed for the type of operation
  * attempted.
- * 
  */
 public class ClosedChannelException extends IOException {
 
-	private static final long serialVersionUID = 882777185433553857L;
-
-	/**
-	 * Default constructor. 
-	 */
-	public ClosedChannelException() {
-		super();
-	}
+    private static final long serialVersionUID = 882777185433553857L;
 
+    /**
+     * Default constructor.
+     */
+    public ClosedChannelException() {
+        super();
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ClosedSelectorException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ClosedSelectorException.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ClosedSelectorException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ClosedSelectorException.java Tue Oct 23 06:54:37 2007
@@ -16,22 +16,17 @@
 
 package java.nio.channels;
 
-
 /**
  * Thrown when an a selector is closed and an IO operation is attempted.
- * 
  */
 public class ClosedSelectorException extends IllegalStateException {
 
     private static final long serialVersionUID = 6466297122317847835L;
-    
-	/**
-	 * Default constructor.
-	 *
-	 */
-	public ClosedSelectorException() {
-		super();
-	}
-}
-
 
+    /**
+     * Default constructor.
+     */
+    public ClosedSelectorException() {
+        super();
+    }
+}

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ConnectionPendingException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ConnectionPendingException.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ConnectionPendingException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ConnectionPendingException.java Tue Oct 23 06:54:37 2007
@@ -16,22 +16,18 @@
 
 package java.nio.channels;
 
-
 /**
  * Thrown when an attempt is made to connect a SocketChannel that has a
  * non-blocking connection already underway.
- * 
  */
 public class ConnectionPendingException extends IllegalStateException {
 
-	private static final long serialVersionUID = 2008393366501760879L;
-
-	/**
-	 * Default constructor.
-	 * 
-	 */
-	public ConnectionPendingException() {
-		super();
-	}
+    private static final long serialVersionUID = 2008393366501760879L;
 
+    /**
+     * Default constructor.
+     */
+    public ConnectionPendingException() {
+        super();
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/DatagramChannel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/DatagramChannel.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/DatagramChannel.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/DatagramChannel.java Tue Oct 23 06:54:37 2007
@@ -42,415 +42,407 @@
  * Datagram channels are thread-safe, no more than one thread can read or write
  * at given time.
  * </p>
- * 
  */
 public abstract class DatagramChannel extends AbstractSelectableChannel
-		implements ByteChannel, ScatteringByteChannel, GatheringByteChannel {
+        implements ByteChannel, ScatteringByteChannel, GatheringByteChannel {
 
     static {
         Platform.getNetworkSystem().oneTimeInitialization(true);
     }
-    
-	/**
-	 * Constructor for this class.
-	 * 
-	 * @param selectorProvider
-	 *            A instance of SelectorProvider
-	 */
-	protected DatagramChannel(SelectorProvider selectorProvider) {
-		super(selectorProvider);
-	}
-
-	/**
-	 * Create a open and not-connected datagram channel.
-	 * <p>
-	 * This channel is got by <code>openDatagramChannel</code> method of the
-	 * default <code>SelectorProvider </code> instance.
-	 * </p>
-	 * 
-	 * @return The new created channel which is open but not-connected.
-	 * @throws IOException
-	 *             If some IO problem occurs.
-	 */
-	public static DatagramChannel open() throws IOException {
-		return SelectorProvider.provider().openDatagramChannel();
-	}
-
-	/**
-	 * Get the valid operations of this channel. Datagram channels support read
-	 * and write operation, so this method returns (
-	 * <code>SelectionKey.OP_READ</code> | <code>SelectionKey.OP_WRITE</code> ).
-	 * 
-	 * @see java.nio.channels.SelectableChannel#validOps()
-	 * @return Valid operations in bit-set.
-	 */
-	public final int validOps() {
-		return (SelectionKey.OP_READ | SelectionKey.OP_WRITE);
-	}
-
-	/**
-	 * Return the related datagram socket of this channel, which won't declare
-	 * public methods that not declared in <code>DatagramSocket</code>.
-	 * 
-	 * @return The related DatagramSocket instance.
-	 */
-	public abstract DatagramSocket socket();
-
-	/**
-	 * Answer whether this channel's socket is connected or not.
-	 * 
-	 * @return <code>true</code> for this channel's socket is connected;
-	 *         <code>false</code> otherwise.
-	 */
-	public abstract boolean isConnected();
-
-	/**
-	 * Connect the socket of this channel to a remote address, which is the only
-	 * communication peer of getting and sending datagrams after connected.
-	 * <p>
-	 * This method can be called at any moment, and won't affect the processing
-	 * read and write operation. The connect status won't changed before
-	 * disconnected and closed.
-	 * </p>
-	 * <p>
-	 * This method just execute the same security checks as the connect method
-	 * of the <code>DatagramSocket</code> class.
-	 * </p>
-	 * 
-	 * @param address
-	 *            The address to be connected.
-	 * @return This channel.
-	 * @throws ClosedChannelException
-	 *             If the channel is already closed.
-	 * @throws AsynchronousCloseException
-	 *             If the channel is closed by another thread while this method
-	 *             is in operation.
-	 * @throws ClosedByInterruptException
-	 *             If another thread interrupts the calling thread while the
-	 *             operation is in progress. The calling thread will have the
-	 *             interrupt state set, and the channel will be closed.
-	 * @throws SecurityException
-	 *             If there is a security manager, and the address is not
-	 *             permitted to access.
-	 * @throws IOException
-	 *             Some other IO error occurred.
-	 * 
-	 */
-	public abstract DatagramChannel connect(SocketAddress address)
-			throws IOException;
-
-	/**
-	 * Disconnect the socket of this channel, which is connected before for
-	 * getting and sending datagrams.
-	 * <p>
-	 * This method can be called at any moment, and won't affect the processing
-	 * read and write operation. It won't has any effect if the socket is not
-	 * connected or the channel is closed.
-	 * </p>
-	 * 
-	 * @return This channel.
-	 * @throws IOException
-	 *             Some other IO error occurred.
-	 */
-	public abstract DatagramChannel disconnect() throws IOException;
-
-	/**
-	 * Get a datagram from this channel.
-	 * <p>
-	 * This method transfers the datagram from the channel into the target byte
-	 * buffer and return the address of the datagram, if the datagram is
-	 * available or will be available as this channel is in blocking mode. This
-	 * method returns <code>null</code> if the datagram is not available now
-	 * and the channel is in non-blocking mode. The transfer start at the
-	 * current position of the buffer, and the residual part of the datagram
-	 * will be ignored if there is no efficient remaining in the buffer to store
-	 * the datagram.
-	 * </p>
-	 * <p>
-	 * This method can be called at any moment, and will block if there is
-	 * another thread started a read operation on the channel.
-	 * </p>
-	 * <p>
-	 * This method just execute the same security checks as the receive method
-	 * of the <code>DatagramSocket</code> class.
-	 * </p>
-	 * 
-	 * @param target
-	 *            The byte buffer to store the received datagram.
-	 * @return Address of the datagram if the transfer is performed, or null if
-	 *         the channel is in non-blocking mode and the datagram are
-	 *         unavailable.
-	 * @throws ClosedChannelException
-	 *             If the channel is already closed.
-	 * @throws AsynchronousCloseException
-	 *             If the channel is closed by another thread while this method
-	 *             is in operation.
-	 * @throws ClosedByInterruptException
-	 *             If another thread interrupts the calling thread while the
-	 *             operation is in progress. The calling thread will have the
-	 *             interrupt state set, and the channel will be closed.
-	 * @throws SecurityException
-	 *             If there is a security manager, and the address is not
-	 *             permitted to access.
-	 * @throws IOException
-	 *             Some other IO error occurred.
-	 * 
-	 */
-	public abstract SocketAddress receive(ByteBuffer target) throws IOException;
-
-	/**
-	 * Sends out a datagram by the channel.
-	 * <p>
-	 * The precondition of sending is that whether the channel is in blocking
-	 * mode and enough byte buffer space will be available, or the channel is in
-	 * non-blocking mode and byte buffer space is enough. The transfer action is
-	 * just like a regular write operation.
-	 * </p>
-	 * <p>
-	 * This method can be called at any moment, and will block if there is
-	 * another thread started a read operation on the channel.
-	 * </p>
-	 * <p>
-	 * This method just execute the same security checks as the send method of
-	 * the <code>DatagramSocket</code> class.
-	 * </p>
-	 * 
-	 * @param source
-	 *            The byte buffer with the datagram to be sent.
-	 * @param address
-	 *            The address to be sent.
-	 * @return The number of sent bytes. If this method is called, it returns
-	 *         the number of bytes that remaining in the byte buffer. If the
-	 *         channel is in non-blocking mode and no enough space for the
-	 *         datagram in the buffer, it may returns zero.
-	 * @throws ClosedChannelException
-	 *             If the channel is already closed.
-	 * @throws AsynchronousCloseException
-	 *             If the channel is closed by another thread while this method
-	 *             is in operation.
-	 * @throws ClosedByInterruptException
-	 *             If another thread interrupts the calling thread while the
-	 *             operation is in progress. The calling thread will have the
-	 *             interrupt state set, and the channel will be closed.
-	 * @throws SecurityException
-	 *             If there is a security manager, and the address is not
-	 *             permitted to access.
-	 * @throws IOException
-	 *             Some other IO error occurred.
-	 * 
-	 */
-	public abstract int send(ByteBuffer source, SocketAddress address)
-			throws IOException;
-
-	/**
-	 * Reads datagram from the channel into the byte buffer.
-	 * <p>
-	 * The precondition of calling this method is that the channel is connected
-	 * and the coming datagram is from the connected address. If the buffer is
-	 * not enough to store the datagram, the residual part of the datagram is
-	 * ignored. Otherwise, this method has the same behavior as the read method
-	 * in the <code>ReadableByteChannel</code> interface.
-	 * </p>
-	 * 
-	 * @see java.nio.channels.ReadableByteChannel#read(java.nio.ByteBuffer)
-	 * @param target
-	 *            The byte buffer to store the received datagram.
-	 * @return Non-negative number as the number of bytes read, or -1 as the
-	 *         read operation reaches the end of stream.
-	 * @throws NotYetConnectedException
-	 *             If the channel is not connected yet.
-	 * @throws ClosedChannelException
-	 *             If the channel is already closed.
-	 * @throws AsynchronousCloseException
-	 *             If the channel is closed by another thread while this method
-	 *             is in operation.
-	 * @throws ClosedByInterruptException
-	 *             If another thread interrupts the calling thread while the
-	 *             operation is in progress. The calling thread will have the
-	 *             interrupt state set, and the channel will be closed.
-	 * @throws IOException
-	 *             Some other IO error occurred.
-	 * 
-	 */
-	public abstract int read(ByteBuffer target) throws IOException;
-
-	/**
-	 * Reads datagram from the channel into the byte buffer.
-	 * <p>
-	 * The precondition of calling this method is that the channel is connected
-	 * and the coming datagram is from the connected address. If the buffer is
-	 * not enough to store the datagram, the residual part of the datagram is
-	 * ignored. Otherwise, this method has the same behavior as the read method
-	 * in the <code>ScatteringByteChannel</code> interface.
-	 * </p>
-	 * 
-	 * @see java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[],
-	 *      int, int)
-	 * @param targets
-	 *            The byte buffers to store the received datagram.
-	 * @param offset
-	 *            A non-negative offset in the array of buffer, pointing to the
-	 *            starting buffer to store the byte transferred, must no larger
-	 *            than targets.length.
-	 * @param length
-	 *            A non-negative length to indicate the maximum number of byte
-	 *            to be read, must no larger than targets.length - offset.
-	 * @return Non-negative number as the number of bytes read, or -1 as the
-	 *         read operation reaches the end of stream.
-	 * @throws NotYetConnectedException
-	 *             If the channel is not connected yet.
-	 * @throws ClosedChannelException
-	 *             If the channel is already closed.
-	 * @throws AsynchronousCloseException
-	 *             If the channel is closed by another thread while this method
-	 *             is in operation.
-	 * @throws ClosedByInterruptException
-	 *             If another thread interrupts the calling thread while the
-	 *             operation is in progress. The calling thread will have the
-	 *             interrupt state set, and the channel will be closed.
-	 * @throws IOException
-	 *             Some other IO error occurred.
-	 */
-	public abstract long read(ByteBuffer[] targets, int offset, int length)
-			throws IOException;
-
-	/**
-	 * Reads datagram from the channel into the byte buffer.
-	 * <p>
-	 * The precondition of calling this method is that the channel is connected
-	 * and the coming datagram is from the connected address. If the buffer is
-	 * not enough to store the datagram, the residual part of the datagram is
-	 * ignored. Otherwise, this method has the same behavior as the read method
-	 * in the <code>ScatteringByteChannel</code> interface.
-	 * </p>
-	 * 
-	 * @see java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[])
-	 * @param targets
-	 *            The byte buffers to store the received datagram.
-	 * @return Non-negative number as the number of bytes read, or -1 as the
-	 *         read operation reaches the end of stream.
-	 * @throws NotYetConnectedException
-	 *             If the channel is not connected yet.
-	 * @throws ClosedChannelException
-	 *             If the channel is already closed.
-	 * @throws AsynchronousCloseException
-	 *             If the channel is closed by another thread while this method
-	 *             is in operation.
-	 * @throws ClosedByInterruptException
-	 *             If another thread interrupts the calling thread while the
-	 *             operation is in progress. The calling thread will have the
-	 *             interrupt state set, and the channel will be closed.
-	 * @throws IOException
-	 *             Some other IO error occurred.
-	 */
-	public synchronized final long read(ByteBuffer[] targets)
-			throws IOException {
-		return read(targets, 0, targets.length);
-	}
-
-	/**
-	 * Write datagram from the byte buffer into the channel.
-	 * <p>
-	 * The precondition of calling this method is that the channel is connected
-	 * and the datagram is sent to the connected address. Otherwise, this method
-	 * has the same behavior as the write method in the
-	 * <code>WritableByteChannel</code> interface.
-	 * </p>
-	 * 
-	 * @see java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer)
-	 * @param source
-	 *            The byte buffer as the source of the datagram.
-	 * @return Non-negative number of bytes written.
-	 * @throws NotYetConnectedException
-	 *             If the channel is not connected yet.
-	 * @throws ClosedChannelException
-	 *             If the channel is already closed.
-	 * @throws AsynchronousCloseException
-	 *             If the channel is closed by another thread while this method
-	 *             is in operation.
-	 * @throws ClosedByInterruptException
-	 *             If another thread interrupts the calling thread while the
-	 *             operation is in progress. The calling thread will have the
-	 *             interrupt state set, and the channel will be closed.
-	 * @throws IOException
-	 *             Some other IO error occurred.
-	 * 
-	 */
-	public abstract int write(ByteBuffer source) throws IOException;
-
-	/**
-	 * Write datagram from the byte buffer into the channel.
-	 * <p>
-	 * The precondition of calling this method is that the channel is connected
-	 * and the datagram is sent to the connected address. Otherwise, this method
-	 * has the same behavior as the write method in the
-	 * <code>GatheringByteChannel</code> interface.
-	 * 
-	 * @see java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[],
-	 *      int, int)
-	 * @param sources
-	 *            The byte buffers as the source of the datagram.
-	 * @param offset
-	 *            A non-negative offset in the array of buffer, pointing to the
-	 *            starting buffer to be retrieved, must no larger than
-	 *            sources.length.
-	 * @param length
-	 *            A non-negative length to indicate the maximum number of byte
-	 *            to be written, must no larger than sources.length - offset.
-	 * @return The number of written bytes. If this method is called, it returns
-	 *         the number of bytes that remaining in the byte buffer. If the
-	 *         channel is in non-blocking mode and no enough space for the
-	 *         datagram in the buffer, it may returns zero.
-	 * @throws NotYetConnectedException
-	 *             If the channel is not connected yet.
-	 * @throws ClosedChannelException
-	 *             If the channel is already closed.
-	 * @throws AsynchronousCloseException
-	 *             If the channel is closed by another thread while this method
-	 *             is in operation.
-	 * @throws ClosedByInterruptException
-	 *             If another thread interrupts the calling thread while the
-	 *             operation is in progress. The calling thread will have the
-	 *             interrupt state set, and the channel will be closed.
-	 * @throws IOException
-	 *             Some other IO error occurred.
-	 * 
-	 */
-	public abstract long write(ByteBuffer[] sources, int offset, int length)
-			throws IOException;
-
-	/**
-	 * Write datagram from the byte buffer into the channel.
-	 * <p>
-	 * The precondition of calling this method is that the channel is connected
-	 * and the datagram is sent to the connected address. Otherwise, this method
-	 * has the same behavior as the write method in the
-	 * <code>GatheringByteChannel</code> interface.
-	 * 
-	 * @see java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[])
-	 * @param sources
-	 *            The byte buffers as the source of the datagram.
-	 * @return The number of written bytes. If this method is called, it returns
-	 *         the number of bytes that remaining in the byte buffer. If the
-	 *         channel is in non-blocking mode and no enough space for the
-	 *         datagram in the buffer, it may returns zero.
-	 * @throws NotYetConnectedException
-	 *             If the channel is not connected yet.
-	 * @throws ClosedChannelException
-	 *             If the channel is already closed.
-	 * @throws AsynchronousCloseException
-	 *             If the channel is closed by another thread while this method
-	 *             is in operation.
-	 * @throws ClosedByInterruptException
-	 *             If another thread interrupts the calling thread while the
-	 *             operation is in progress. The calling thread will have the
-	 *             interrupt state set, and the channel will be closed.
-	 * @throws IOException
-	 *             Some other IO error occurred.
-	 * 
-	 */
-	public synchronized final long write(ByteBuffer[] sources)
-			throws IOException {
-		return write(sources, 0, sources.length);
-	}
+
+    /**
+     * Constructor for this class.
+     * 
+     * @param selectorProvider
+     *            A instance of SelectorProvider
+     */
+    protected DatagramChannel(SelectorProvider selectorProvider) {
+        super(selectorProvider);
+    }
+
+    /**
+     * Create a open and not-connected datagram channel.
+     * <p>
+     * This channel is got by <code>openDatagramChannel</code> method of the
+     * default <code>SelectorProvider </code> instance.
+     * </p>
+     * 
+     * @return The new created channel which is open but not-connected.
+     * @throws IOException
+     *             If some IO problem occurs.
+     */
+    public static DatagramChannel open() throws IOException {
+        return SelectorProvider.provider().openDatagramChannel();
+    }
+
+    /**
+     * Get the valid operations of this channel. Datagram channels support read
+     * and write operation, so this method returns (
+     * <code>SelectionKey.OP_READ</code> | <code>SelectionKey.OP_WRITE</code> ).
+     * 
+     * @see java.nio.channels.SelectableChannel#validOps()
+     * @return Valid operations in bit-set.
+     */
+    public final int validOps() {
+        return (SelectionKey.OP_READ | SelectionKey.OP_WRITE);
+    }
+
+    /**
+     * Return the related datagram socket of this channel, which won't declare
+     * public methods that not declared in <code>DatagramSocket</code>.
+     * 
+     * @return The related DatagramSocket instance.
+     */
+    public abstract DatagramSocket socket();
+
+    /**
+     * Answer whether this channel's socket is connected or not.
+     * 
+     * @return <code>true</code> for this channel's socket is connected;
+     *         <code>false</code> otherwise.
+     */
+    public abstract boolean isConnected();
+
+    /**
+     * Connect the socket of this channel to a remote address, which is the only
+     * communication peer of getting and sending datagrams after connected.
+     * <p>
+     * This method can be called at any moment, and won't affect the processing
+     * read and write operation. The connect status won't changed before
+     * disconnected and closed.
+     * </p>
+     * <p>
+     * This method just execute the same security checks as the connect method
+     * of the <code>DatagramSocket</code> class.
+     * </p>
+     * 
+     * @param address
+     *            The address to be connected.
+     * @return This channel.
+     * @throws ClosedChannelException
+     *             If the channel is already closed.
+     * @throws AsynchronousCloseException
+     *             If the channel is closed by another thread while this method
+     *             is in operation.
+     * @throws ClosedByInterruptException
+     *             If another thread interrupts the calling thread while the
+     *             operation is in progress. The calling thread will have the
+     *             interrupt state set, and the channel will be closed.
+     * @throws SecurityException
+     *             If there is a security manager, and the address is not
+     *             permitted to access.
+     * @throws IOException
+     *             Some other IO error occurred.
+     */
+    public abstract DatagramChannel connect(SocketAddress address)
+            throws IOException;
+
+    /**
+     * Disconnect the socket of this channel, which is connected before for
+     * getting and sending datagrams.
+     * <p>
+     * This method can be called at any moment, and won't affect the processing
+     * read and write operation. It won't has any effect if the socket is not
+     * connected or the channel is closed.
+     * </p>
+     * 
+     * @return This channel.
+     * @throws IOException
+     *             Some other IO error occurred.
+     */
+    public abstract DatagramChannel disconnect() throws IOException;
+
+    /**
+     * Get a datagram from this channel.
+     * <p>
+     * This method transfers the datagram from the channel into the target byte
+     * buffer and return the address of the datagram, if the datagram is
+     * available or will be available as this channel is in blocking mode. This
+     * method returns <code>null</code> if the datagram is not available now
+     * and the channel is in non-blocking mode. The transfer start at the
+     * current position of the buffer, and the residual part of the datagram
+     * will be ignored if there is no efficient remaining in the buffer to store
+     * the datagram.
+     * </p>
+     * <p>
+     * This method can be called at any moment, and will block if there is
+     * another thread started a read operation on the channel.
+     * </p>
+     * <p>
+     * This method just execute the same security checks as the receive method
+     * of the <code>DatagramSocket</code> class.
+     * </p>
+     * 
+     * @param target
+     *            The byte buffer to store the received datagram.
+     * @return Address of the datagram if the transfer is performed, or null if
+     *         the channel is in non-blocking mode and the datagram are
+     *         unavailable.
+     * @throws ClosedChannelException
+     *             If the channel is already closed.
+     * @throws AsynchronousCloseException
+     *             If the channel is closed by another thread while this method
+     *             is in operation.
+     * @throws ClosedByInterruptException
+     *             If another thread interrupts the calling thread while the
+     *             operation is in progress. The calling thread will have the
+     *             interrupt state set, and the channel will be closed.
+     * @throws SecurityException
+     *             If there is a security manager, and the address is not
+     *             permitted to access.
+     * @throws IOException
+     *             Some other IO error occurred.
+     */
+    public abstract SocketAddress receive(ByteBuffer target) throws IOException;
+
+    /**
+     * Sends out a datagram by the channel.
+     * <p>
+     * The precondition of sending is that whether the channel is in blocking
+     * mode and enough byte buffer space will be available, or the channel is in
+     * non-blocking mode and byte buffer space is enough. The transfer action is
+     * just like a regular write operation.
+     * </p>
+     * <p>
+     * This method can be called at any moment, and will block if there is
+     * another thread started a read operation on the channel.
+     * </p>
+     * <p>
+     * This method just execute the same security checks as the send method of
+     * the <code>DatagramSocket</code> class.
+     * </p>
+     * 
+     * @param source
+     *            The byte buffer with the datagram to be sent.
+     * @param address
+     *            The address to be sent.
+     * @return The number of sent bytes. If this method is called, it returns
+     *         the number of bytes that remaining in the byte buffer. If the
+     *         channel is in non-blocking mode and no enough space for the
+     *         datagram in the buffer, it may returns zero.
+     * @throws ClosedChannelException
+     *             If the channel is already closed.
+     * @throws AsynchronousCloseException
+     *             If the channel is closed by another thread while this method
+     *             is in operation.
+     * @throws ClosedByInterruptException
+     *             If another thread interrupts the calling thread while the
+     *             operation is in progress. The calling thread will have the
+     *             interrupt state set, and the channel will be closed.
+     * @throws SecurityException
+     *             If there is a security manager, and the address is not
+     *             permitted to access.
+     * @throws IOException
+     *             Some other IO error occurred.
+     */
+    public abstract int send(ByteBuffer source, SocketAddress address)
+            throws IOException;
+
+    /**
+     * Reads datagram from the channel into the byte buffer.
+     * <p>
+     * The precondition of calling this method is that the channel is connected
+     * and the coming datagram is from the connected address. If the buffer is
+     * not enough to store the datagram, the residual part of the datagram is
+     * ignored. Otherwise, this method has the same behavior as the read method
+     * in the <code>ReadableByteChannel</code> interface.
+     * </p>
+     * 
+     * @see java.nio.channels.ReadableByteChannel#read(java.nio.ByteBuffer)
+     * @param target
+     *            The byte buffer to store the received datagram.
+     * @return Non-negative number as the number of bytes read, or -1 as the
+     *         read operation reaches the end of stream.
+     * @throws NotYetConnectedException
+     *             If the channel is not connected yet.
+     * @throws ClosedChannelException
+     *             If the channel is already closed.
+     * @throws AsynchronousCloseException
+     *             If the channel is closed by another thread while this method
+     *             is in operation.
+     * @throws ClosedByInterruptException
+     *             If another thread interrupts the calling thread while the
+     *             operation is in progress. The calling thread will have the
+     *             interrupt state set, and the channel will be closed.
+     * @throws IOException
+     *             Some other IO error occurred.
+     */
+    public abstract int read(ByteBuffer target) throws IOException;
+
+    /**
+     * Reads datagram from the channel into the byte buffer.
+     * <p>
+     * The precondition of calling this method is that the channel is connected
+     * and the coming datagram is from the connected address. If the buffer is
+     * not enough to store the datagram, the residual part of the datagram is
+     * ignored. Otherwise, this method has the same behavior as the read method
+     * in the <code>ScatteringByteChannel</code> interface.
+     * </p>
+     * 
+     * @see java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[],
+     *      int, int)
+     * @param targets
+     *            The byte buffers to store the received datagram.
+     * @param offset
+     *            A non-negative offset in the array of buffer, pointing to the
+     *            starting buffer to store the byte transferred, must no larger
+     *            than targets.length.
+     * @param length
+     *            A non-negative length to indicate the maximum number of byte
+     *            to be read, must no larger than targets.length - offset.
+     * @return Non-negative number as the number of bytes read, or -1 as the
+     *         read operation reaches the end of stream.
+     * @throws NotYetConnectedException
+     *             If the channel is not connected yet.
+     * @throws ClosedChannelException
+     *             If the channel is already closed.
+     * @throws AsynchronousCloseException
+     *             If the channel is closed by another thread while this method
+     *             is in operation.
+     * @throws ClosedByInterruptException
+     *             If another thread interrupts the calling thread while the
+     *             operation is in progress. The calling thread will have the
+     *             interrupt state set, and the channel will be closed.
+     * @throws IOException
+     *             Some other IO error occurred.
+     */
+    public abstract long read(ByteBuffer[] targets, int offset, int length)
+            throws IOException;
+
+    /**
+     * Reads datagram from the channel into the byte buffer.
+     * <p>
+     * The precondition of calling this method is that the channel is connected
+     * and the coming datagram is from the connected address. If the buffer is
+     * not enough to store the datagram, the residual part of the datagram is
+     * ignored. Otherwise, this method has the same behavior as the read method
+     * in the <code>ScatteringByteChannel</code> interface.
+     * </p>
+     * 
+     * @see java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[])
+     * @param targets
+     *            The byte buffers to store the received datagram.
+     * @return Non-negative number as the number of bytes read, or -1 as the
+     *         read operation reaches the end of stream.
+     * @throws NotYetConnectedException
+     *             If the channel is not connected yet.
+     * @throws ClosedChannelException
+     *             If the channel is already closed.
+     * @throws AsynchronousCloseException
+     *             If the channel is closed by another thread while this method
+     *             is in operation.
+     * @throws ClosedByInterruptException
+     *             If another thread interrupts the calling thread while the
+     *             operation is in progress. The calling thread will have the
+     *             interrupt state set, and the channel will be closed.
+     * @throws IOException
+     *             Some other IO error occurred.
+     */
+    public synchronized final long read(ByteBuffer[] targets)
+            throws IOException {
+        return read(targets, 0, targets.length);
+    }
+
+    /**
+     * Write datagram from the byte buffer into the channel.
+     * <p>
+     * The precondition of calling this method is that the channel is connected
+     * and the datagram is sent to the connected address. Otherwise, this method
+     * has the same behavior as the write method in the
+     * <code>WritableByteChannel</code> interface.
+     * </p>
+     * 
+     * @see java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer)
+     * @param source
+     *            The byte buffer as the source of the datagram.
+     * @return Non-negative number of bytes written.
+     * @throws NotYetConnectedException
+     *             If the channel is not connected yet.
+     * @throws ClosedChannelException
+     *             If the channel is already closed.
+     * @throws AsynchronousCloseException
+     *             If the channel is closed by another thread while this method
+     *             is in operation.
+     * @throws ClosedByInterruptException
+     *             If another thread interrupts the calling thread while the
+     *             operation is in progress. The calling thread will have the
+     *             interrupt state set, and the channel will be closed.
+     * @throws IOException
+     *             Some other IO error occurred.
+     */
+    public abstract int write(ByteBuffer source) throws IOException;
+
+    /**
+     * Write datagram from the byte buffer into the channel.
+     * <p>
+     * The precondition of calling this method is that the channel is connected
+     * and the datagram is sent to the connected address. Otherwise, this method
+     * has the same behavior as the write method in the
+     * <code>GatheringByteChannel</code> interface.
+     * 
+     * @see java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[],
+     *      int, int)
+     * @param sources
+     *            The byte buffers as the source of the datagram.
+     * @param offset
+     *            A non-negative offset in the array of buffer, pointing to the
+     *            starting buffer to be retrieved, must no larger than
+     *            sources.length.
+     * @param length
+     *            A non-negative length to indicate the maximum number of byte
+     *            to be written, must no larger than sources.length - offset.
+     * @return The number of written bytes. If this method is called, it returns
+     *         the number of bytes that remaining in the byte buffer. If the
+     *         channel is in non-blocking mode and no enough space for the
+     *         datagram in the buffer, it may returns zero.
+     * @throws NotYetConnectedException
+     *             If the channel is not connected yet.
+     * @throws ClosedChannelException
+     *             If the channel is already closed.
+     * @throws AsynchronousCloseException
+     *             If the channel is closed by another thread while this method
+     *             is in operation.
+     * @throws ClosedByInterruptException
+     *             If another thread interrupts the calling thread while the
+     *             operation is in progress. The calling thread will have the
+     *             interrupt state set, and the channel will be closed.
+     * @throws IOException
+     *             Some other IO error occurred.
+     */
+    public abstract long write(ByteBuffer[] sources, int offset, int length)
+            throws IOException;
+
+    /**
+     * Write datagram from the byte buffer into the channel.
+     * <p>
+     * The precondition of calling this method is that the channel is connected
+     * and the datagram is sent to the connected address. Otherwise, this method
+     * has the same behavior as the write method in the
+     * <code>GatheringByteChannel</code> interface.
+     * 
+     * @see java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[])
+     * @param sources
+     *            The byte buffers as the source of the datagram.
+     * @return The number of written bytes. If this method is called, it returns
+     *         the number of bytes that remaining in the byte buffer. If the
+     *         channel is in non-blocking mode and no enough space for the
+     *         datagram in the buffer, it may returns zero.
+     * @throws NotYetConnectedException
+     *             If the channel is not connected yet.
+     * @throws ClosedChannelException
+     *             If the channel is already closed.
+     * @throws AsynchronousCloseException
+     *             If the channel is closed by another thread while this method
+     *             is in operation.
+     * @throws ClosedByInterruptException
+     *             If another thread interrupts the calling thread while the
+     *             operation is in progress. The calling thread will have the
+     *             interrupt state set, and the channel will be closed.
+     * @throws IOException
+     *             Some other IO error occurred.
+     */
+    public synchronized final long write(ByteBuffer[] sources)
+            throws IOException {
+        return write(sources, 0, sources.length);
+    }
 }



Mime
View raw message