harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r587508 [3/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/SocketChannel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/SocketChannel.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/SocketChannel.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/SocketChannel.java Tue Oct 23 06:54:37 2007
@@ -59,426 +59,419 @@
  * </p>
  */
 public abstract class SocketChannel extends AbstractSelectableChannel implements
-		ByteChannel, ScatteringByteChannel, GatheringByteChannel {
+        ByteChannel, ScatteringByteChannel, GatheringByteChannel {
 
     static {
         Platform.getNetworkSystem().oneTimeInitialization(true);
     }
-    
-	/**
-	 * Constructor for this class.
-	 * 
-	 * @param selectorProvider
-	 *            A instance of SelectorProvider
-	 */
-	protected SocketChannel(SelectorProvider selectorProvider) {
-		super(selectorProvider);
-	}
-
-	/**
-	 * Create a open and not-connected socket channel.
-	 * <p>
-	 * This channel is got by <code>openSocketChannel</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 SocketChannel open() throws IOException {
-		return SelectorProvider.provider().openSocketChannel();
-	}
-
-	/**
-	 * Create a socket channel and connect it to a socket address.
-	 * <p>
-	 * This method perform just as <code>open</code> method following by the
-	 * <code>connect</code> method.
-	 * </p>
-	 * 
-	 * @param address
-	 *            The socket address to be connected.
-	 * @return The new opened channel.
-	 * @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 UnresolvedAddressException
-	 *             If the address is not resolved.
-	 * @throws UnsupportedAddressTypeException
-	 *             If the address type is not supported.
-	 * @throws SecurityException
-	 *             If there is a security manager, and the address is not
-	 *             permitted to access.
-	 * @throws IOException
-	 *             Some other IO error occurred.
-	 * 
-	 */
-	public static SocketChannel open(SocketAddress address) throws IOException {
-		SocketChannel socketChannel = open();
-		if (null != socketChannel) {
-			socketChannel.connect(address);
-		}
-		return socketChannel;
-	}
-
-	/**
-	 * Get the valid operations of this channel. Socket channels support
-	 * connect, read and write operation, so this method returns (
-	 * <code>SelectionKey.OP_CONNECT</code> |
-	 * <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_CONNECT | SelectionKey.OP_READ | SelectionKey.OP_WRITE);
-	}
-
-	/**
-	 * Return the related socket of this channel, which won't declare public
-	 * methods that not declared in <code>Socket</code>.
-	 * 
-	 * @return The related Socket instance.
-	 */
-	public abstract Socket 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();
-
-	/**
-	 * Answer whether this channel's socket is in connecting or not.
-	 * 
-	 * @return <code>true</code> for the connection is initiated but not
-	 *         finished; <code>false</code> otherwise.
-	 */
-	public abstract boolean isConnectionPending();
-
-	/**
-	 * Connect the socket to remote address.
-	 * <p>
-	 * If the channel is blocking, this method will suspend before connection
-	 * finished or an I/O exception. If the channel is non-blocking, this method
-	 * will return <code>true</code> if the connection is finished at once or
-	 * return <code>false</code> and the connection must wait
-	 * <code>finishConnect</code> to finished otherwise.
-	 * </p>
-	 * <p>
-	 * This method can be called at any moment, and can block other read and
-	 * write operations while connecting.
-	 * </p>
-	 * <p>
-	 * This method just execute the same security checks as the connect method
-	 * of the <code>Socket</code> class.
-	 * </p>
-	 * 
-	 * @param address
-	 *            The address to be connected.
-	 * @return <code>true</code> if connection is finished,<code>false</code>
-	 *         otherwise.
-	 * @throws AlreadyConnectedException
-	 *             If the channel is connected already.
-	 * @throws ConnectionPendingException
-	 *             A non-blocking connecting is doing on 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 UnresolvedAddressException
-	 *             If the address is not resolved.
-	 * @throws UnsupportedAddressTypeException
-	 *             If the address type is not supported.
-	 * @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 boolean connect(SocketAddress address) throws IOException;
-
-	/**
-	 * Complete the connection.
-	 * <p>
-	 * This method is used when the channel is connectable to finish the
-	 * connection, and the connectable status of a channel means the channel is
-	 * after initiating in non-blocking mode and calling its
-	 * <code>connect</code> method. It will throw related
-	 * <code>IOException</code> if the connection failed.
-	 * </p>
-	 * <p>
-	 * This method will return <code>true</code> if the connection is finished
-	 * already, and return <code>false</code> if the channel is non-blocking
-	 * and the connection is not finished yet.
-	 * </p>
-	 * <p>
-	 * If the channel is in blocking mode, this method will suspend, and return
-	 * <code>true</code> for connection finished or throw some exception
-	 * otherwise. The channel will be closed if the connection failed and this
-	 * method thrown some exception.
-	 * </p>
-	 * <p>
-	 * This method can be called at any moment, and can block other read and
-	 * write operations while connecting.
-	 * </p>
-	 * 
-	 * @return <code>true</code> if the connection is successfully finished,
-	 *         <code>false</code> otherwise.
-	 * @throws NoConnectionPendingException
-	 *             If the channel is not connected and the connection is not
-	 *             initiated.
-	 * @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 boolean finishConnect() 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>
-	 * 
-	 * @see java.nio.channels.ReadableByteChannel#read(java.nio.ByteBuffer)
-	 * @param target
-	 *            The byte buffer to receive the bytes.
-	 * @return The number of bytes actually read.
-	 * @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 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>targets[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>
-	 * 
-	 * @see java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[],
-	 *      int, int)
-	 * @param targets
-	 *            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.
-	 * @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 bytes from the channel into all the given buffers.
-	 * <p>
-	 * This method is equivalent to:
-	 * 
-	 * <pre>
-	 * read(targets, 0, targets.length);
-	 * </pre>
-	 * 
-	 * @see java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[])
-	 * @param targets
-	 *            the array of byte buffers to receive the bytes being read.
-	 * @return the number of bytes actually read.
-	 * @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);
-	}
-
-	/**
-	 * Writes bytes from the given buffer to the channel.
-	 * <p>
-	 * The maximum number of bytes that will be written is the
-	 * <code>remaining()</code> number of bytes in the buffer when the method
-	 * invoked. The bytes will be written from the buffer starting at the
-	 * buffer's <code>position</code>.
-	 * </p>
-	 * <p>
-	 * The call may block if other threads are also attempting to write on the
-	 * same channel.
-	 * </p>
-	 * <p>
-	 * Upon completion, the buffer's <code>position()</code> is updated to the
-	 * end of the bytes that were written. The buffer's <code>limit()</code>
-	 * is unmodified.
-	 * </p>
-	 * 
-	 * @see java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer)
-	 * @param source
-	 *            the byte buffer containing the bytes to be written.
-	 * @return the number of bytes actually 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;
-
-	/**
-	 * 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>sources[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>
-	 * 
-	 * @see java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[],
-	 *      int, int)
-	 * @param sources
-	 *            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 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;
-
-	/**
-	 * Writes bytes from all the given buffers to the channel.
-	 * <p>
-	 * This method is equivalent to:
-	 * 
-	 * <pre>
-	 * write(buffers, 0, buffers.length);
-	 * </pre>
-	 * 
-	 * </p>
-	 * 
-	 * @see java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[])
-	 * @param sources
-	 *            the buffers containing bytes to be written.
-	 * @return the number of bytes actually 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 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 SocketChannel(SelectorProvider selectorProvider) {
+        super(selectorProvider);
+    }
+
+    /**
+     * Create a open and not-connected socket channel.
+     * <p>
+     * This channel is got by <code>openSocketChannel</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 SocketChannel open() throws IOException {
+        return SelectorProvider.provider().openSocketChannel();
+    }
+
+    /**
+     * Create a socket channel and connect it to a socket address.
+     * <p>
+     * This method perform just as <code>open</code> method following by the
+     * <code>connect</code> method.
+     * </p>
+     * 
+     * @param address
+     *            The socket address to be connected.
+     * @return The new opened channel.
+     * @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 UnresolvedAddressException
+     *             If the address is not resolved.
+     * @throws UnsupportedAddressTypeException
+     *             If the address type is not supported.
+     * @throws SecurityException
+     *             If there is a security manager, and the address is not
+     *             permitted to access.
+     * @throws IOException
+     *             Some other IO error occurred.
+     * 
+     */
+    public static SocketChannel open(SocketAddress address) throws IOException {
+        SocketChannel socketChannel = open();
+        if (null != socketChannel) {
+            socketChannel.connect(address);
+        }
+        return socketChannel;
+    }
+
+    /**
+     * Get the valid operations of this channel. Socket channels support
+     * connect, read and write operation, so this method returns (
+     * <code>SelectionKey.OP_CONNECT</code> |
+     * <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_CONNECT | SelectionKey.OP_READ | SelectionKey.OP_WRITE);
+    }
+
+    /**
+     * Return the related socket of this channel, which won't declare public
+     * methods that not declared in <code>Socket</code>.
+     * 
+     * @return The related Socket instance.
+     */
+    public abstract Socket 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();
+
+    /**
+     * Answer whether this channel's socket is in connecting or not.
+     * 
+     * @return <code>true</code> for the connection is initiated but not
+     *         finished; <code>false</code> otherwise.
+     */
+    public abstract boolean isConnectionPending();
+
+    /**
+     * Connect the socket to remote address.
+     * <p>
+     * If the channel is blocking, this method will suspend before connection
+     * finished or an I/O exception. If the channel is non-blocking, this method
+     * will return <code>true</code> if the connection is finished at once or
+     * return <code>false</code> and the connection must wait
+     * <code>finishConnect</code> to finished otherwise.
+     * </p>
+     * <p>
+     * This method can be called at any moment, and can block other read and
+     * write operations while connecting.
+     * </p>
+     * <p>
+     * This method just execute the same security checks as the connect method
+     * of the <code>Socket</code> class.
+     * </p>
+     * 
+     * @param address
+     *            The address to be connected.
+     * @return <code>true</code> if connection is finished,<code>false</code>
+     *         otherwise.
+     * @throws AlreadyConnectedException
+     *             If the channel is connected already.
+     * @throws ConnectionPendingException
+     *             A non-blocking connecting is doing on 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 UnresolvedAddressException
+     *             If the address is not resolved.
+     * @throws UnsupportedAddressTypeException
+     *             If the address type is not supported.
+     * @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 boolean connect(SocketAddress address) throws IOException;
+
+    /**
+     * Complete the connection.
+     * <p>
+     * This method is used when the channel is connectable to finish the
+     * connection, and the connectable status of a channel means the channel is
+     * after initiating in non-blocking mode and calling its
+     * <code>connect</code> method. It will throw related
+     * <code>IOException</code> if the connection failed.
+     * </p>
+     * <p>
+     * This method will return <code>true</code> if the connection is finished
+     * already, and return <code>false</code> if the channel is non-blocking
+     * and the connection is not finished yet.
+     * </p>
+     * <p>
+     * If the channel is in blocking mode, this method will suspend, and return
+     * <code>true</code> for connection finished or throw some exception
+     * otherwise. The channel will be closed if the connection failed and this
+     * method thrown some exception.
+     * </p>
+     * <p>
+     * This method can be called at any moment, and can block other read and
+     * write operations while connecting.
+     * </p>
+     * 
+     * @return <code>true</code> if the connection is successfully finished,
+     *         <code>false</code> otherwise.
+     * @throws NoConnectionPendingException
+     *             If the channel is not connected and the connection is not
+     *             initiated.
+     * @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 boolean finishConnect() 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>
+     * 
+     * @see java.nio.channels.ReadableByteChannel#read(java.nio.ByteBuffer)
+     * @param target
+     *            The byte buffer to receive the bytes.
+     * @return The number of bytes actually read.
+     * @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 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>targets[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>
+     * 
+     * @see java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[],
+     *      int, int)
+     * @param targets
+     *            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.
+     * @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 bytes from the channel into all the given buffers.
+     * <p>
+     * This method is equivalent to:
+     * 
+     * <pre>
+     * read(targets, 0, targets.length);
+     * </pre>
+     * 
+     * @see java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[])
+     * @param targets
+     *            the array of byte buffers to receive the bytes being read.
+     * @return the number of bytes actually read.
+     * @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);
+    }
+
+    /**
+     * Writes bytes from the given buffer to the channel.
+     * <p>
+     * The maximum number of bytes that will be written is the
+     * <code>remaining()</code> number of bytes in the buffer when the method
+     * invoked. The bytes will be written from the buffer starting at the
+     * buffer's <code>position</code>.
+     * </p>
+     * <p>
+     * The call may block if other threads are also attempting to write on the
+     * same channel.
+     * </p>
+     * <p>
+     * Upon completion, the buffer's <code>position()</code> is updated to the
+     * end of the bytes that were written. The buffer's <code>limit()</code>
+     * is unmodified.
+     * </p>
+     * 
+     * @see java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer)
+     * @param source
+     *            the byte buffer containing the bytes to be written.
+     * @return the number of bytes actually 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;
+
+    /**
+     * 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>sources[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>
+     * 
+     * @see java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[],
+     *      int, int)
+     * @param sources
+     *            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 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;
+
+    /**
+     * Writes bytes from all the given buffers to the channel.
+     * <p>
+     * This method is equivalent to:
+     * 
+     * <pre>
+     * write(buffers, 0, buffers.length);
+     * </pre>
+     * 
+     * </p>
+     * 
+     * @see java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[])
+     * @param sources
+     *            the buffers containing bytes to be written.
+     * @return the number of bytes actually 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 synchronized final long write(ByteBuffer[] sources)
+            throws IOException {
+        return write(sources, 0, sources.length);
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/UnresolvedAddressException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/UnresolvedAddressException.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/UnresolvedAddressException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/UnresolvedAddressException.java Tue Oct 23 06:54:37 2007
@@ -16,21 +16,18 @@
 
 package java.nio.channels;
 
-
 /**
  * Thrown when trying to use an unresolved network address in a network
  * operation.
- * 
  */
 public class UnresolvedAddressException extends IllegalArgumentException {
 
-	private static final long serialVersionUID = 6136959093620794148L;
+    private static final long serialVersionUID = 6136959093620794148L;
 
-	/**
-	 * Default constructor.
-	 * 
-	 */
-	public UnresolvedAddressException() {
-		super();
-	}
+    /**
+     * Default constructor.
+     */
+    public UnresolvedAddressException() {
+        super();
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/UnsupportedAddressTypeException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/UnsupportedAddressTypeException.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/UnsupportedAddressTypeException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/UnsupportedAddressTypeException.java Tue Oct 23 06:54:37 2007
@@ -16,20 +16,17 @@
 
 package java.nio.channels;
 
-
 /**
  * Thrown when connecting or binding to an unsupported address type.
- * 
  */
 public class UnsupportedAddressTypeException extends IllegalArgumentException {
 
-	private static final long serialVersionUID = -2964323842829700493L;
+    private static final long serialVersionUID = -2964323842829700493L;
 
-	/**
-	 * Default constructor.
-	 * 
-	 */
-	public UnsupportedAddressTypeException() {
-		super();
-	}
+    /**
+     * Default constructor.
+     */
+    public UnsupportedAddressTypeException() {
+        super();
+    }
 }

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

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelectionKey.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelectionKey.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelectionKey.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelectionKey.java Tue Oct 23 06:54:37 2007
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- 
+
 package java.nio.channels.spi;
 
 import java.nio.channels.SelectionKey;
@@ -23,38 +23,37 @@
  * <p>
  * The class takes charge of the validation and cancellation of key.
  * </p>
- * 
  */
 public abstract class AbstractSelectionKey extends SelectionKey {
 
     /*
-     * package private for deregister method in AbstractSelector.
+     * Package private for deregister method in AbstractSelector.
+     */
+    boolean isValid = true;
+
+    /**
+     * Constructor for this class.
      */
-	boolean isValid = true;
+    protected AbstractSelectionKey() {
+        super();
+    }
 
-	/**
-	 * Constructor for this class.
-	 */
-	protected AbstractSelectionKey() {
-		super();
-	}
-
-	/**
-	 * @see java.nio.channels.SelectionKey#isValid()
-	 */
-	public final boolean isValid() {
-		return isValid;
-	}
-
-	/**
-	 * Cancels this key and adds it to the cancelled key set.
-	 * 
-	 * @see java.nio.channels.SelectionKey#cancel()
-	 */
-	public final void cancel() {
-		if (isValid) {
-			isValid = false;
-			((AbstractSelector) selector()).cancel(this);
-		}
-	}
+    /**
+     * @see java.nio.channels.SelectionKey#isValid()
+     */
+    public final boolean isValid() {
+        return isValid;
+    }
+
+    /**
+     * Cancels this key and adds it to the cancelled key set.
+     * 
+     * @see java.nio.channels.SelectionKey#cancel()
+     */
+    public final void cancel() {
+        if (isValid) {
+            isValid = false;
+            ((AbstractSelector) selector()).cancel(this);
+        }
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/AddressUtil.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/AddressUtil.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/AddressUtil.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/AddressUtil.java Tue Oct 23 06:54:37 2007
@@ -27,50 +27,50 @@
 public class AddressUtil {
 
     /**
-	 * Gets the start address of a direct buffer.
-	 * <p>
-	 * This method corresponds to the JNI function:
-	 * 
-	 * <pre>
-	 *    void* GetDirectBufferAddress(JNIEnv* env, jobject buf);
-	 * </pre>
-	 * 
-	 * @param buf
-	 *            the direct buffer whose address shall be returned must not be
-	 *            <code>null</code>.
-	 * @return the address of the buffer given, or zero if the buffer is not a
-	 *         direct Buffer.
-	 */
-	public static long getDirectBufferAddress(Buffer buf) {
-		if (!(buf instanceof DirectBuffer)) {
-			return 0;
-		}
-		return ((DirectBuffer) buf).getEffectiveAddress().toLong();
-	}
-    
+     * Gets the start address of a direct buffer.
+     * <p>
+     * This method corresponds to the JNI function:
+     * 
+     * <pre>
+     *    void* GetDirectBufferAddress(JNIEnv* env, jobject buf);
+     * </pre>
+     * 
+     * @param buf
+     *            the direct buffer whose address shall be returned must not be
+     *            <code>null</code>.
+     * @return the address of the buffer given, or zero if the buffer is not a
+     *         direct Buffer.
+     */
+    public static long getDirectBufferAddress(Buffer buf) {
+        if (!(buf instanceof DirectBuffer)) {
+            return 0;
+        }
+        return ((DirectBuffer) buf).getEffectiveAddress().toLong();
+    }
+
     /**
-	 * Gets the address of native resource held by the given channel, if has
-	 * any.
-	 * 
-	 * For network related channel, including SocketChannel, ServerSocketChannel
-	 * and DatagramChannel, this method returns a int of Socket handler in Linux
-	 * while returns a SOCKET (UINT_PTR) in windows.
-	 * 
-	 * For FileChannel, this method returns the native file descriptor.
-	 * 
-	 * For other channels, this method return 0, which means unsupported
-	 * operation.
-	 * 
-	 * @param channel
-	 *            the given channel which may holds a native resource address
-	 * @return the address of native resource held by the given channel, if any,
-	 *         otherwise return 0
-	 */
-    public static long getChannelAddress(Channel channel){
-        if(channel instanceof FileDescriptorHandler){
-            return getFDAddress(((FileDescriptorHandler) channel).getFD());    
-        }else if(channel instanceof FileChannelImpl){
-            return ((FileChannelImpl) channel).getHandle();    
+     * Gets the address of native resource held by the given channel, if has
+     * any.
+     * 
+     * For network related channel, including SocketChannel, ServerSocketChannel
+     * and DatagramChannel, this method returns a int of Socket handler in Linux
+     * while returns a SOCKET (UINT_PTR) in windows.
+     * 
+     * For FileChannel, this method returns the native file descriptor.
+     * 
+     * For other channels, this method return 0, which means unsupported
+     * operation.
+     * 
+     * @param channel
+     *            the given channel which may holds a native resource address
+     * @return the address of native resource held by the given channel, if any,
+     *         otherwise return 0
+     */
+    public static long getChannelAddress(Channel channel) {
+        if (channel instanceof FileDescriptorHandler) {
+            return getFDAddress(((FileDescriptorHandler) channel).getFD());
+        } else if (channel instanceof FileChannelImpl) {
+            return ((FileChannelImpl) channel).getHandle();
         }
         return 0;
     }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/FileChannelFactory.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/FileChannelFactory.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/FileChannelFactory.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/FileChannelFactory.java Tue Oct 23 06:54:37 2007
@@ -16,7 +16,6 @@
 
 package org.apache.harmony.nio;
 
-
 import java.nio.channels.FileChannel;
 
 import org.apache.harmony.nio.internal.ReadOnlyFileChannel;
@@ -30,21 +29,21 @@
  * implementation from within the java.io package.
  */
 public class FileChannelFactory {
-	public static FileChannel getFileChannel(Object stream, long fd, int mode) {
-        switch(mode){
-        case IFileSystem.O_RDONLY:
-            return new ReadOnlyFileChannel(stream, fd);
-        case IFileSystem.O_WRONLY:
-            return new WriteOnlyFileChannel(stream, fd);
-        case IFileSystem.O_RDWR:
-            return new ReadWriteFileChannel(stream, fd);
-        case IFileSystem.O_RDWRSYNC:
-            return new ReadWriteFileChannel(stream, fd);
-        case IFileSystem.O_APPEND:
-            return new WriteOnlyFileChannel(stream, fd, true);
-        default:
-            // nio.09=Unknown file channel type: {0}
-            throw new RuntimeException(Messages.getString("nio.09", mode));  //$NON-NLS-1$
+    public static FileChannel getFileChannel(Object stream, long fd, int mode) {
+        switch (mode) {
+            case IFileSystem.O_RDONLY:
+                return new ReadOnlyFileChannel(stream, fd);
+            case IFileSystem.O_WRONLY:
+                return new WriteOnlyFileChannel(stream, fd);
+            case IFileSystem.O_RDWR:
+                return new ReadWriteFileChannel(stream, fd);
+            case IFileSystem.O_RDWRSYNC:
+                return new ReadWriteFileChannel(stream, fd);
+            case IFileSystem.O_APPEND:
+                return new WriteOnlyFileChannel(stream, fd, true);
+            default:
+                // nio.09=Unknown file channel type: {0}
+                throw new RuntimeException(Messages.getString("nio.09", mode)); //$NON-NLS-1$
         }
-	}
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileLockImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileLockImpl.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileLockImpl.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileLockImpl.java Tue Oct 23 06:54:37 2007
@@ -16,7 +16,6 @@
 
 package org.apache.harmony.nio.internal;
 
-
 import java.io.IOException;
 import java.nio.channels.ClosedChannelException;
 import java.nio.channels.FileChannel;
@@ -24,43 +23,42 @@
 
 /*
  * The concrete implementation of an NIO file lock object.
- * 
  */
 final class FileLockImpl extends FileLock {
 
-	// Remembers if this lock has been released via the API.
-	private boolean isReleased = false;
-
-	/*
-	 * Answers a new file lock object with the given parameters.
-	 * 
-	 * @param channel the file channel hosting the lock. @param position the
-	 * start position of the lock, in bytes @param size the length of the lock,
-	 * in bytes @param shared whether this lock is shared (true) or exclusive
-	 * (false)
-	 */
-	public FileLockImpl(FileChannel channel, long position, long size,
-			boolean shared) {
-		super(channel, position, size, shared);
-	}
-
-	/*
-	 * Tests to see if the lock is valid. A lock can be invalidated if the
-	 * channel it is acquired on is closed or if it is released. (non-Javadoc)
-	 * 
-	 * @see java.nio.channels.FileLock#isValid()
-	 */
-	public boolean isValid() {
-		return !isReleased && channel().isOpen();
-	}
+    // Remembers if this lock has been released via the API.
+    private boolean isReleased = false;
 
-	/*
-	 * Releases the file lock on the channel that acquired it. Releasing an
-	 * invalid lock has no effect.
-	 * 
-	 * @see java.nio.channels.FileLock#release()
-	 */
-	public void release() throws IOException {
+    /*
+     * Answers a new file lock object with the given parameters.
+     * 
+     * @param channel the file channel hosting the lock. @param position the
+     * start position of the lock, in bytes @param size the length of the lock,
+     * in bytes @param shared whether this lock is shared (true) or exclusive
+     * (false)
+     */
+    public FileLockImpl(FileChannel channel, long position, long size,
+            boolean shared) {
+        super(channel, position, size, shared);
+    }
+
+    /*
+     * Tests to see if the lock is valid. A lock can be invalidated if the
+     * channel it is acquired on is closed or if it is released. (non-Javadoc)
+     * 
+     * @see java.nio.channels.FileLock#isValid()
+     */
+    public boolean isValid() {
+        return !isReleased && channel().isOpen();
+    }
+
+    /*
+     * Releases the file lock on the channel that acquired it. Releasing an
+     * invalid lock has no effect.
+     * 
+     * @see java.nio.channels.FileLock#release()
+     */
+    public void release() throws IOException {
         if (!channel().isOpen()) {
             throw new ClosedChannelException();
         }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/IOUtil.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/IOUtil.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/IOUtil.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/IOUtil.java Tue Oct 23 06:54:37 2007
@@ -29,210 +29,196 @@
 import org.apache.harmony.nio.Util;
 import org.apache.harmony.nio.internal.nls.Messages;
 
-
 /*
  * Static methods for I/O util. Used by io package and nio package.
- * 
  */
 public final class IOUtil {
 
-	// -------------------------------------------------------------------
-	// Class variables
-	// -------------------------------------------------------------------
-
-	private static final int DEFAULT_BUFFER_SIZE = 8192;
-
-	// -------------------------------------------------------------------
-	// Constructor
-	// -------------------------------------------------------------------
-
-	/*
-	 * No instance.
-	 */
-	private IOUtil() {
-		super();
-	}
-
-	// -------------------------------------------------------------------
-	// Routine methods.
-	// -------------------------------------------------------------------
-
-	/*
-	 * Read method for InputStreamReader and Channels.
-	 */
-	public static int readInputStreamReader(InputStream in, ByteBuffer bytes,
-			CharBuffer chars, CharsetDecoder decoder, Object lock)
-			throws IOException {
-		synchronized (lock) {
-			if (in != null) {
-				if (chars.limit() == chars.position()) {
-					fillBuf(in, bytes, chars, decoder);
-				}
-				if (chars.limit() == 0) {
-					return -1;
-				}
-				return chars.get();
-			}
+    private static final int DEFAULT_BUFFER_SIZE = 8192;
+
+    /*
+     * Not designed to be instantiated.
+     */
+    private IOUtil() {
+        super();
+    }
+
+    /*
+     * Read method for InputStreamReader and Channels.
+     */
+    public static int readInputStreamReader(InputStream in, ByteBuffer bytes,
+            CharBuffer chars, CharsetDecoder decoder, Object lock)
+            throws IOException {
+        synchronized (lock) {
+            if (in != null) {
+                if (chars.limit() == chars.position()) {
+                    fillBuf(in, bytes, chars, decoder);
+                }
+                if (chars.limit() == 0) {
+                    return -1;
+                }
+                return chars.get();
+            }
             // nio.06=InputStreamReader is closed.
-			throw new IOException(Messages.getString("nio.06")); //$NON-NLS-1$
-		}
-	}
-
-	/*
-	 * Read method for InputStreamReader and Channels.
-	 */
-	public static int readInputStreamReader(char[] buf, int offset, int length,
-			InputStream in, ByteBuffer bytes, CharBuffer chars,
-			CharsetDecoder decoder, Object lock) throws IOException {
-		synchronized (lock) {
-			if (in != null) {
-				if (length == 0) {
-					return 0;
-				}
-				Util.assertArrayIndex(buf, offset, length);
-				// read at least once
-				if (chars.limit() == chars.position()) {
-					fillBuf(in, bytes, chars, decoder);
-				}
-				int position = chars.position();
-				int availableChars = chars.limit() - position;
-				// read at least once for one byte
-				int needChars = length;
-				while (availableChars < needChars) {
-					System.arraycopy(chars.array(), position, buf, offset,
-							availableChars);
-					chars.position(position + availableChars);
-					needChars -= availableChars;
-					offset += availableChars;
-					if (in.available() <= 0) {
-						return needChars == length ? -1 : length - needChars;
-					}
-					fillBuf(in, bytes, chars, decoder);
-					position = chars.position();
-					availableChars = chars.limit();
-					if (availableChars == 0) {
-						return needChars == length ? -1 : length - needChars;
-					}
-				}
-				System.arraycopy(chars.array(), position, buf, offset,
-						needChars);
-				chars.position(chars.position() + needChars);
-				return length;
-			}
+            throw new IOException(Messages.getString("nio.06")); //$NON-NLS-1$
+        }
+    }
+
+    /*
+     * Read method for InputStreamReader and Channels.
+     */
+    public static int readInputStreamReader(char[] buf, int offset, int length,
+            InputStream in, ByteBuffer bytes, CharBuffer chars,
+            CharsetDecoder decoder, Object lock) throws IOException {
+        synchronized (lock) {
+            if (in != null) {
+                if (length == 0) {
+                    return 0;
+                }
+                Util.assertArrayIndex(buf, offset, length);
+                // read at least once
+                if (chars.limit() == chars.position()) {
+                    fillBuf(in, bytes, chars, decoder);
+                }
+                int position = chars.position();
+                int availableChars = chars.limit() - position;
+                // read at least once for one byte
+                int needChars = length;
+                while (availableChars < needChars) {
+                    System.arraycopy(chars.array(), position, buf, offset,
+                            availableChars);
+                    chars.position(position + availableChars);
+                    needChars -= availableChars;
+                    offset += availableChars;
+                    if (in.available() <= 0) {
+                        return needChars == length ? -1 : length - needChars;
+                    }
+                    fillBuf(in, bytes, chars, decoder);
+                    position = chars.position();
+                    availableChars = chars.limit();
+                    if (availableChars == 0) {
+                        return needChars == length ? -1 : length - needChars;
+                    }
+                }
+                System.arraycopy(chars.array(), position, buf, offset,
+                        needChars);
+                chars.position(chars.position() + needChars);
+                return length;
+            }
             // nio.06=InputStreamReader is closed.
             throw new IOException(Messages.getString("nio.06")); //$NON-NLS-1$
-		}
-	}
+        }
+    }
+
+    /*
+     * Refill the buffer from wrapped InputStream.
+     */
+    private static void fillBuf(InputStream in, ByteBuffer bytes,
+            CharBuffer chars, CharsetDecoder decoder) throws IOException {
+        chars.clear();
+        int read = 0;
+        try {
+            read = in.read(bytes.array());
+        } catch (IOException e) {
+            chars.limit(0);
+            throw e;
+        }
+        if (read == -1) {
+            chars.limit(0);
+            return;
+        }
+        bytes.limit(read);
+        boolean endOfInput = read < DEFAULT_BUFFER_SIZE;
+        CoderResult result = decoder.decode(bytes, chars, endOfInput);
+        if (result.isError()) {
+            throw new IOException(result.toString());
+        }
+        bytes.clear();
+        chars.flip();
+    }
 
-	/*
-	 * refill the buffer from wrapped InputStream
-	 */
-	private static void fillBuf(InputStream in, ByteBuffer bytes,
-			CharBuffer chars, CharsetDecoder decoder) throws IOException {
-		chars.clear();
-		int read = 0;
-		try {
-			read = in.read(bytes.array());
-		} catch (IOException e) {
-			chars.limit(0);
-			throw e;
-		}
-		if (read == -1) {
-			chars.limit(0);
-			return;
-		}
-		bytes.limit(read);
-		boolean endOfInput = read < DEFAULT_BUFFER_SIZE;
-		CoderResult result = decoder.decode(bytes, chars, endOfInput);
-		if (result.isError()) {
-			throw new IOException(result.toString());
-		}
-		bytes.clear();
-		chars.flip();
-	}
-
-	/*
-	 * Write method for OutputStreamWriter and Channels.
-	 */
-	public static void writeOutputStreamWriter(String str, int offset,
-			int count, OutputStream out, ByteBuffer bytes,
-			CharsetEncoder encoder, Object lock) throws IOException {
-		Util.assertArrayIndex(str.length(), offset, count);
-		CharBuffer chars = CharBuffer.wrap(str, offset, count + offset);
-		convert(lock, encoder, bytes, chars, out);
-	}
-
-	/*
-	 * Write method for OutputStreamWriter and Channels.
-	 */
-	public static void writeOutputStreamWriter(int oneChar, OutputStream out,
-			ByteBuffer bytes, CharsetEncoder encoder, Object lock)
-			throws IOException {
-		synchronized (lock) {
-			if (encoder == null) {
+    /*
+     * Write method for OutputStreamWriter and Channels.
+     */
+    public static void writeOutputStreamWriter(String str, int offset,
+            int count, OutputStream out, ByteBuffer bytes,
+            CharsetEncoder encoder, Object lock) throws IOException {
+        Util.assertArrayIndex(str.length(), offset, count);
+        CharBuffer chars = CharBuffer.wrap(str, offset, count + offset);
+        convert(lock, encoder, bytes, chars, out);
+    }
+
+    /*
+     * Write method for OutputStreamWriter and Channels.
+     */
+    public static void writeOutputStreamWriter(int oneChar, OutputStream out,
+            ByteBuffer bytes, CharsetEncoder encoder, Object lock)
+            throws IOException {
+        synchronized (lock) {
+            if (encoder == null) {
                 // nio.07=Writer is closed.
                 throw new IOException(Messages.getString("nio.07")); //$NON-NLS-1$
-			}
-			CharBuffer chars = CharBuffer.wrap(new char[] { (char) oneChar });
-			convert(lock, encoder, bytes, chars, out);
-		}
-	}
-
-	/*
-	 * Write method for OutputStreamWriter and Channels.
-	 */
-	public static void writeOutputStreamWriter(char[] buf, int offset,
-			int count, OutputStream out, ByteBuffer bytes,
-			CharsetEncoder encoder, Object lock) throws IOException {
-		Util.assertArrayIndex(buf, offset, count);
-		CharBuffer chars = CharBuffer.wrap(buf, offset, count);
-		convert(lock, encoder, bytes, chars, out);
-	}
-
-	/*
-	 * Flush method for OutputStreamWriter and Channels.
-	 */
-	public static void flushOutputStreamWriter(OutputStream out,
-			ByteBuffer bytes, CharsetEncoder encoder, Object lock)
-			throws IOException {
-		synchronized (lock) {
-			if (encoder == null) {
+            }
+            CharBuffer chars = CharBuffer.wrap(new char[] { (char) oneChar });
+            convert(lock, encoder, bytes, chars, out);
+        }
+    }
+
+    /*
+     * Write method for OutputStreamWriter and Channels.
+     */
+    public static void writeOutputStreamWriter(char[] buf, int offset,
+            int count, OutputStream out, ByteBuffer bytes,
+            CharsetEncoder encoder, Object lock) throws IOException {
+        Util.assertArrayIndex(buf, offset, count);
+        CharBuffer chars = CharBuffer.wrap(buf, offset, count);
+        convert(lock, encoder, bytes, chars, out);
+    }
+
+    /*
+     * Flush method for OutputStreamWriter and Channels.
+     */
+    public static void flushOutputStreamWriter(OutputStream out,
+            ByteBuffer bytes, CharsetEncoder encoder, Object lock)
+            throws IOException {
+        synchronized (lock) {
+            if (encoder == null) {
                 // nio.07=Writer is closed.
                 throw new IOException(Messages.getString("nio.07")); //$NON-NLS-1$
-			}
-			int position;
-			if ((position = bytes.position()) > 0) {
-				bytes.flip();
-				out.write(bytes.array(), 0, position);
-				bytes.clear();
-			}
-			out.flush();
-		}
-	}
-
-    /*
-	 * convert function used in write.
-	 */
-	private static void convert(Object lock, CharsetEncoder encoder,
-			ByteBuffer bytes, CharBuffer chars, OutputStream out)
-			throws IOException {
-		synchronized (lock) {
-			if (encoder == null) {
+            }
+            int position;
+            if ((position = bytes.position()) > 0) {
+                bytes.flip();
+                out.write(bytes.array(), 0, position);
+                bytes.clear();
+            }
+            out.flush();
+        }
+    }
+
+    /*
+     * Convert function used in write.
+     */
+    private static void convert(Object lock, CharsetEncoder encoder,
+            ByteBuffer bytes, CharBuffer chars, OutputStream out)
+            throws IOException {
+        synchronized (lock) {
+            if (encoder == null) {
                 // nio.07=Writer is closed.
                 throw new IOException(Messages.getString("nio.07")); //$NON-NLS-1$
-			}
-			CoderResult result = encoder.encode(chars, bytes, true);
-			while (true) {
-				if (result.isError()) {
-					throw new IOException(result.toString());
-				} else if (result.isOverflow()) {
-					// flush the output buffer
-					flushOutputStreamWriter(out, bytes, encoder, lock);
-					result = encoder.encode(chars, bytes, true);
-					continue;
-				}
-				break;
-			}
-		}
-	}
+            }
+            CoderResult result = encoder.encode(chars, bytes, true);
+            while (true) {
+                if (result.isError()) {
+                    throw new IOException(result.toString());
+                } else if (result.isOverflow()) {
+                    // flush the output buffer
+                    flushOutputStreamWriter(out, bytes, encoder, lock);
+                    result = encoder.encode(chars, bytes, true);
+                    continue;
+                }
+                break;
+            }
+        }
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ReadOnlyFileChannel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ReadOnlyFileChannel.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ReadOnlyFileChannel.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ReadOnlyFileChannel.java Tue Oct 23 06:54:37 2007
@@ -29,41 +29,41 @@
 import org.apache.harmony.luni.platform.IMemorySystem;
 
 public final class ReadOnlyFileChannel extends FileChannelImpl {
-	public ReadOnlyFileChannel(Object stream, long handle) {
-		super(stream, handle);
-	}
+    public ReadOnlyFileChannel(Object stream, long handle) {
+        super(stream, handle);
+    }
 
-	public final int write(ByteBuffer buffer, long position) throws IOException {
-        if (null == buffer){
+    public final int write(ByteBuffer buffer, long position) throws IOException {
+        if (null == buffer) {
             throw new NullPointerException();
         }
-        if (position < 0){
+        if (position < 0) {
             throw new IllegalArgumentException();
         }
-		throw new NonWritableChannelException();
-	}
+        throw new NonWritableChannelException();
+    }
 
-	public final int write(ByteBuffer buffer) throws IOException {
-		openCheck();
-		throw new NonWritableChannelException();
-	}
+    public final int write(ByteBuffer buffer) throws IOException {
+        openCheck();
+        throw new NonWritableChannelException();
+    }
 
-	public final long write(ByteBuffer[] buffers, int offset, int length)
-			throws IOException {
+    public final long write(ByteBuffer[] buffers, int offset, int length)
+            throws IOException {
         if (offset < 0 || length < 0 || (offset + length) > buffers.length) {
             throw new IndexOutOfBoundsException();
         }
-		openCheck();
-		throw new NonWritableChannelException();
-	}
+        openCheck();
+        throw new NonWritableChannelException();
+    }
 
-	public final FileChannel truncate(long size) throws IOException {
-		openCheck();
+    public final FileChannel truncate(long size) throws IOException {
+        openCheck();
         if (size < 0) {
             throw new IllegalArgumentException();
         }
-		throw new NonWritableChannelException();
-	}
+        throw new NonWritableChannelException();
+    }
 
     public final long transferFrom(ReadableByteChannel src, long position,
             long count) throws IOException {
@@ -74,31 +74,31 @@
         throw new NonWritableChannelException();
     }
 
-	public final MappedByteBuffer map(MapMode mode, long position, long size)
-			throws IOException {
-		openCheck();
-		if (mode == null) {
-			throw new NullPointerException();
-		}
-		if (position < 0 || size < 0 || size > Integer.MAX_VALUE) {
-			throw new IllegalArgumentException();
-		}
-		if (mode != MapMode.READ_ONLY) {
-			throw new NonWritableChannelException();
-		}
-		return super.mapImpl(IMemorySystem.MMAP_READ_ONLY, position, size);
-	}
-
-	public final void force(boolean metadata) throws IOException {
-		openCheck();
-		return;
-	}
-
-	protected final FileLock basicLock(long position, long size,
-			boolean shared, boolean wait) throws IOException {
-		if (!shared) {
-			throw new NonWritableChannelException();
-		}
-		return super.basicLock(position, size, shared, true);
-	}
+    public final MappedByteBuffer map(MapMode mode, long position, long size)
+            throws IOException {
+        openCheck();
+        if (mode == null) {
+            throw new NullPointerException();
+        }
+        if (position < 0 || size < 0 || size > Integer.MAX_VALUE) {
+            throw new IllegalArgumentException();
+        }
+        if (mode != MapMode.READ_ONLY) {
+            throw new NonWritableChannelException();
+        }
+        return super.mapImpl(IMemorySystem.MMAP_READ_ONLY, position, size);
+    }
+
+    public final void force(boolean metadata) throws IOException {
+        openCheck();
+        return;
+    }
+
+    protected final FileLock basicLock(long position, long size,
+            boolean shared, boolean wait) throws IOException {
+        if (!shared) {
+            throw new NonWritableChannelException();
+        }
+        return super.basicLock(position, size, shared, true);
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ReadWriteFileChannel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ReadWriteFileChannel.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ReadWriteFileChannel.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ReadWriteFileChannel.java Tue Oct 23 06:54:37 2007
@@ -23,27 +23,27 @@
 import org.apache.harmony.luni.platform.IMemorySystem;
 
 public final class ReadWriteFileChannel extends FileChannelImpl {
-	public ReadWriteFileChannel(Object stream, long handle) {
-		super(stream, handle);
-	}
+    public ReadWriteFileChannel(Object stream, long handle) {
+        super(stream, handle);
+    }
 
-	public final MappedByteBuffer map(MapMode mode, long position, long size)
-			throws IOException {
-		openCheck();
-		if (mode == null) {
-			throw new NullPointerException();
-		}
-		if (position < 0 || size < 0 || size > Integer.MAX_VALUE) {
-			throw new IllegalArgumentException();
-		}
-		int mapMode;
-		if (mode == MapMode.READ_ONLY) {
-			mapMode = IMemorySystem.MMAP_READ_ONLY;
-		} else if (mode == MapMode.READ_WRITE) {
-			mapMode = IMemorySystem.MMAP_READ_WRITE;
-		} else {
-			mapMode = IMemorySystem.MMAP_WRITE_COPY;
-		}
-		return mapImpl(mapMode, position, size);
-	}
+    public final MappedByteBuffer map(MapMode mode, long position, long size)
+            throws IOException {
+        openCheck();
+        if (mode == null) {
+            throw new NullPointerException();
+        }
+        if (position < 0 || size < 0 || size > Integer.MAX_VALUE) {
+            throw new IllegalArgumentException();
+        }
+        int mapMode;
+        if (mode == MapMode.READ_ONLY) {
+            mapMode = IMemorySystem.MMAP_READ_ONLY;
+        } else if (mode == MapMode.READ_WRITE) {
+            mapMode = IMemorySystem.MMAP_READ_WRITE;
+        } else {
+            mapMode = IMemorySystem.MMAP_WRITE_COPY;
+        }
+        return mapImpl(mapMode, position, size);
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorProviderImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorProviderImpl.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorProviderImpl.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorProviderImpl.java Tue Oct 23 06:54:37 2007
@@ -25,58 +25,50 @@
 import java.nio.channels.spi.AbstractSelector;
 import java.nio.channels.spi.SelectorProvider;
 
-
 /*
  * Internal implementation of SelectorProvider.
- * 
  */
 public class SelectorProviderImpl extends SelectorProvider {
 
-	/*
-	 * Constructor for this class.
-	 */
-	public SelectorProviderImpl() {
-		super();
-	}
-
-	/*
-	 * 
-	 * @see java.nio.channels.spi.SelectorProvider#openDatagramChannel()
-	 */
-	public DatagramChannel openDatagramChannel() throws IOException {
-		return new DatagramChannelImpl(this);
-	}
-
-	/*
-	 * 
-	 * @see java.nio.channels.spi.SelectorProvider#openPipe()
-	 */
-	public Pipe openPipe() throws IOException {
-	    return new PipeImpl();
-	}
-
-	/*
-	 * 
-	 * @see java.nio.channels.spi.SelectorProvider#openSelector()
-	 */
-	public AbstractSelector openSelector() throws IOException {
+    /*
+     * Constructor for this class.
+     */
+    public SelectorProviderImpl() {
+        super();
+    }
+
+    /**
+     * @see java.nio.channels.spi.SelectorProvider#openDatagramChannel()
+     */
+    public DatagramChannel openDatagramChannel() throws IOException {
+        return new DatagramChannelImpl(this);
+    }
+
+    /**
+     * @see java.nio.channels.spi.SelectorProvider#openPipe()
+     */
+    public Pipe openPipe() throws IOException {
+        return new PipeImpl();
+    }
+
+    /**
+     * @see java.nio.channels.spi.SelectorProvider#openSelector()
+     */
+    public AbstractSelector openSelector() throws IOException {
         return new SelectorImpl(this);
     }
 
-	/*
-	 * 
-	 * @see java.nio.channels.spi.SelectorProvider#openServerSocketChannel()
-	 */
-	public ServerSocketChannel openServerSocketChannel() throws IOException {
-		return new ServerSocketChannelImpl(this);
-	}
-
-	/*
-	 * 
-	 * @see java.nio.channels.spi.SelectorProvider#openSocketChannel()
-	 */
-	public SocketChannel openSocketChannel() throws IOException {
-		return new SocketChannelImpl(this);
-	}
+    /**
+     * @see java.nio.channels.spi.SelectorProvider#openServerSocketChannel()
+     */
+    public ServerSocketChannel openServerSocketChannel() throws IOException {
+        return new ServerSocketChannelImpl(this);
+    }
 
+    /**
+     * @see java.nio.channels.spi.SelectorProvider#openSocketChannel()
+     */
+    public SocketChannel openSocketChannel() throws IOException {
+        return new SocketChannelImpl(this);
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/WriteOnlyFileChannel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/WriteOnlyFileChannel.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/WriteOnlyFileChannel.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/WriteOnlyFileChannel.java Tue Oct 23 06:54:37 2007
@@ -27,83 +27,83 @@
 
 public final class WriteOnlyFileChannel extends FileChannelImpl {
 
-	private boolean append = false;
+    private boolean append = false;
+
+    public WriteOnlyFileChannel(Object stream, long handle) {
+        super(stream, handle);
+    }
+
+    public WriteOnlyFileChannel(Object stream, long handle, boolean isAppend) {
+        super(stream, handle);
+        append = isAppend;
+    }
 
-	public WriteOnlyFileChannel(Object stream, long handle) {
-		super(stream, handle);
-	}
-
-	public WriteOnlyFileChannel(Object stream, long handle, boolean isAppend) {
-		super(stream, handle);
-		append = isAppend;
-	}
-    
     /*
      * (non-Javadoc)
+     * 
      * @see org.apache.harmony.nio.internal.FileChannelImpl#position()
      */
     public long position() throws IOException {
         return append ? size() : super.position();
     }
 
-	public long transferTo(long position, long count, WritableByteChannel target)
-			throws IOException {
-		openCheck();
+    public long transferTo(long position, long count, WritableByteChannel target)
+            throws IOException {
+        openCheck();
         if (!target.isOpen()) {
             throw new ClosedChannelException();
         }
-		throw new NonReadableChannelException();
-	}
+        throw new NonReadableChannelException();
+    }
 
-	public long read(ByteBuffer[] buffers, int offset, int length)
-			throws IOException {		
+    public long read(ByteBuffer[] buffers, int offset, int length)
+            throws IOException {
         if (offset < 0 || length < 0 || offset + length > buffers.length) {
             throw new IndexOutOfBoundsException();
         }
         openCheck();
-		throw new NonReadableChannelException();
-	}
+        throw new NonReadableChannelException();
+    }
 
-	public int read(ByteBuffer buffer) throws IOException {
-		openCheck();
-		throw new NonReadableChannelException();
-	}
+    public int read(ByteBuffer buffer) throws IOException {
+        openCheck();
+        throw new NonReadableChannelException();
+    }
 
-	public int read(ByteBuffer buffer, long position) throws IOException {		
+    public int read(ByteBuffer buffer, long position) throws IOException {
         if (null == buffer) {
             throw new NullPointerException();
         }
-        if (position < 0){
+        if (position < 0) {
             throw new IllegalArgumentException();
         }
-		throw new NonReadableChannelException();
-	}
+        throw new NonReadableChannelException();
+    }
 
-	public MappedByteBuffer map(MapMode mode, long position, long size)
-			throws IOException {
-		openCheck();
-		if (mode == null) {
-			throw new NullPointerException();
-		}
-		if (position < 0 || size < 0 || size > Integer.MAX_VALUE) {
-			throw new IllegalArgumentException();
-		}
-		throw new NonReadableChannelException();
-	}
-
-	public int write(ByteBuffer buffer) throws IOException {
-		if (append) {
-			position(size());
-		}
-		return super.write(buffer);
-	}
-
-	protected final FileLock basicLock(long position, long size,
-			boolean shared, boolean wait) throws IOException {
-		if (shared) {
-			throw new NonReadableChannelException();
-		}
-		return super.basicLock(position, size, shared, wait);
-	}
+    public MappedByteBuffer map(MapMode mode, long position, long size)
+            throws IOException {
+        openCheck();
+        if (mode == null) {
+            throw new NullPointerException();
+        }
+        if (position < 0 || size < 0 || size > Integer.MAX_VALUE) {
+            throw new IllegalArgumentException();
+        }
+        throw new NonReadableChannelException();
+    }
 
+    public int write(ByteBuffer buffer) throws IOException {
+        if (append) {
+            position(size());
+        }
+        return super.write(buffer);
+    }
+
+    protected final FileLock basicLock(long position, long size,
+            boolean shared, boolean wait) throws IOException {
+        if (shared) {
+            throw new NonReadableChannelException();
+        }
+        return super.basicLock(position, size, shared, wait);
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/unix/org/apache/harmony/nio/internal/EpollSelectionKeyImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/unix/org/apache/harmony/nio/internal/EpollSelectionKeyImpl.java?rev=587508&r1=587507&r2=587508&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/unix/org/apache/harmony/nio/internal/EpollSelectionKeyImpl.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/unix/org/apache/harmony/nio/internal/EpollSelectionKeyImpl.java Tue Oct 23 06:54:37 2007
@@ -37,30 +37,30 @@
     private EpollSelectorImpl selector;
 
     private int index;
-    
+
     static int stHash;
-    
-    private int hashCode; 
-    
-	public int hashCode() {		
-		return hashCode;
-	}
-	
-	public boolean equals(Object obj) {
-		if (this == obj)
-			return true;
-		if (obj == null)
-			return false;
-		if (getClass() != obj.getClass())
-			return false;
-		final EpollSelectionKeyImpl other = (EpollSelectionKeyImpl) obj;
-		if (hashCode != other.hashCode)
-			return false;
-		return true;
-	}
 
-	public EpollSelectionKeyImpl(AbstractSelectableChannel channel, int operations,
-            Object attachment, EpollSelectorImpl selector) {
+    private int hashCode;
+
+    public int hashCode() {
+        return hashCode;
+    }
+
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        final EpollSelectionKeyImpl other = (EpollSelectionKeyImpl) obj;
+        if (hashCode != other.hashCode)
+            return false;
+        return true;
+    }
+
+    public EpollSelectionKeyImpl(AbstractSelectableChannel channel,
+            int operations, Object attachment, EpollSelectorImpl selector) {
         super();
         this.channel = channel;
         interestOps = operations;
@@ -109,13 +109,13 @@
     }
 
     int getIndex() {
-    	return index;
+        return index;
     }
-    
+
     void setIndex(int index) {
-    	this.index = index;
+        this.index = index;
     }
-    
+
     private void checkValid() {
         if (!isValid()) {
             throw new CancelledKeyException();



Mime
View raw message