harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r587508 [2/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
Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/FileChannel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/FileChannel.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/FileChannel.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/FileChannel.java Tue Oct 23 06:54:37 2007
@@ -16,7 +16,6 @@
 
 package java.nio.channels;
 
-
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.MappedByteBuffer;
@@ -83,195 +82,194 @@
  * modifications performed via a channel will be visible to the stream, and vice
  * versa; including modifications to the file position, content, size, etc.
  * </p>
- * 
  */
 public abstract class FileChannel extends AbstractInterruptibleChannel
-		implements GatheringByteChannel, ScatteringByteChannel, ByteChannel {
+        implements GatheringByteChannel, ScatteringByteChannel, ByteChannel {
+
+    /**
+     * A type of file mapping modes.
+     */
+    public static class MapMode {
+        /**
+         * Private mapping mode (equivalent to copy on write).
+         */
+        public static final MapMode PRIVATE = new MapMode("PRIVATE"); //$NON-NLS-1$
+
+        /**
+         * Read-only mapping mode.
+         */
+        public static final MapMode READ_ONLY = new MapMode("READ_ONLY"); //$NON-NLS-1$
+
+        /**
+         * Read-write mapping mode.
+         */
+        public static final MapMode READ_WRITE = new MapMode("READ_WRITE"); //$NON-NLS-1$
+
+        // The string used to display the mapping mode.
+        private final String displayName;
+
+        /*
+         * Private constructor prevents others creating new modes.
+         */
+        private MapMode(String displayName) {
+            super();
+            this.displayName = displayName;
+        }
+
+        /**
+         * Answers a string version of the mapping mode useful for debugging
+         * etc.
+         * 
+         * @return the mode string.
+         */
+        @Override
+        public String toString() {
+            return displayName;
+        }
+    }
+
+    /**
+     * Protected default constructor.
+     */
+    protected FileChannel() {
+        super();
+    }
+
+    /**
+     * Request that all updates to the channel are committed to the storage
+     * device.
+     * <p>
+     * When this method returns all modifications made to the platform file
+     * underlying this channel will be committed to a local storage device. If
+     * the file is not hosted locally, such as a networked file system, then
+     * applications cannot be certain that the modifications have been
+     * committed.
+     * </p>
+     * <p>
+     * There are no assurances given that changes made to the file using methods
+     * defined elsewhere will be committed. For example, changes made via a
+     * mapped byte buffer may not be committed.
+     * </p>
+     * <p>
+     * The <code>metadata</code> parameter indicated whether the update should
+     * include the file's metadata such as last modification time, last access
+     * time, etc. Note that passing <code>true</code> may invoke an underlying
+     * write to the operating system (if the platform is maintaining metadata
+     * such as last access time), even if the channel is opened read-only.
+     * 
+     * @param metadata
+     *            true if the file metadata should be flushed in addition to the
+     *            file content, and false otherwise.
+     * @throws ClosedChannelException
+     *             if the channel is already closed.
+     * @throws IOException
+     *             some other problem occurred.
+     */
+    public abstract void force(boolean metadata) throws IOException;
+
+    /**
+     * Obtain an exclusive lock on this file.
+     * <p>
+     * This is a convenience method for acquiring a maximum length lock on a
+     * file. It is equivalent to:
+     * 
+     * <pre>
+     * fileChannel.lock(0L, Long.MAX_VALUE, false)
+     * </pre>
+     * 
+     * @return the lock object representing the locked file area.
+     * @throws ClosedChannelException
+     *             the file channel is closed.
+     * @throws NonWritableChannelException
+     *             this channel was not opened for writing.
+     * @throws OverlappingFileLockException
+     *             Either a lock is already held that overlaps this lock
+     *             request, or another thread is waiting to acquire a lock that
+     *             will overlap with this request.
+     * @throws FileLockInterruptionException
+     *             The calling thread was interrupted while waiting to acquire
+     *             the lock.
+     * @throws AsynchronousCloseException
+     *             The channel was closed while the calling thread was waiting
+     *             to acquire the lock.
+     * @throws IOException
+     *             some other problem occurred obtaining the requested lock.
+     */
+    public final FileLock lock() throws IOException {
+        return lock(0L, Long.MAX_VALUE, false);
+    }
 
-	/**
-	 * A type of file mapping modes.
-	 * 
-	 */
-	public static class MapMode {
-		/**
-		 * Private mapping mode (equivalent to copy on write).
-		 */
-		public static final MapMode PRIVATE = new MapMode("PRIVATE"); //$NON-NLS-1$
-
-		/**
-		 * Read-only mapping mode.
-		 */
-		public static final MapMode READ_ONLY = new MapMode("READ_ONLY"); //$NON-NLS-1$
-
-		/**
-		 * Read-write mapping mode.
-		 */
-		public static final MapMode READ_WRITE = new MapMode("READ_WRITE"); //$NON-NLS-1$
-
-		// The string used to display the mapping mode.
-		private final String displayName;
-
-		/*
-		 * Private constructor prevents others creating new modes.
-		 */
-		private MapMode(String displayName) {
-			super();
-			this.displayName = displayName;
-		}
-
-		/**
-		 * Answers a string version of the mapping mode useful for debugging
-		 * etc.
-		 * 
-		 * @return the mode string.
-		 */
-		public String toString() {
-			return displayName;
-		}
-	}
-
-	/**
-	 * Protected default constructor.
-	 */
-	protected FileChannel() {
-		super();
-	}
-
-	/**
-	 * Request that all updates to the channel are committed to the storage
-	 * device.
-	 * <p>
-	 * When this method returns all modifications made to the platform file
-	 * underlying this channel will be committed to a local storage device. If
-	 * the file is not hosted locally, such as a networked file system, then
-	 * applications cannot be certain that the modifications have been
-	 * committed.
-	 * </p>
-	 * <p>
-	 * There are no assurances given that changes made to the file using methods
-	 * defined elsewhere will be committed. For example, changes made via a
-	 * mapped byte buffer may not be committed.
-	 * </p>
-	 * <p>
-	 * The <code>metadata</code> parameter indicated whether the update should
-	 * include the file's metadata such as last modification time, last access
-	 * time, etc. Note that passing <code>true</code> may invoke an underlying
-	 * write to the operating system (if the platform is maintaining metadata
-	 * such as last access time), even if the channel is opened read-only.
-	 * 
-	 * @param metadata
-	 *            true if the file metadata should be flushed in addition to the
-	 *            file content, and false otherwise.
-	 * @throws ClosedChannelException
-	 *             if the channel is already closed.
-	 * @throws IOException
-	 *             some other problem occurred.
-	 */
-	public abstract void force(boolean metadata) throws IOException;
-
-	/**
-	 * Obtain an exclusive lock on this file.
-	 * <p>
-	 * This is a convenience method for acquiring a maximum length lock on a
-	 * file. It is equivalent to:
-	 * 
-	 * <pre>
-	 * fileChannel.lock(0L, Long.MAX_VALUE, false)
-	 * </pre>
-	 * 
-	 * @return the lock object representing the locked file area.
-	 * @throws ClosedChannelException
-	 *             the file channel is closed.
-	 * @throws NonWritableChannelException
-	 *             this channel was not opened for writing.
-	 * @throws OverlappingFileLockException
-	 *             Either a lock is already held that overlaps this lock
-	 *             request, or another thread is waiting to acquire a lock that
-	 *             will overlap with this request.
-	 * @throws FileLockInterruptionException
-	 *             The calling thread was interrupted while waiting to acquire
-	 *             the lock.
-	 * @throws AsynchronousCloseException
-	 *             The channel was closed while the calling thread was waiting
-	 *             to acquire the lock.
-	 * @throws IOException
-	 *             some other problem occurred obtaining the requested lock.
-	 */
-	public final FileLock lock() throws IOException {
-		return lock(0L, Long.MAX_VALUE, false);
-	}
-
-	/**
-	 * Obtain a lock on a specified region of the file.
-	 * <p>
-	 * This is the blocking version of lock acquisition, see also the
-	 * <code>tryLock()</code> methods.
-	 * </p>
-	 * <p>
-	 * Attempts to acquire an overlapping lock region will fail. The attempt
-	 * will fail if the overlapping lock has already been obtained, or if
-	 * another thread is currently waiting to acquire the overlapping lock.
-	 * </p>
-	 * <p>
-	 * If the request is not for an overlapping lock, the thread calling this
-	 * method will block until the lock is obtained (likely by no contention or
-	 * another process releasing a lock), or this thread being interrupted or
-	 * the channel closed.
-	 * </p>
-	 * <p>
-	 * If the lock is obtained successfully then the FileLock object returned
-	 * represents the lock for subsequent operations on the locked region.
-	 * </p>
-	 * <p>
-	 * If the thread is interrupted while waiting for the lock, the thread is
-	 * set to the interrupted state, and throws a
-	 * <code>FileLockInterruptionException</code>. If the channel is closed
-	 * while the thread is waiting to obtain the lock then the thread throws a
-	 * <code>AsynchronousCloseException</code>.
-	 * </p>
-	 * <p>
-	 * There is no requirement for the position and size to be within the
-	 * current start and length of the file.
-	 * </p>
-	 * <p>
-	 * Some platforms do not support shared locks, and if a request is made for
-	 * a shared lock on such a platform this method will attempt to acquire an
-	 * exclusive lock instead. It is undefined whether the lock obtained is
-	 * advisory or mandatory.
-	 * </p>
-	 * 
-	 * @param position
-	 *            the starting position for the lock region
-	 * @param size
-	 *            the length of the lock, in bytes
-	 * @param shared
-	 *            a flag indicating whether an attempt should be made to acquire
-	 *            a shared lock.
-	 * @return the file lock object
-	 * @throws IllegalArgumentException
-	 *             if the parameters are invalid.
-	 * @throws ClosedChannelException
-	 *             if the channel is already closed.
-	 * @throws OverlappingFileLockException
-	 *             if the requested region overlaps an existing lock or pending
-	 *             lock request.
-	 * @throws NonReadableChannelException
-	 *             if the channel is not open in read-mode and shared is true.
-	 * @throws NonWritableChannelException
-	 *             if the channel is not open in write mode and shared is false.
-	 * @throws AsynchronousCloseException
-	 *             if the channel is closed by another thread while this method
-	 *             is in operation.
-	 * @throws FileLockInterruptionException
-	 *             if the thread is interrupted while in the state of waiting
-	 *             on the desired file lock.
-	 * @throws IOException
-	 *             if some other IO problem occurs.
-	 */
-	public abstract FileLock lock(long position, long size, boolean shared)
-			throws IOException;
+    /**
+     * Obtain a lock on a specified region of the file.
+     * <p>
+     * This is the blocking version of lock acquisition, see also the
+     * <code>tryLock()</code> methods.
+     * </p>
+     * <p>
+     * Attempts to acquire an overlapping lock region will fail. The attempt
+     * will fail if the overlapping lock has already been obtained, or if
+     * another thread is currently waiting to acquire the overlapping lock.
+     * </p>
+     * <p>
+     * If the request is not for an overlapping lock, the thread calling this
+     * method will block until the lock is obtained (likely by no contention or
+     * another process releasing a lock), or this thread being interrupted or
+     * the channel closed.
+     * </p>
+     * <p>
+     * If the lock is obtained successfully then the FileLock object returned
+     * represents the lock for subsequent operations on the locked region.
+     * </p>
+     * <p>
+     * If the thread is interrupted while waiting for the lock, the thread is
+     * set to the interrupted state, and throws a
+     * <code>FileLockInterruptionException</code>. If the channel is closed
+     * while the thread is waiting to obtain the lock then the thread throws a
+     * <code>AsynchronousCloseException</code>.
+     * </p>
+     * <p>
+     * There is no requirement for the position and size to be within the
+     * current start and length of the file.
+     * </p>
+     * <p>
+     * Some platforms do not support shared locks, and if a request is made for
+     * a shared lock on such a platform this method will attempt to acquire an
+     * exclusive lock instead. It is undefined whether the lock obtained is
+     * advisory or mandatory.
+     * </p>
+     * 
+     * @param position
+     *            the starting position for the lock region
+     * @param size
+     *            the length of the lock, in bytes
+     * @param shared
+     *            a flag indicating whether an attempt should be made to acquire
+     *            a shared lock.
+     * @return the file lock object
+     * @throws IllegalArgumentException
+     *             if the parameters are invalid.
+     * @throws ClosedChannelException
+     *             if the channel is already closed.
+     * @throws OverlappingFileLockException
+     *             if the requested region overlaps an existing lock or pending
+     *             lock request.
+     * @throws NonReadableChannelException
+     *             if the channel is not open in read-mode and shared is true.
+     * @throws NonWritableChannelException
+     *             if the channel is not open in write mode and shared is false.
+     * @throws AsynchronousCloseException
+     *             if the channel is closed by another thread while this method
+     *             is in operation.
+     * @throws FileLockInterruptionException
+     *             if the thread is interrupted while in the state of waiting on
+     *             the desired file lock.
+     * @throws IOException
+     *             if some other IO problem occurs.
+     */
+    public abstract FileLock lock(long position, long size, boolean shared)
+            throws IOException;
 
-	/**
+    /**
      * Maps the file into memory.There can be three modes:Read-only,Read/write
      * and Private.
      * 
@@ -298,140 +296,140 @@
      * @throws IOException
      *             If any I/O error occurs
      */
-	public abstract MappedByteBuffer map(FileChannel.MapMode mode,
-			long position, long size) throws IOException;
+    public abstract MappedByteBuffer map(FileChannel.MapMode mode,
+            long position, long size) throws IOException;
+
+    /**
+     * Answers the current value of the file position pointer.
+     * 
+     * @return the current position as a positive integer number of bytes from
+     *         the start of the file.
+     * @throws ClosedChannelException
+     *             if the channel is already closed.
+     * @throws IOException
+     *             if some other IO problem occurs.
+     */
+    public abstract long position() throws IOException;
 
-	/**
-	 * Answers the current value of the file position pointer.
-	 * 
-	 * @return the current position as a positive integer number of bytes from
-	 *         the start of the file.
-	 * @throws ClosedChannelException
-	 *             if the channel is already closed.
-	 * @throws IOException
-	 *             if some other IO problem occurs.
-	 */
-	public abstract long position() throws IOException;
-
-	/**
-	 * Sets the file position pointer to a new value.
-	 * <p>
-	 * The argument is the number of bytes counted from the start of the file.
-	 * The position cannot be set to a value that is negative. The new position
-	 * can be set beyond the current file size. If set beyond the current file
-	 * size, attempts to read will return end of file, and writes will succeed,
-	 * but fill-in the bytes between the current end of file and the position
-	 * with the required number of (unspecified) byte values.
-	 * 
-	 * @param offset
-	 *            the new file position, in bytes.
-	 * @return the receiver.
-	 * @throws IllegalArgumentException
-	 *             if the new position is negative.
-	 * @throws ClosedChannelException
-	 *             if the channel is already closed.
-	 * @throws IOException
-	 *             if some other IO problem occurs.
-	 */
-	public abstract FileChannel position(long offset) throws IOException;
-
-	/**
-	 * Reads bytes from the channel into the given byte buffer.
-	 * <p>
-	 * The bytes are read starting at the current file position, and after some
-	 * number of bytes are read (up to the remaining number of bytes in the
-	 * buffer) the file position is increased by the number of bytes actually
-	 * read.
-	 * 
-	 * @see java.nio.channels.ReadableByteChannel#read(java.nio.ByteBuffer)
-	 */
-	public abstract int read(ByteBuffer buffer) throws IOException;
-
-	/**
-	 * Reads bytes from the file channel into the given buffer starting from the
-	 * given file position.
-	 * <p>
-	 * The bytes are read starting at the given file position (up to the
-	 * remaining number of bytes in the buffer). The number of bytes actually
-	 * read is returned.
-	 * </p>
-	 * <p>
-	 * If the position is beyond the current end of file, then no bytes are
-	 * read.
-	 * </p>
-	 * <p>
-	 * Note that file position is unmodified by this method.
-	 * </p>
-	 * 
-	 * @param buffer
-	 *            the buffer to receive the bytes
-	 * @param position
-	 *            the (non-negative) position at which to read the bytes.
-	 * @return the number of bytes actually read.
-	 * @throws IllegalArgumentException
-	 *             if <code>position</code> is less than <code>-1</code>.
-	 * @throws ClosedChannelException
-	 *             if the channel is already closed.
-	 * @throws NonReadableChannelException
-	 *             if the channel was not opened in read-mode.
-	 * @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 buffer, long position)
-			throws IOException;
-
-	/**
-	 * Reads bytes from the channel into all the given byte buffers.
-	 * <p>
-	 * The bytes are read starting at the current file position, and after some
-	 * number of bytes are read (up to the remaining number of bytes in all the
-	 * buffers) the file position is increased by the number of bytes actually
-	 * read.
-	 * </p>
-	 * <p>
-	 * This method behaves exactly like:
-	 * 
-	 * <pre>
-	 * read(buffers, 0, buffers.length);
-	 * </pre>
-	 * 
-	 * </p>
-	 * 
-	 * @see java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[])
-	 */
-	public final long read(ByteBuffer[] buffers) throws IOException {
-		return read(buffers, 0, buffers.length);
-	}
-
-	/**
-	 * Reads bytes from the file channel into a subset of the given byte
-	 * buffers.
-	 * 
-	 * @see java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[],
-	 *      int, int)
-	 */
-	public abstract long read(ByteBuffer[] buffers, int start, int number)
-			throws IOException;
-
-	/**
-	 * Answers the size of the file underlying this channel, in bytes.
-	 * 
-	 * @return the size of the file in bytes.
-	 * @throws ClosedChannelException
-	 *             if the channel is closed.
-	 * @throws IOException
-	 *             if a problem occurs getting the size of the file.
-	 */
-	public abstract long size() throws IOException;
+    /**
+     * Sets the file position pointer to a new value.
+     * <p>
+     * The argument is the number of bytes counted from the start of the file.
+     * The position cannot be set to a value that is negative. The new position
+     * can be set beyond the current file size. If set beyond the current file
+     * size, attempts to read will return end of file, and writes will succeed,
+     * but fill-in the bytes between the current end of file and the position
+     * with the required number of (unspecified) byte values.
+     * 
+     * @param offset
+     *            the new file position, in bytes.
+     * @return the receiver.
+     * @throws IllegalArgumentException
+     *             if the new position is negative.
+     * @throws ClosedChannelException
+     *             if the channel is already closed.
+     * @throws IOException
+     *             if some other IO problem occurs.
+     */
+    public abstract FileChannel position(long offset) throws IOException;
 
-	/**
+    /**
+     * Reads bytes from the channel into the given byte buffer.
+     * <p>
+     * The bytes are read starting at the current file position, and after some
+     * number of bytes are read (up to the remaining number of bytes in the
+     * buffer) the file position is increased by the number of bytes actually
+     * read.
+     * 
+     * @see java.nio.channels.ReadableByteChannel#read(java.nio.ByteBuffer)
+     */
+    public abstract int read(ByteBuffer buffer) throws IOException;
+
+    /**
+     * Reads bytes from the file channel into the given buffer starting from the
+     * given file position.
+     * <p>
+     * The bytes are read starting at the given file position (up to the
+     * remaining number of bytes in the buffer). The number of bytes actually
+     * read is returned.
+     * </p>
+     * <p>
+     * If the position is beyond the current end of file, then no bytes are
+     * read.
+     * </p>
+     * <p>
+     * Note that file position is unmodified by this method.
+     * </p>
+     * 
+     * @param buffer
+     *            the buffer to receive the bytes
+     * @param position
+     *            the (non-negative) position at which to read the bytes.
+     * @return the number of bytes actually read.
+     * @throws IllegalArgumentException
+     *             if <code>position</code> is less than <code>-1</code>.
+     * @throws ClosedChannelException
+     *             if the channel is already closed.
+     * @throws NonReadableChannelException
+     *             if the channel was not opened in read-mode.
+     * @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 buffer, long position)
+            throws IOException;
+
+    /**
+     * Reads bytes from the channel into all the given byte buffers.
+     * <p>
+     * The bytes are read starting at the current file position, and after some
+     * number of bytes are read (up to the remaining number of bytes in all the
+     * buffers) the file position is increased by the number of bytes actually
+     * read.
+     * </p>
+     * <p>
+     * This method behaves exactly like:
+     * 
+     * <pre>
+     * read(buffers, 0, buffers.length);
+     * </pre>
+     * 
+     * </p>
+     * 
+     * @see java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[])
+     */
+    public final long read(ByteBuffer[] buffers) throws IOException {
+        return read(buffers, 0, buffers.length);
+    }
+
+    /**
+     * Reads bytes from the file channel into a subset of the given byte
+     * buffers.
+     * 
+     * @see java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[],
+     *      int, int)
+     */
+    public abstract long read(ByteBuffer[] buffers, int start, int number)
+            throws IOException;
+
+    /**
+     * Answers the size of the file underlying this channel, in bytes.
+     * 
+     * @return the size of the file in bytes.
+     * @throws ClosedChannelException
+     *             if the channel is closed.
+     * @throws IOException
+     *             if a problem occurs getting the size of the file.
+     */
+    public abstract long size() throws IOException;
+
+    /**
      * Transfers bytes into this channel's file from the given readable byte
      * channel. It may be very efficient.
      * 
@@ -458,14 +456,15 @@
      * @throws ClosedChannelException
      *             If either channel has already been closed
      * @throws AsynchronousCloseException
-     *             If either channel is closed by other threads during this operation
+     *             If either channel is closed by other threads during this
+     *             operation
      * @throws ClosedByInterruptException
      *             If the thread is interrupted during this operation
      * @throws IOException
      *             If any I/O error occurs
      */
-	public abstract long transferFrom(ReadableByteChannel src, long position,
-			long count) throws IOException;
+    public abstract long transferFrom(ReadableByteChannel src, long position,
+            long count) throws IOException;
 
     /**
      * Transfers data from the file to the given channel. It may be very
@@ -501,35 +500,35 @@
      * @throws IOException
      *             If any I/O error occurs
      */
-	public abstract long transferTo(long position, long count,
-			WritableByteChannel target) throws IOException;
+    public abstract long transferTo(long position, long count,
+            WritableByteChannel target) throws IOException;
 
-	/**
-	 * Truncates the file underlying this channel to a given size.
-	 * <p>
-	 * Any bytes beyond the given size are removed from the file. If there are
-	 * no bytes beyond the given size then the file contents are unmodified.
-	 * </p>
-	 * <p>
-	 * If the file position is currently greater than the given size, then it is
-	 * set to be the given size.
-	 * </p>
-	 * 
-	 * @param size
-	 *            the maximum size of the underlying file
-	 * @throws IllegalArgumentException
-	 *             the requested size is negative.
-	 * @throws ClosedChannelException
-	 *             the channel is closed.
-	 * @throws NonWritableChannelException
-	 *             the channel cannot be written.
-	 * @throws IOException
-	 *             some other IO problem occurred.
-	 * @return this channel
-	 */
-	public abstract FileChannel truncate(long size) throws IOException;
+    /**
+     * Truncates the file underlying this channel to a given size.
+     * <p>
+     * Any bytes beyond the given size are removed from the file. If there are
+     * no bytes beyond the given size then the file contents are unmodified.
+     * </p>
+     * <p>
+     * If the file position is currently greater than the given size, then it is
+     * set to be the given size.
+     * </p>
+     * 
+     * @param size
+     *            the maximum size of the underlying file
+     * @throws IllegalArgumentException
+     *             the requested size is negative.
+     * @throws ClosedChannelException
+     *             the channel is closed.
+     * @throws NonWritableChannelException
+     *             the channel cannot be written.
+     * @throws IOException
+     *             some other IO problem occurred.
+     * @return this channel
+     */
+    public abstract FileChannel truncate(long size) throws IOException;
 
-	/**
+    /**
      * Attempts to acquire an exclusive lock on this file without blocking.
      * <p>
      * This is a convenience method for attempting to acquire a maximum length
@@ -556,9 +555,9 @@
      * @throws IOException
      *             if any I/O error occurs
      */
-	public final FileLock tryLock() throws IOException {
-		return tryLock(0L, Long.MAX_VALUE, false);
-	}
+    public final FileLock tryLock() throws IOException {
+        return tryLock(0L, Long.MAX_VALUE, false);
+    }
 
     /**
      * Attempts to acquire an exclusive lock on this file without blocking.
@@ -587,10 +586,10 @@
      * @throws IOException
      *             if any I/O error occurs
      */
-	public abstract FileLock tryLock(long position, long size, boolean shared)
-			throws IOException;
+    public abstract FileLock tryLock(long position, long size, boolean shared)
+            throws IOException;
 
-	/**
+    /**
      * Writes bytes from the given byte buffer into the file channel.
      * <p>
      * The bytes are written starting at the current file position, and after
@@ -603,78 +602,75 @@
      * @param src
      *            the source buffer to write
      */
-	public abstract int write(ByteBuffer src) throws IOException;
+    public abstract int write(ByteBuffer src) throws IOException;
 
-	/**
-	 * Writes bytes from the given buffer to the file channel starting at the
-	 * given file position.
-	 * <p>
-	 * The bytes are written starting at the given file position (up to the
-	 * remaining number of bytes in the buffer). The number of bytes actually
-	 * written is returned.
-	 * </p>
-	 * <p>
-	 * If the position is beyond the current end of file, then the file is first
-	 * extended up to the given position by the required number of unspecified
-	 * byte values.
-	 * </p>
-	 * <p>
-	 * Note that file position is unmodified by this method.
-	 * </p>
-	 * 
-	 * @param buffer
-	 *            the buffer containing the bytes to be written.
-	 * @param position
-	 *            the (non-negative) position at which to write the bytes.
-	 * @return the number of bytes actually written.
-	 * @throws IllegalArgumentException
-	 *             if <code>position</code> is less than <code>-1</code>.
-	 * @throws ClosedChannelException
-	 *             if the channel is already closed.
-	 * @throws NonWritableChannelException
-	 *             if the channel was not opened in write-mode.
-	 * @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 buffer, long position)
-			throws IOException;
-
-	/**
-	 * Writes bytes from all the given byte buffers into the file channel.
-	 * <p>
-	 * The bytes are written starting at the current file position, and after
-	 * some number of bytes are written (up to the remaining number of bytes in
-	 * all the buffers) the file position is increased by the number of bytes
-	 * actually written.
-	 * <p>
-	 * This method behaves exactly like:
-	 * 
-	 * <pre>
-	 * write(buffers, 0, buffers.length);
-	 * </pre>
-	 * 
-	 * </p>
-	 * 
-	 * @see java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[])
-	 */
-	public final long write(ByteBuffer[] buffers) throws IOException {
-		return write(buffers, 0, buffers.length);
-	}
-
-	/**
-	 * 
-	 * 
-	 * @see java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[],
-	 *      int, int)
-	 */
-	public abstract long write(ByteBuffer[] buffers, int offset, int length)
-			throws IOException;
+    /**
+     * Writes bytes from the given buffer to the file channel starting at the
+     * given file position.
+     * <p>
+     * The bytes are written starting at the given file position (up to the
+     * remaining number of bytes in the buffer). The number of bytes actually
+     * written is returned.
+     * </p>
+     * <p>
+     * If the position is beyond the current end of file, then the file is first
+     * extended up to the given position by the required number of unspecified
+     * byte values.
+     * </p>
+     * <p>
+     * Note that file position is unmodified by this method.
+     * </p>
+     * 
+     * @param buffer
+     *            the buffer containing the bytes to be written.
+     * @param position
+     *            the (non-negative) position at which to write the bytes.
+     * @return the number of bytes actually written.
+     * @throws IllegalArgumentException
+     *             if <code>position</code> is less than <code>-1</code>.
+     * @throws ClosedChannelException
+     *             if the channel is already closed.
+     * @throws NonWritableChannelException
+     *             if the channel was not opened in write-mode.
+     * @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 buffer, long position)
+            throws IOException;
+
+    /**
+     * Writes bytes from all the given byte buffers into the file channel.
+     * <p>
+     * The bytes are written starting at the current file position, and after
+     * some number of bytes are written (up to the remaining number of bytes in
+     * all the buffers) the file position is increased by the number of bytes
+     * actually written.
+     * <p>
+     * This method behaves exactly like:
+     * 
+     * <pre>
+     * write(buffers, 0, buffers.length);
+     * </pre>
+     * 
+     * </p>
+     * 
+     * @see java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[])
+     */
+    public final long write(ByteBuffer[] buffers) throws IOException {
+        return write(buffers, 0, buffers.length);
+    }
 
+    /**
+     * @see java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[],
+     *      int, int)
+     */
+    public abstract long write(ByteBuffer[] buffers, int offset, int length)
+            throws IOException;
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/FileLock.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/FileLock.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/FileLock.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/FileLock.java Tue Oct 23 06:54:37 2007
@@ -70,92 +70,92 @@
  */
 public abstract class FileLock {
 
-	// The underlying file channel.
-	private final FileChannel channel;
+    // The underlying file channel.
+    private final FileChannel channel;
 
-	// The lock starting position.
-	private final long position;
+    // The lock starting position.
+    private final long position;
 
-	// The lock length in bytes
-	private final long size;
+    // The lock length in bytes
+    private final long size;
 
-	// If true then shared, if false then exclusive
-	private final boolean shared;
-
-	/**
-	 * Constructor for a new file lock instance for a given channel. The
-	 * constructor enforces the starting position, stretch, and shared status of
-	 * the lock.
-	 * 
-	 * @param channel
-	 *            underlying file channel that holds the lock.
-	 * @param position
-	 *            starting point for the lock.
-	 * @param size
-	 *            length of lock in number of bytes.
-	 * @param shared
-	 *            shared status of lock (true is shared, false is exclusive).
-	 */
-	protected FileLock(FileChannel channel, long position, long size,
-			boolean shared) {
-		super();
-		if (position < 0 || size < 0 || position + size < 0) {
-			throw new IllegalArgumentException();
-		}
-		this.channel = channel;
-		this.position = position;
-		this.size = size;
-		this.shared = shared;
-	}
-
-	/**
-	 * Answers the lock's FileChannel.
-	 * 
-	 * @return the channel.
-	 */
-	public final FileChannel channel() {
-		return channel;
-	}
-
-	/**
-	 * Answers the lock's starting position in the file.
-	 * 
-	 * @return the lock position.
-	 */
-	public final long position() {
-		return position;
-	}
-
-	/**
-	 * Answers the length of the file lock in bytes.
-	 * 
-	 * @return the size of file lock in bytes.
-	 */
-	public final long size() {
-		return size;
-	}
-
-	/**
-	 * Answers true if the file lock is shared with other processes and false if
-	 * it is not.
-	 * 
-	 * @return true if the lock is a shared lock, and false if it is exclusive.
-	 */
-	public final boolean isShared() {
-		return shared;
-	}
-
-	/**
-	 * Answers true if the receiver's lock region overlapps the region described
-	 * in the parameter list,and answers false otherwise.
-	 * 
-	 * @param start
-	 *            the starting position for the comparative lock.
-	 * @param length
-	 *            the length of the comparative lock.
-	 * @return true if there is an overlap, and false otherwise.
-	 */
-	public final boolean overlaps(long start, long length) {
+    // If true then shared, if false then exclusive
+    private final boolean shared;
+
+    /**
+     * Constructor for a new file lock instance for a given channel. The
+     * constructor enforces the starting position, stretch, and shared status of
+     * the lock.
+     * 
+     * @param channel
+     *            underlying file channel that holds the lock.
+     * @param position
+     *            starting point for the lock.
+     * @param size
+     *            length of lock in number of bytes.
+     * @param shared
+     *            shared status of lock (true is shared, false is exclusive).
+     */
+    protected FileLock(FileChannel channel, long position, long size,
+            boolean shared) {
+        super();
+        if (position < 0 || size < 0 || position + size < 0) {
+            throw new IllegalArgumentException();
+        }
+        this.channel = channel;
+        this.position = position;
+        this.size = size;
+        this.shared = shared;
+    }
+
+    /**
+     * Answers the lock's FileChannel.
+     * 
+     * @return the channel.
+     */
+    public final FileChannel channel() {
+        return channel;
+    }
+
+    /**
+     * Answers the lock's starting position in the file.
+     * 
+     * @return the lock position.
+     */
+    public final long position() {
+        return position;
+    }
+
+    /**
+     * Answers the length of the file lock in bytes.
+     * 
+     * @return the size of file lock in bytes.
+     */
+    public final long size() {
+        return size;
+    }
+
+    /**
+     * Answers true if the file lock is shared with other processes and false if
+     * it is not.
+     * 
+     * @return true if the lock is a shared lock, and false if it is exclusive.
+     */
+    public final boolean isShared() {
+        return shared;
+    }
+
+    /**
+     * Answers true if the receiver's lock region overlapps the region described
+     * in the parameter list,and answers false otherwise.
+     * 
+     * @param start
+     *            the starting position for the comparative lock.
+     * @param length
+     *            the length of the comparative lock.
+     * @return true if there is an overlap, and false otherwise.
+     */
+    public final boolean overlaps(long start, long length) {
         final long end = position + size - 1;
         final long newEnd = start + length - 1;
         if (end < start || position > newEnd) {
@@ -164,42 +164,43 @@
         return true;
     }
 
-	/**
-	 * Answers whether the receiver is a valid file lock or not. The lock is
-	 * valid unless the underlying channel has been closed or it has been
-	 * explicitly released.
-	 * 
-	 * @return true if the lock is valid, and false otherwise.
-	 */
-	public abstract boolean isValid();
-
-	/**
-	 * Releases this particular lock on the file. If the lock is invalid then
-	 * this method has no effect. Once released the lock becomes invalid.
-	 * 
-	 * @throws ClosedChannelException
-	 *             if the channel is already closed when an attempt to release
-	 *             the lock is made.
-	 * @throws IOException
-	 *             some other IO exception occurred.
-	 */
-	public abstract void release() throws IOException;
-
-	/**
-	 * Answers a string that shows the details of the lock suitable for display
-	 * to an end user.
-	 * 
-	 * @return the display string.
-	 */
-	public final String toString() {
-		StringBuffer buffer = new StringBuffer(64); // Guess length of string
-		buffer.append("FileLock: [position="); //$NON-NLS-1$
-		buffer.append(position);
-		buffer.append(", size="); //$NON-NLS-1$
-		buffer.append(size);
-		buffer.append(", shared="); //$NON-NLS-1$
-		buffer.append(Boolean.toString(shared));
-		buffer.append("]"); //$NON-NLS-1$
-		return buffer.toString();
-	}
+    /**
+     * Answers whether the receiver is a valid file lock or not. The lock is
+     * valid unless the underlying channel has been closed or it has been
+     * explicitly released.
+     * 
+     * @return true if the lock is valid, and false otherwise.
+     */
+    public abstract boolean isValid();
+
+    /**
+     * Releases this particular lock on the file. If the lock is invalid then
+     * this method has no effect. Once released the lock becomes invalid.
+     * 
+     * @throws ClosedChannelException
+     *             if the channel is already closed when an attempt to release
+     *             the lock is made.
+     * @throws IOException
+     *             some other IO exception occurred.
+     */
+    public abstract void release() throws IOException;
+
+    /**
+     * Answers a string that shows the details of the lock suitable for display
+     * to an end user.
+     * 
+     * @return the display string.
+     */
+    @SuppressWarnings("nls")
+    public final String toString() {
+        StringBuffer buffer = new StringBuffer(64); // Guess length of string
+        buffer.append("FileLock: [position=");
+        buffer.append(position);
+        buffer.append(", size=");
+        buffer.append(size);
+        buffer.append(", shared=");
+        buffer.append(Boolean.toString(shared));
+        buffer.append("]");
+        return buffer.toString();
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/FileLockInterruptionException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/FileLockInterruptionException.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/FileLockInterruptionException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/FileLockInterruptionException.java Tue Oct 23 06:54:37 2007
@@ -16,7 +16,6 @@
 
 package java.nio.channels;
 
-
 import java.io.IOException;
 
 /**
@@ -24,16 +23,15 @@
  * <p>
  * Note that the thread will also be in the 'interrupted' state.
  * </p>
- * 
  */
 public class FileLockInterruptionException extends IOException {
 
-	private static final long serialVersionUID = 7104080643653532383L;
+    private static final long serialVersionUID = 7104080643653532383L;
 
-	/**
-	 * Default constructor.
-	 */
-	public FileLockInterruptionException() {
-		super();
-	}
+    /**
+     * Default constructor.
+     */
+    public FileLockInterruptionException() {
+        super();
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/GatheringByteChannel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/GatheringByteChannel.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/GatheringByteChannel.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/GatheringByteChannel.java Tue Oct 23 06:54:37 2007
@@ -16,7 +16,6 @@
 
 package java.nio.channels;
 
-
 import java.io.IOException;
 import java.nio.ByteBuffer;
 
@@ -26,79 +25,78 @@
  * <p>
  * The corresponding interface for reads is called
  * <code>ScatteringByteChannel</code>.
- * 
  */
 public interface GatheringByteChannel extends WritableByteChannel {
 
-	/**
-	 * Writes bytes from all the given buffers to the channel.
-	 * <p>
-	 * This method is equivalent to:
-	 * 
-	 * <pre>
-	 * write(buffers, 0, buffers.length);
-	 * </pre>
-	 * 
-	 * </p>
-	 * 
-	 * @param buffers
-	 *            the buffers containing bytes to be written.
-	 * @return the number of bytes actually written.
-	 * @throws ClosedChannelException
-	 *             if the channel is closed.
-	 * @throws NonWritableChannelException
-	 *             if the channel is open, but not in a mode that permits
-	 *             writing.
-	 * @throws ClosedByInterruptException
-	 *             if the thread is interrupted in its IO operation by another
-	 *             thread closing the channel.
-	 * @throws AsynchronousCloseException
-	 *             if the write is interrupted by another thread sending an
-	 *             explicit interrupt.
-	 * @throws IOException
-	 *             if some other type of exception occurs. Details are in the
-	 *             message.
-	 */
-	public long write(ByteBuffer[] buffers) throws IOException;
+    /**
+     * Writes bytes from all the given buffers to the channel.
+     * <p>
+     * This method is equivalent to:
+     * 
+     * <pre>
+     * write(buffers, 0, buffers.length);
+     * </pre>
+     * 
+     * </p>
+     * 
+     * @param buffers
+     *            the buffers containing bytes to be written.
+     * @return the number of bytes actually written.
+     * @throws ClosedChannelException
+     *             if the channel is closed.
+     * @throws NonWritableChannelException
+     *             if the channel is open, but not in a mode that permits
+     *             writing.
+     * @throws ClosedByInterruptException
+     *             if the thread is interrupted in its IO operation by another
+     *             thread closing the channel.
+     * @throws AsynchronousCloseException
+     *             if the write is interrupted by another thread sending an
+     *             explicit interrupt.
+     * @throws IOException
+     *             if some other type of exception occurs. Details are in the
+     *             message.
+     */
+    public long write(ByteBuffer[] buffers) throws IOException;
 
-	/**
-	 * Writes a subset of the given bytes from the buffers to the channel.
-	 * <p>
-	 * This method attempts to write all of the <code>remaining()</code> bytes
-	 * from <code>length</code> byte buffers, in order, starting at
-	 * <code>buffers[offset]</code>. The number of bytes actually written is
-	 * returned.
-	 * </p>
-	 * <p>
-	 * If a write operation is in progress, subsequent threads will block until
-	 * the write is completed, and will then contend for the ability to write.
-	 * </p>
-	 * 
-	 * @param buffers
-	 *            the array of byte buffers containing the source of remaining
-	 *            bytes that will be attempted to be written.
-	 * @param offset
-	 *            the index of the first buffer to write.
-	 * @param length
-	 *            the number of buffers to write.
-	 * @return the number of bytes actually written.
-	 * @throws IndexOutOfBoundsException
-	 *             if offset < 0 or > buffers.length; or length < 0 or >
-	 *             buffers.length - offset.
-	 * @throws NonWritableChannelException
-	 *             if the channel was not opened for writing.
-	 * @throws ClosedChannelException
-	 *             the channel is currently closed.
-	 * @throws AsynchronousCloseException
-	 *             the channel was closed by another thread while the write was
-	 *             underway.
-	 * @throws ClosedByInterruptException
-	 *             the thread was interrupted by another thread while the write
-	 *             was underway.
-	 * @throws IOException
-	 *             if some other type of exception occurs. Details are in the
-	 *             message.
-	 */
-	public long write(ByteBuffer[] buffers, int offset, int length)
-			throws IOException;
+    /**
+     * Writes a subset of the given bytes from the buffers to the channel.
+     * <p>
+     * This method attempts to write all of the <code>remaining()</code> bytes
+     * from <code>length</code> byte buffers, in order, starting at
+     * <code>buffers[offset]</code>. The number of bytes actually written is
+     * returned.
+     * </p>
+     * <p>
+     * If a write operation is in progress, subsequent threads will block until
+     * the write is completed, and will then contend for the ability to write.
+     * </p>
+     * 
+     * @param buffers
+     *            the array of byte buffers containing the source of remaining
+     *            bytes that will be attempted to be written.
+     * @param offset
+     *            the index of the first buffer to write.
+     * @param length
+     *            the number of buffers to write.
+     * @return the number of bytes actually written.
+     * @throws IndexOutOfBoundsException
+     *             if offset < 0 or > buffers.length; or length < 0 or >
+     *             buffers.length - offset.
+     * @throws NonWritableChannelException
+     *             if the channel was not opened for writing.
+     * @throws ClosedChannelException
+     *             the channel is currently closed.
+     * @throws AsynchronousCloseException
+     *             the channel was closed by another thread while the write was
+     *             underway.
+     * @throws ClosedByInterruptException
+     *             the thread was interrupted by another thread while the write
+     *             was underway.
+     * @throws IOException
+     *             if some other type of exception occurs. Details are in the
+     *             message.
+     */
+    public long write(ByteBuffer[] buffers, int offset, int length)
+            throws IOException;
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/IllegalBlockingModeException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/IllegalBlockingModeException.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/IllegalBlockingModeException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/IllegalBlockingModeException.java Tue Oct 23 06:54:37 2007
@@ -16,20 +16,18 @@
 
 package java.nio.channels;
 
-
 /**
  * Thrown when when operation that requires a specific blocking mode is invoked
  * on a channel that is in a different blocking mode.
- * 
  */
 public class IllegalBlockingModeException extends IllegalStateException {
 
-	private static final long serialVersionUID = -3335774961855590474L;
+    private static final long serialVersionUID = -3335774961855590474L;
 
-	/**
-	 * Default constructor.
-	 */
-	public IllegalBlockingModeException() {
-		super();
-	}
+    /**
+     * Default constructor.
+     */
+    public IllegalBlockingModeException() {
+        super();
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/IllegalSelectorException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/IllegalSelectorException.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/IllegalSelectorException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/IllegalSelectorException.java Tue Oct 23 06:54:37 2007
@@ -16,22 +16,18 @@
 
 package java.nio.channels;
 
-
 /**
  * Thrown when a call is made to register a channel on a selector that has been
  * created by a different provider.
- * 
  */
 public class IllegalSelectorException extends IllegalArgumentException {
 
-	private static final long serialVersionUID = -8406323347253320987L;
-
-	/**
-	 * Default constructor.
-	 * 
-	 */
-	public IllegalSelectorException() {
-		super();
-	}
+    private static final long serialVersionUID = -8406323347253320987L;
 
+    /**
+     * Default constructor.
+     */
+    public IllegalSelectorException() {
+        super();
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/InterruptibleChannel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/InterruptibleChannel.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/InterruptibleChannel.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/InterruptibleChannel.java Tue Oct 23 06:54:37 2007
@@ -16,7 +16,6 @@
 
 package java.nio.channels;
 
-
 import java.io.IOException;
 
 /**
@@ -37,22 +36,20 @@
  * closed. If the IO thread attempts to make an IO call with the interrupt
  * status set the call will immediately fail with a
  * <code>ClosedByInterruptException</code>.
- * 
  */
 public interface InterruptibleChannel extends Channel {
 
-	/**
-	 * Closes an InterruptibleChannel. This method is precisely the same as the
-	 * super-interface <code>close()</code>.
-	 * <p>
-	 * Any threads that are blocked on IO operations on this channel will be
-	 * interrupted with an <code>AsynchronousCloseException
-	 * </code>.
-	 * </p>
-	 * 
-	 * @throws IOException
-	 *             if an IO problem occurs closing the channel.
-	 */
-	public void close() throws IOException;
-
+    /**
+     * Closes an InterruptibleChannel. This method is precisely the same as the
+     * super-interface <code>close()</code>.
+     * <p>
+     * Any threads that are blocked on IO operations on this channel will be
+     * interrupted with an <code>AsynchronousCloseException
+     * </code>.
+     * </p>
+     * 
+     * @throws IOException
+     *             if an IO problem occurs closing the channel.
+     */
+    public void close() throws IOException;
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NoConnectionPendingException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NoConnectionPendingException.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NoConnectionPendingException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NoConnectionPendingException.java Tue Oct 23 06:54:37 2007
@@ -16,21 +16,18 @@
 
 package java.nio.channels;
 
-
 /**
  * Thrown if SocketChannel's finishConnect method is called before the
  * SocketChannel's connect method completed without error.
- * 
  */
 public class NoConnectionPendingException extends IllegalStateException {
 
-	private static final long serialVersionUID = -8296561183633134743L;
+    private static final long serialVersionUID = -8296561183633134743L;
 
-	/**
-	 * Default constructor.
-	 * 
-	 */
-	public NoConnectionPendingException() {
-		super();
-	}
+    /**
+     * Default constructor.
+     */
+    public NoConnectionPendingException() {
+        super();
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NonReadableChannelException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NonReadableChannelException.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NonReadableChannelException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NonReadableChannelException.java Tue Oct 23 06:54:37 2007
@@ -16,19 +16,17 @@
 
 package java.nio.channels;
 
-
 /**
  * Thrown when attempting to read from a channel that is not open for reading.
- * 
  */
 public class NonReadableChannelException extends IllegalStateException {
 
-	private static final long serialVersionUID = -3200915679294993514L;
+    private static final long serialVersionUID = -3200915679294993514L;
 
-	/**
-	 * Default constructor.
-	 */
-	public NonReadableChannelException() {
-		super();
-	}
+    /**
+     * Default constructor.
+     */
+    public NonReadableChannelException() {
+        super();
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NonWritableChannelException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NonWritableChannelException.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NonWritableChannelException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NonWritableChannelException.java Tue Oct 23 06:54:37 2007
@@ -16,19 +16,17 @@
 
 package java.nio.channels;
 
-
 /**
  * Thrown when attempting to write to a channel that is not open for writing.
- * 
  */
 public class NonWritableChannelException extends IllegalStateException {
 
-	private static final long serialVersionUID = -7071230488279011621L;
+    private static final long serialVersionUID = -7071230488279011621L;
 
-	/**
-	 * Default constructor.
-	 */
-	public NonWritableChannelException() {
-		super();
-	}
+    /**
+     * Default constructor.
+     */
+    public NonWritableChannelException() {
+        super();
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NotYetBoundException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NotYetBoundException.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NotYetBoundException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NotYetBoundException.java Tue Oct 23 06:54:37 2007
@@ -16,21 +16,18 @@
 
 package java.nio.channels;
 
-
 /**
  * Thrown if the server socket channel is not bound before an IO operation is
  * made.
- * 
  */
 public class NotYetBoundException extends IllegalStateException {
 
-	private static final long serialVersionUID = 4640999303950202242L;
+    private static final long serialVersionUID = 4640999303950202242L;
 
-	/**
-	 * Default constructor.
-	 * 
-	 */
-	public NotYetBoundException() {
-		super();
-	}
+    /**
+     * Default constructor.
+     */
+    public NotYetBoundException() {
+        super();
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NotYetConnectedException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NotYetConnectedException.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NotYetConnectedException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/NotYetConnectedException.java Tue Oct 23 06:54:37 2007
@@ -16,22 +16,18 @@
 
 package java.nio.channels;
 
-
 /**
  * Thrown if the socket channel is not connected before an IO operation is
  * invoked.
- * 
  */
 public class NotYetConnectedException extends IllegalStateException {
 
-	private static final long serialVersionUID = 4697316551909513464L;
-
-	/**
-	 * Default constructor.
-	 * 
-	 */
-	public NotYetConnectedException() {
-		super();
-	}
+    private static final long serialVersionUID = 4697316551909513464L;
 
+    /**
+     * Default constructor.
+     */
+    public NotYetConnectedException() {
+        super();
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/OverlappingFileLockException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/OverlappingFileLockException.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/OverlappingFileLockException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/OverlappingFileLockException.java Tue Oct 23 06:54:37 2007
@@ -16,20 +16,18 @@
 
 package java.nio.channels;
 
-
 /**
  * Thrown when attempting to acquire a lock that overlaps an existing or pending
  * lock held by this process.
- * 
  */
 public class OverlappingFileLockException extends IllegalStateException {
 
-	private static final long serialVersionUID = 2047812138163068433L;
+    private static final long serialVersionUID = 2047812138163068433L;
 
-	/**
-	 * Default constructor.
-	 */
-	public OverlappingFileLockException() {
-		super();
-	}
+    /**
+     * Default constructor.
+     */
+    public OverlappingFileLockException() {
+        super();
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ReadableByteChannel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ReadableByteChannel.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ReadableByteChannel.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ReadableByteChannel.java Tue Oct 23 06:54:37 2007
@@ -16,7 +16,6 @@
 
 package java.nio.channels;
 
-
 import java.io.IOException;
 import java.nio.ByteBuffer;
 
@@ -26,42 +25,41 @@
  * Reads are synchronous on a ReadableByteChannel, that is, if a read is already
  * in progress on the channel then subsequent reads will block until the first
  * read completes. It is undefined whether non-read operations will block.
- * 
  */
 public interface ReadableByteChannel extends Channel {
 
-	/**
-	 * Reads bytes from the channel into the given buffer.
-	 * <p>
-	 * The maximum number of bytes that will be read is the
-	 * <code>remaining()</code> number of bytes in the buffer when the method
-	 * invoked. The bytes will be read into the buffer starting at the buffer's
-	 * <code>position</code>.
-	 * </p>
-	 * <p>
-	 * The call may block if other threads are also attempting to read on the
-	 * same channel.
-	 * </p>
-	 * <p>
-	 * Upon completion, the buffer's <code>position()</code> is updated to the
-	 * end of the bytes that were read. The buffer's <code>limit()</code> is
-	 * unmodified.
-	 * </p>
-	 * 
-	 * @param buffer
-	 *            the byte buffer to receive the bytes.
-	 * @return the number of bytes actually read.
-	 * @throws NonReadableChannelException
-	 *             if the channel was not opened for reading.
-	 * @throws ClosedChannelException
-	 *             if the channel was already closed.
-	 * @throws AsynchronousCloseException
-	 *             if another thread closes the channel during the read.
-	 * @throws ClosedByInterruptException
-	 *             if another thread interrupt the calling thread during the
-	 *             read.
-	 * @throws IOException
-	 *             another IO exception occurs, details are in the message.
-	 */
-	public int read(ByteBuffer buffer) throws IOException;
+    /**
+     * Reads bytes from the channel into the given buffer.
+     * <p>
+     * The maximum number of bytes that will be read is the
+     * <code>remaining()</code> number of bytes in the buffer when the method
+     * invoked. The bytes will be read into the buffer starting at the buffer's
+     * <code>position</code>.
+     * </p>
+     * <p>
+     * The call may block if other threads are also attempting to read on the
+     * same channel.
+     * </p>
+     * <p>
+     * Upon completion, the buffer's <code>position()</code> is updated to the
+     * end of the bytes that were read. The buffer's <code>limit()</code> is
+     * unmodified.
+     * </p>
+     * 
+     * @param buffer
+     *            the byte buffer to receive the bytes.
+     * @return the number of bytes actually read.
+     * @throws NonReadableChannelException
+     *             if the channel was not opened for reading.
+     * @throws ClosedChannelException
+     *             if the channel was already closed.
+     * @throws AsynchronousCloseException
+     *             if another thread closes the channel during the read.
+     * @throws ClosedByInterruptException
+     *             if another thread interrupt the calling thread during the
+     *             read.
+     * @throws IOException
+     *             another IO exception occurs, details are in the message.
+     */
+    public int read(ByteBuffer buffer) throws IOException;
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ScatteringByteChannel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ScatteringByteChannel.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ScatteringByteChannel.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ScatteringByteChannel.java Tue Oct 23 06:54:37 2007
@@ -16,7 +16,6 @@
 
 package java.nio.channels;
 
-
 import java.io.IOException;
 import java.nio.ByteBuffer;
 
@@ -26,79 +25,77 @@
  * <p>
  * The corresponding interface for writes is called
  * <code>GatheringByteChannel</code>.
- * 
  */
 public interface ScatteringByteChannel extends ReadableByteChannel {
 
-	/**
-	 * Reads bytes from the channel into all the given buffers.
-	 * <p>
-	 * This method is equivalent to:
-	 * 
-	 * <pre>
-	 * read(buffers, 0, buffers.length);
-	 * </pre>
-	 * 
-	 * </p>
-	 * 
-	 * @param buffers
-	 *            the array of byte buffers to receive the bytes being read.
-	 * @return the number of bytes actually read.
-	 * @throws ClosedChannelException
-	 *             if the channel is closed.
-	 * @throws NonReadableChannelException
-	 *             if the channel is open, but not in a mode that permits
-	 *             reading.
-	 * @throws ClosedByInterruptException
-	 *             if the thread is interrupted in its IO operation by another
-	 *             thread closing the channel.
-	 * @throws AsynchronousCloseException
-	 *             if the read is interrupted by another thread sending an
-	 *             explicit interrupt.
-	 * @throws IOException
-	 *             if some other type of exception occurs. Details are in the
-	 *             message.
-	 */
-	public long read(ByteBuffer[] buffers) throws IOException;
-
-	/**
-	 * Reads bytes from the channel into a subset of the given buffers.
-	 * <p>
-	 * This method attempts to read all of the <code>remaining()</code> bytes
-	 * from <code>length</code> byte buffers, in order, starting at
-	 * <code>buffers[offset]</code>. The number of bytes actually read is
-	 * returned.
-	 * </p>
-	 * <p>
-	 * If a read operation is in progress, subsequent threads will block until
-	 * the read is completed, and will then contend for the ability to read.
-	 * </p>
-	 * 
-	 * @param buffers
-	 *            the array of byte buffers into which the bytes will be read.
-	 * @param offset
-	 *            the index of the first buffer to read.
-	 * @param length
-	 *            the maximum number of buffers to read.
-	 * @return the number of bytes actually read.
-	 * @throws IndexOutOfBoundsException
-	 *             if offset < 0 or > buffers.length; or length < 0 or >
-	 *             buffers.length - offset.
-	 * @throws NonReadableChannelException
-	 *             if the channel was not opened for reading.
-	 * @throws ClosedChannelException
-	 *             the channel is currently closed.
-	 * @throws AsynchronousCloseException
-	 *             the channel was closed by another thread while the write was
-	 *             underway.
-	 * @throws ClosedByInterruptException
-	 *             the thread was interrupted by another thread while the write
-	 *             was underway.
-	 * @throws IOException
-	 *             if some other type of exception occurs. Details are in the
-	 *             message.
-	 */
-	public long read(ByteBuffer[] buffers, int offset, int length)
-			throws IOException;
+    /**
+     * Reads bytes from the channel into all the given buffers.
+     * <p>
+     * This method is equivalent to:
+     * 
+     * <pre>
+     * read(buffers, 0, buffers.length);
+     * </pre>
+     * 
+     * </p>
+     * 
+     * @param buffers
+     *            the array of byte buffers to receive the bytes being read.
+     * @return the number of bytes actually read.
+     * @throws ClosedChannelException
+     *             if the channel is closed.
+     * @throws NonReadableChannelException
+     *             if the channel is open, but not in a mode that permits
+     *             reading.
+     * @throws ClosedByInterruptException
+     *             if the thread is interrupted in its IO operation by another
+     *             thread closing the channel.
+     * @throws AsynchronousCloseException
+     *             if the read is interrupted by another thread sending an
+     *             explicit interrupt.
+     * @throws IOException
+     *             if some other type of exception occurs. Details are in the
+     *             message.
+     */
+    public long read(ByteBuffer[] buffers) throws IOException;
 
+    /**
+     * Reads bytes from the channel into a subset of the given buffers.
+     * <p>
+     * This method attempts to read all of the <code>remaining()</code> bytes
+     * from <code>length</code> byte buffers, in order, starting at
+     * <code>buffers[offset]</code>. The number of bytes actually read is
+     * returned.
+     * </p>
+     * <p>
+     * If a read operation is in progress, subsequent threads will block until
+     * the read is completed, and will then contend for the ability to read.
+     * </p>
+     * 
+     * @param buffers
+     *            the array of byte buffers into which the bytes will be read.
+     * @param offset
+     *            the index of the first buffer to read.
+     * @param length
+     *            the maximum number of buffers to read.
+     * @return the number of bytes actually read.
+     * @throws IndexOutOfBoundsException
+     *             if offset < 0 or > buffers.length; or length < 0 or >
+     *             buffers.length - offset.
+     * @throws NonReadableChannelException
+     *             if the channel was not opened for reading.
+     * @throws ClosedChannelException
+     *             the channel is currently closed.
+     * @throws AsynchronousCloseException
+     *             the channel was closed by another thread while the write was
+     *             underway.
+     * @throws ClosedByInterruptException
+     *             the thread was interrupted by another thread while the write
+     *             was underway.
+     * @throws IOException
+     *             if some other type of exception occurs. Details are in the
+     *             message.
+     */
+    public long read(ByteBuffer[] buffers, int offset, int length)
+            throws IOException;
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/SelectableChannel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/SelectableChannel.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/SelectableChannel.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/SelectableChannel.java Tue Oct 23 06:54:37 2007
@@ -16,7 +16,6 @@
 
 package java.nio.channels;
 
-
 import java.io.IOException;
 import java.nio.channels.spi.AbstractInterruptibleChannel;
 import java.nio.channels.spi.SelectorProvider;
@@ -24,19 +23,18 @@
 /**
  * A channel that can be detected by a selector. The channel can be registered
  * with some selectors, and when invoke select method of the selectors, the
- * channel can be checked if it is readable, writable, connectable or
- * acceptable according to its interesting operation.
- * 
+ * channel can be checked if it is readable, writable, connectable or acceptable
+ * according to its interesting operation.
  */
 public abstract class SelectableChannel extends AbstractInterruptibleChannel
-		implements Channel {
+        implements Channel {
 
     /**
      * Default constructor, can be overridden.
      */
-	protected SelectableChannel() {
-		super();
-	}
+    protected SelectableChannel() {
+        super();
+    }
 
     /**
      * Gets the blocking lock which synchronizes the configureBlocking and
@@ -44,7 +42,7 @@
      * 
      * @return the blocking object as lock
      */
-	public abstract Object blockingLock();
+    public abstract Object blockingLock();
 
     /**
      * Sets blocking mode of the channel.
@@ -59,22 +57,22 @@
      * @throws IOException
      *             if I/O error occurs
      */
-	public abstract SelectableChannel configureBlocking(boolean block)
-			throws IOException;
+    public abstract SelectableChannel configureBlocking(boolean block)
+            throws IOException;
 
     /**
      * Returns if channel is in blocking mode.
      * 
      * @return true if channel is blocking
      */
-	public abstract boolean isBlocking();
+    public abstract boolean isBlocking();
 
     /**
      * Returns if channel is registered.
      * 
      * @return true if channel is registered
      */
-	public abstract boolean isRegistered();
+    public abstract boolean isRegistered();
 
     /**
      * Gets the selection key for the channel with the given selector.
@@ -83,14 +81,14 @@
      *            the selector with which this channel may register
      * @return the selection key for the channel according to the given selector
      */
-	public abstract SelectionKey keyFor(Selector sel);
+    public abstract SelectionKey keyFor(Selector sel);
 
     /**
      * Gets the provider of the channel.
      * 
      * @return the provider of the channel
      */
-	public abstract SelectorProvider provider();
+    public abstract SelectorProvider provider();
 
     /**
      * Registers with the given selector with a certain interesting operation.
@@ -105,17 +103,17 @@
      * @throws IllegalBlockingModeException
      *             If the channel is in blocking mode
      * @throws IllegalSelectorException
-     *             If this channel does not have the same provider as the
-     *             given selector
+     *             If this channel does not have the same provider as the given
+     *             selector
      * @throws CancelledKeyException
      *             If this channel is registered but its key has been cancelled
      * @throws IllegalArgumentException
      *             If the operation given is unsupported by this channel
      */
-	public final SelectionKey register(Selector selector, int operations)
-			throws ClosedChannelException {
-		return register(selector, operations, null);
-	}
+    public final SelectionKey register(Selector selector, int operations)
+            throws ClosedChannelException {
+        return register(selector, operations, null);
+    }
 
     /**
      * Registers with the given selector with a certain interesting operation
@@ -140,14 +138,13 @@
      * @throws IllegalArgumentException
      *             If the operation given is unsupported by this channel
      */
-	public abstract SelectionKey register(Selector sel, int ops, Object att)
-			throws ClosedChannelException;
+    public abstract SelectionKey register(Selector sel, int ops, Object att)
+            throws ClosedChannelException;
 
     /**
      * Gets the possible interesting operation of the channel.
      * 
      * @return the possible interesting operation of the channel
      */
-	public abstract int validOps();
-
+    public abstract int validOps();
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ServerSocketChannel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ServerSocketChannel.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ServerSocketChannel.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/ServerSocketChannel.java Tue Oct 23 06:54:37 2007
@@ -24,96 +24,98 @@
 
 /**
  * A ServerSocketChannel is a partly abstracted stream-oriented listening socket
- * which is selectable. Binding and manipulation of socket options can only be done
- * through the associated <code>ServerSocket</code> object, returned by calling 
- * socket method. ServerSocketChannels can not be constructed for a pre-existing 
- * server socket, nor can it be assigned a SocketImpl.
- * <p> 
+ * which is selectable. Binding and manipulation of socket options can only be
+ * done through the associated <code>ServerSocket</code> object, returned by
+ * calling socket method. ServerSocketChannels can not be constructed for a
+ * pre-existing server socket, nor can it be assigned a SocketImpl.
+ * <p>
  * A Server-Socket channel is open but not bound when created by
- * <code>open</code> method. (Calling <code>accept</code> before bound will cause a
- * <code>NotYetBoundException</code>). It can be bound by calling the bind method 
- * of a related <code>ServerSocket</code> instance.</p>  
+ * <code>open</code> method. (Calling <code>accept</code> before bound will
+ * cause a <code>NotYetBoundException</code>). It can be bound by calling the
+ * bind method of a related <code>ServerSocket</code> instance.
+ * </p>
  */
 public abstract class ServerSocketChannel extends AbstractSelectableChannel {
 
-	/**
-	 * Construct a new instance for ServerSocketChannel
-	 * @param selectorProvider
-	 *            An instance of SelectorProvider
-	 */
-
-	protected ServerSocketChannel(SelectorProvider selectorProvider) {
-		super(selectorProvider);
-	}
-
-	/**
-	 * Create an open and unbound server-socket channel.
-	 * <p>
-	 * This channel is got by calling <code>openServerSocketChannel</code>
-	 * method of the default <code>SelectorProvider </code> instance.
-	 * </p> 
-	 * 
-	 * @return The new created channel which is open but unbound.
-	 * @throws IOException
-	 *             If some IO problem occurs.
-	 */
-	public static ServerSocketChannel open() throws IOException {
-		return SelectorProvider.provider().openServerSocketChannel();
-	}
-
-	/**
-	 * Get the valid operations of this channel. Server-socket channels support
-	 * accepting operation.Currently the only supported operation is OP_ACCEPT.
-	 * It always returns <code>SelectionKey.OP_ACCEPT</code>.
-	 * 
-	 * @see java.nio.channels.SelectableChannel#validOps()
-	 * @return Valid operations in bit-set.
-	 */
-	public final int validOps() {
-		return SelectionKey.OP_ACCEPT;
-	}
-
-	/**
-	 * Return the related server-socket of this channel. 
-	 * All public methods declared in returned object should be declared in <code>ServerSocket</code>.
-	 * 
-	 * @return The related ServerSocket instance.
-	 */
-	public abstract ServerSocket socket();
-
-	/**
-	 * Accepts a connection to this socket.
-	 * <p>
-	 * It returns null when the channel is non-blocking and no connections available, otherwise it
-	 * blocks indefinitely until a new connection is available or an I/O error occurs.
-	 * The returned channel will be in blocking mode any way. 
-	 * </p>
-	 * 
-	 * <p>
-	 * This method just execute the same security checks as the accept method of
-	 * the <code>ServerSocket</code> class.
-	 * </p>
-	 * 
-	 * @return The accepted SocketChannel instance, or null as the channel is
-	 *         non-blocking and no connections available.
-	 * @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 NotYetBoundException
-	 *             If the socket has not yet been bound.
-	 * @throws SecurityException
-	 *             If there is a security manager, and the new connection is not
-	 *             permitted to access.
-	 * @throws IOException
-	 *             Some other IO error occurred.
-	 * 
-	 */
-	public abstract SocketChannel accept() throws IOException;
-
+    /**
+     * Construct a new instance for ServerSocketChannel
+     * 
+     * @param selectorProvider
+     *            An instance of SelectorProvider
+     */
+    protected ServerSocketChannel(SelectorProvider selectorProvider) {
+        super(selectorProvider);
+    }
+
+    /**
+     * Create an open and unbound server-socket channel.
+     * <p>
+     * This channel is got by calling <code>openServerSocketChannel</code>
+     * method of the default <code>SelectorProvider </code> instance.
+     * </p>
+     * 
+     * @return The new created channel which is open but unbound.
+     * @throws IOException
+     *             If some IO problem occurs.
+     */
+    public static ServerSocketChannel open() throws IOException {
+        return SelectorProvider.provider().openServerSocketChannel();
+    }
+
+    /**
+     * Get the valid operations of this channel. Server-socket channels support
+     * accepting operation.Currently the only supported operation is OP_ACCEPT.
+     * It always returns <code>SelectionKey.OP_ACCEPT</code>.
+     * 
+     * @see java.nio.channels.SelectableChannel#validOps()
+     * @return Valid operations in bit-set.
+     */
+    public final int validOps() {
+        return SelectionKey.OP_ACCEPT;
+    }
+
+    /**
+     * Return the related server-socket of this channel. All public methods
+     * declared in returned object should be declared in
+     * <code>ServerSocket</code>.
+     * 
+     * @return The related ServerSocket instance.
+     */
+    public abstract ServerSocket socket();
+
+    /**
+     * Accepts a connection to this socket.
+     * <p>
+     * It returns null when the channel is non-blocking and no connections
+     * available, otherwise it blocks indefinitely until a new connection is
+     * available or an I/O error occurs. The returned channel will be in
+     * blocking mode any way.
+     * </p>
+     * 
+     * <p>
+     * This method just execute the same security checks as the accept method of
+     * the <code>ServerSocket</code> class.
+     * </p>
+     * 
+     * @return The accepted SocketChannel instance, or null as the channel is
+     *         non-blocking and no connections available.
+     * @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 NotYetBoundException
+     *             If the socket has not yet been bound.
+     * @throws SecurityException
+     *             If there is a security manager, and the new connection is not
+     *             permitted to access.
+     * @throws IOException
+     *             Some other IO error occurred.
+     * 
+     */
+    public abstract SocketChannel accept() throws IOException;
 }



Mime
View raw message