harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r578502 [7/10] - in /harmony/enhanced/classlib/branches/java6: depends/files/ depends/jars/ depends/manifests/xerces_2.9.0/ depends/manifests/xerces_2.9.1/ depends/manifests/xerces_2.9.1/META-INF/ make/ modules/archive/src/main/native/archi...
Date Sat, 22 Sep 2007 21:25:00 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/IntBuffer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/IntBuffer.java?rev=578502&r1=578501&r2=578502&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/IntBuffer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/IntBuffer.java Sat Sep 22 14:24:54 2007
@@ -32,529 +32,532 @@
  */
 public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer> {
 
-	/**
-	 * Creates a int buffer based on a new allocated int array.
-	 * 
-	 * @param capacity
-	 *            The capacity of the new buffer
-	 * @return The created int buffer
-	 * @throws IllegalArgumentException
-	 *             If <code>capacity</code> is less than zero
-	 */
-	public static IntBuffer allocate(int capacity) {
-		if (capacity < 0) {
-			throw new IllegalArgumentException();
-		}
-		return BufferFactory.newIntBuffer(capacity);
-	}
-
-	/**
-	 * Creates a new int buffer by wrapping the given int array.
-	 * <p>
-	 * Calling this method has the same effect as
-	 * <code>wrap(array, 0, array.length)</code>.
-	 * </p>
-	 * 
-	 * @param array
-	 *            The int array which the new buffer will be based on
-	 * @return The created int buffer
-	 */
-	public static IntBuffer wrap(int[] array) {
-		return wrap(array, 0, array.length);
-	}
-
-	/**
-	 * Creates new a int buffer by wrapping the given int array.
-	 * <p>
-	 * The new buffer's position will be <code>start</code>, limit will be
-	 * <code>start + len</code>, capacity will be the length of the array.
-	 * </p>
-	 * 
-	 * @param array
-	 *            The int array which the new buffer will be based on
-	 * @param start
-	 *            The start index, must be no less than zero and no greater than
-	 *            <code>array.length</code>
-	 * @param len
-	 *            The length, must be no less than zero and no greater than
-	 *            <code>array.length - start</code>
-	 * @return The created int buffer
-	 * @exception IndexOutOfBoundsException
-	 *                If either <code>start</code> or <code>len</code> is
-	 *                invalid
-	 */
-	public static IntBuffer wrap(int[] array, int start, int len) {
-                if (array == null) {
-                        throw new NullPointerException();
-                }
-                if (start < 0 || len < 0 || (long)len + (long)start > array.length) {
-                        throw new IndexOutOfBoundsException();
-                }
-
-		IntBuffer buf = BufferFactory.newIntBuffer(array);
-		buf.position = start;
-		buf.limit = start + len;
-
-		return buf;
-	}
-
-	/**
-	 * Constructs a <code>IntBuffer</code> with given capacity.
-	 * 
-	 * @param capacity
-	 *            The capacity of the buffer
-	 */
-	IntBuffer(int capacity) {
-		super(capacity);
-	}
-
-	/**
-	 * Returns the int array which this buffer is based on, if there's one.
-	 * 
-	 * @return The int array which this buffer is based on
-	 * @exception ReadOnlyBufferException
-	 *                If this buffer is based on an array, but it is readonly
-	 * @exception UnsupportedOperationException
-	 *                If this buffer is not based on an array
-	 */
-	public final int[] array() {
-		return protectedArray();
-	}
-
-	/**
-	 * Returns the offset of the int array which this buffer is based on, if
-	 * there's one.
-	 * <p>
-	 * The offset is the index of the array corresponds to the zero position of
-	 * the buffer.
-	 * </p>
-	 * 
-	 * @return The offset of the int array which this buffer is based on
-	 * @exception ReadOnlyBufferException
-	 *                If this buffer is based on an array, but it is readonly
-	 * @exception UnsupportedOperationException
-	 *                If this buffer is not based on an array
-	 */
-	public final int arrayOffset() {
-		return protectedArrayOffset();
-	}
-
-	/**
-	 * Returns a readonly buffer that shares content with this buffer.
-	 * <p>
-	 * The returned buffer is guaranteed to be a new instance, even this buffer
-	 * is readonly itself. The new buffer's position, limit, capacity and mark
-	 * are the same as this buffer.
-	 * </p>
-	 * <p>
-	 * The new buffer shares content with this buffer, which means this buffer's
-	 * change of content will be visible to the new buffer. The two buffer's
-	 * position, limit and mark are independent.
-	 * </p>
-	 * 
-	 * @return A readonly version of this buffer.
-	 */
-	public abstract IntBuffer asReadOnlyBuffer();
-
-	/**
-	 * Compacts this int buffer.
-	 * <p>
-	 * The remaining <code>int</code>s will be moved to the head of the
-	 * buffer, staring from position zero. Then the position is set to
-	 * <code>remaining()</code>; the limit is set to capacity; the mark is
-	 * cleared.
-	 * </p>
-	 * 
-	 * @return This buffer
-	 * @exception ReadOnlyBufferException
-	 *                If no changes may be made to the contents of this buffer
-	 */
-	public abstract IntBuffer compact();
-
-	/**
-	 * Compare the remaining <code>int</code>s of this buffer to another int
-	 * buffer's remaining <code>int</code>s.
-	 * 
-	 * @param otherBuffer
-	 *            Another int buffer
-	 * @return a negative value if this is less than <code>other</code>; 0 if
-	 *         this equals to <code>other</code>; a positive value if this is
-	 *         greater than <code>other</code>
-	 * @exception ClassCastException
-	 *                If <code>other</code> is not a int buffer
-	 */
-	public int compareTo(IntBuffer otherBuffer) {
-		int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
-				: otherBuffer.remaining();
-		int thisPos = position;
-		int otherPos = otherBuffer.position;
-		int thisByte, otherByte;
-		while (compareRemaining > 0) {
-			thisByte = get(thisPos);
-			otherByte = otherBuffer.get(otherPos);
-			if (thisByte != otherByte) {
-				return thisByte < otherByte ? -1 : 1;
-			}
-			thisPos++;
-			otherPos++;
-			compareRemaining--;
-		}
-		return remaining() - otherBuffer.remaining();
-	}
-
-	/**
-	 * Returns a duplicated buffer that shares content with this buffer.
-	 * <p>
-	 * The duplicated buffer's position, limit, capacity and mark are the same
-	 * as this buffer. The duplicated buffer's readonly property and byte order
-	 * are same as this buffer too.
-	 * </p>
-	 * <p>
-	 * The new buffer shares content with this buffer, which means either
-	 * buffer's change of content will be visible to the other. The two buffer's
-	 * position, limit and mark are independent.
-	 * </p>
-	 * 
-	 * @return A duplicated buffer that shares content with this buffer.
-	 */
-	public abstract IntBuffer duplicate();
-
-	/**
-	 * Tests whether this int buffer equals to another object.
-	 * <p>
-	 * If <code>other</code> is not a int buffer, then false is returned.
-	 * </p>
-	 * <p>
-	 * Two int buffers are equals if, and only if, their remaining
-	 * <code>int</code>s are exactly the same. Position, limit, capacity and
-	 * mark are not considered.
-	 * </p>
-	 * 
-	 * @param other
-	 *            the object to be compared against
-	 * @return Whether this int buffer equals to another object.
-	 */
-	public boolean equals(Object other) {
-		if (!(other instanceof IntBuffer)) {
-			return false;
-		}
-		IntBuffer otherBuffer = (IntBuffer) other;
-
-		if (remaining() != otherBuffer.remaining()) {
-			return false;
-		}
-
-		int myPosition = position;
-		int otherPosition = otherBuffer.position;
-		boolean equalSoFar = true;
-		while (equalSoFar && (myPosition < limit)) {
-			equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++);
-		}
-
-		return equalSoFar;
-	}
-
-	/**
-	 * Returns the int at the current position and increase the position by 1.
-	 * 
-	 * @return The int at the current position.
-	 * @exception BufferUnderflowException
-	 *                If the position is equal or greater than limit
-	 */
-	public abstract int get();
-
-	/**
-	 * Reads <code>int</code>s from the current position into the specified
-	 * int array and increase the position by the number of <code>int</code>s
-	 * read.
-	 * <p>
-	 * Calling this method has the same effect as
-	 * <code>get(dest, 0, dest.length)</code>.
-	 * </p>
-	 * 
-	 * @param dest
-	 *            The destination int array
-	 * @return This buffer
-	 * @exception BufferUnderflowException
-	 *                if <code>dest.length</code> is greater than
-	 *                <code>remaining()</code>
-	 */
-	public IntBuffer get(int[] dest) {
-		return get(dest, 0, dest.length);
-	}
-
-	/**
-	 * Reads <code>int</code>s from the current position into the specified
-	 * int array, starting from the specified offset, and increase the position
-	 * by the number of <code>int</code>s read.
-	 * 
-	 * @param dest
-	 *            The target int array
-	 * @param off
-	 *            The offset of the int array, must be no less than zero and no
-	 *            greater than <code>dest.length</code>
-	 * @param len
-	 *            The number of <code>int</code>s to read, must be no less
-	 *            than zero and no greater than <code>dest.length - off</code>
-	 * @return This buffer
-	 * @exception IndexOutOfBoundsException
-	 *                If either <code>off</code> or <code>len</code> is
-	 *                invalid
-	 * @exception BufferUnderflowException
-	 *                If <code>len</code> is greater than
-	 *                <code>remaining()</code>
-	 */
-	public IntBuffer get(int[] dest, int off, int len) {
+    /**
+     * Creates a int buffer based on a new allocated int array.
+     * 
+     * @param capacity
+     *            The capacity of the new buffer
+     * @return The created int buffer
+     * @throws IllegalArgumentException
+     *             If <code>capacity</code> is less than zero
+     */
+    public static IntBuffer allocate(int capacity) {
+        if (capacity < 0) {
+            throw new IllegalArgumentException();
+        }
+        return BufferFactory.newIntBuffer(capacity);
+    }
+
+    /**
+     * Creates a new int buffer by wrapping the given int array.
+     * <p>
+     * Calling this method has the same effect as
+     * <code>wrap(array, 0, array.length)</code>.
+     * </p>
+     * 
+     * @param array
+     *            The int array which the new buffer will be based on
+     * @return The created int buffer
+     */
+    public static IntBuffer wrap(int[] array) {
+        return wrap(array, 0, array.length);
+    }
+
+    /**
+     * Creates new a int buffer by wrapping the given int array.
+     * <p>
+     * The new buffer's position will be <code>start</code>, limit will be
+     * <code>start + len</code>, capacity will be the length of the array.
+     * </p>
+     * 
+     * @param array
+     *            The int array which the new buffer will be based on
+     * @param start
+     *            The start index, must be no less than zero and no greater than
+     *            <code>array.length</code>
+     * @param len
+     *            The length, must be no less than zero and no greater than
+     *            <code>array.length - start</code>
+     * @return The created int buffer
+     * @exception IndexOutOfBoundsException
+     *                If either <code>start</code> or <code>len</code> is
+     *                invalid
+     */
+    public static IntBuffer wrap(int[] array, int start, int len) {
+        if (array == null) {
+            throw new NullPointerException();
+        }
+        if (start < 0 || len < 0 || (long) len + (long) start > array.length) {
+            throw new IndexOutOfBoundsException();
+        }
+
+        IntBuffer buf = BufferFactory.newIntBuffer(array);
+        buf.position = start;
+        buf.limit = start + len;
+
+        return buf;
+    }
+
+    /**
+     * Constructs a <code>IntBuffer</code> with given capacity.
+     * 
+     * @param capacity
+     *            The capacity of the buffer
+     */
+    IntBuffer(int capacity) {
+        super(capacity);
+    }
+
+    /**
+     * Returns the int array which this buffer is based on, if there's one.
+     * 
+     * @return The int array which this buffer is based on
+     * @exception ReadOnlyBufferException
+     *                If this buffer is based on an array, but it is readonly
+     * @exception UnsupportedOperationException
+     *                If this buffer is not based on an array
+     */
+    public final int[] array() {
+        return protectedArray();
+    }
+
+    /**
+     * Returns the offset of the int array which this buffer is based on, if
+     * there's one.
+     * <p>
+     * The offset is the index of the array corresponds to the zero position of
+     * the buffer.
+     * </p>
+     * 
+     * @return The offset of the int array which this buffer is based on
+     * @exception ReadOnlyBufferException
+     *                If this buffer is based on an array, but it is readonly
+     * @exception UnsupportedOperationException
+     *                If this buffer is not based on an array
+     */
+    public final int arrayOffset() {
+        return protectedArrayOffset();
+    }
+
+    /**
+     * Returns a readonly buffer that shares content with this buffer.
+     * <p>
+     * The returned buffer is guaranteed to be a new instance, even this buffer
+     * is readonly itself. The new buffer's position, limit, capacity and mark
+     * are the same as this buffer.
+     * </p>
+     * <p>
+     * The new buffer shares content with this buffer, which means this buffer's
+     * change of content will be visible to the new buffer. The two buffer's
+     * position, limit and mark are independent.
+     * </p>
+     * 
+     * @return A readonly version of this buffer.
+     */
+    public abstract IntBuffer asReadOnlyBuffer();
+
+    /**
+     * Compacts this int buffer.
+     * <p>
+     * The remaining <code>int</code>s will be moved to the head of the
+     * buffer, staring from position zero. Then the position is set to
+     * <code>remaining()</code>; the limit is set to capacity; the mark is
+     * cleared.
+     * </p>
+     * 
+     * @return This buffer
+     * @exception ReadOnlyBufferException
+     *                If no changes may be made to the contents of this buffer
+     */
+    public abstract IntBuffer compact();
+
+    /**
+     * Compare the remaining <code>int</code>s of this buffer to another int
+     * buffer's remaining <code>int</code>s.
+     * 
+     * @param otherBuffer
+     *            Another int buffer
+     * @return a negative value if this is less than <code>other</code>; 0 if
+     *         this equals to <code>other</code>; a positive value if this is
+     *         greater than <code>other</code>
+     * @exception ClassCastException
+     *                If <code>other</code> is not a int buffer
+     */
+    public int compareTo(IntBuffer otherBuffer) {
+        int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
+                : otherBuffer.remaining();
+        int thisPos = position;
+        int otherPos = otherBuffer.position;
+        int thisByte, otherByte;
+        while (compareRemaining > 0) {
+            thisByte = get(thisPos);
+            otherByte = otherBuffer.get(otherPos);
+            if (thisByte != otherByte) {
+                return thisByte < otherByte ? -1 : 1;
+            }
+            thisPos++;
+            otherPos++;
+            compareRemaining--;
+        }
+        return remaining() - otherBuffer.remaining();
+    }
+
+    /**
+     * Returns a duplicated buffer that shares content with this buffer.
+     * <p>
+     * The duplicated buffer's position, limit, capacity and mark are the same
+     * as this buffer. The duplicated buffer's readonly property and byte order
+     * are same as this buffer too.
+     * </p>
+     * <p>
+     * The new buffer shares content with this buffer, which means either
+     * buffer's change of content will be visible to the other. The two buffer's
+     * position, limit and mark are independent.
+     * </p>
+     * 
+     * @return A duplicated buffer that shares content with this buffer.
+     */
+    public abstract IntBuffer duplicate();
+
+    /**
+     * Tests whether this int buffer equals to another object.
+     * <p>
+     * If <code>other</code> is not a int buffer, then false is returned.
+     * </p>
+     * <p>
+     * Two int buffers are equals if, and only if, their remaining
+     * <code>int</code>s are exactly the same. Position, limit, capacity and
+     * mark are not considered.
+     * </p>
+     * 
+     * @param other
+     *            the object to be compared against
+     * @return Whether this int buffer equals to another object.
+     */
+    @Override
+    public boolean equals(Object other) {
+        if (!(other instanceof IntBuffer)) {
+            return false;
+        }
+        IntBuffer otherBuffer = (IntBuffer) other;
+
+        if (remaining() != otherBuffer.remaining()) {
+            return false;
+        }
+
+        int myPosition = position;
+        int otherPosition = otherBuffer.position;
+        boolean equalSoFar = true;
+        while (equalSoFar && (myPosition < limit)) {
+            equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++);
+        }
+
+        return equalSoFar;
+    }
+
+    /**
+     * Returns the int at the current position and increase the position by 1.
+     * 
+     * @return The int at the current position.
+     * @exception BufferUnderflowException
+     *                If the position is equal or greater than limit
+     */
+    public abstract int get();
+
+    /**
+     * Reads <code>int</code>s from the current position into the specified
+     * int array and increase the position by the number of <code>int</code>s
+     * read.
+     * <p>
+     * Calling this method has the same effect as
+     * <code>get(dest, 0, dest.length)</code>.
+     * </p>
+     * 
+     * @param dest
+     *            The destination int array
+     * @return This buffer
+     * @exception BufferUnderflowException
+     *                if <code>dest.length</code> is greater than
+     *                <code>remaining()</code>
+     */
+    public IntBuffer get(int[] dest) {
+        return get(dest, 0, dest.length);
+    }
+
+    /**
+     * Reads <code>int</code>s from the current position into the specified
+     * int array, starting from the specified offset, and increase the position
+     * by the number of <code>int</code>s read.
+     * 
+     * @param dest
+     *            The target int array
+     * @param off
+     *            The offset of the int array, must be no less than zero and no
+     *            greater than <code>dest.length</code>
+     * @param len
+     *            The number of <code>int</code>s to read, must be no less
+     *            than zero and no greater than <code>dest.length - off</code>
+     * @return This buffer
+     * @exception IndexOutOfBoundsException
+     *                If either <code>off</code> or <code>len</code> is
+     *                invalid
+     * @exception BufferUnderflowException
+     *                If <code>len</code> is greater than
+     *                <code>remaining()</code>
+     */
+    public IntBuffer get(int[] dest, int off, int len) {
         int length = dest.length;
-        if (off < 0 || len < 0 || (long)len + (long)off > length) {
+        if (off < 0 || len < 0 || (long) len + (long) off > length) {
             throw new IndexOutOfBoundsException();
         }
-		if (len > remaining()) {
-			throw new BufferUnderflowException();
-		}
-		for (int i = off; i < off + len; i++) {
-			dest[i] = get();
-		}
-		return this;
-	}
-
-	/**
-	 * Returns a int at the specified index, and the position is not changed.
-	 * 
-	 * @param index
-	 *            The index, must be no less than zero and less than limit
-	 * @return A int at the specified index.
-	 * @exception IndexOutOfBoundsException
-	 *                If index is invalid
-	 */
-	public abstract int get(int index);
-
-	/**
-	 * Returns whether this buffer is based on a int array and is read/write.
-	 * <p>
-	 * If this buffer is readonly, then false is returned.
-	 * </p>
-	 * 
-	 * @return Whether this buffer is based on a int array and is read/write.
-	 */
-	public final boolean hasArray() {
-		return protectedHasArray();
-	}
-
-	/**
-	 * Hash code is calculated from the remaining <code>int</code>s.
-	 * <p>
-	 * Position, limit, capacity and mark don't affect the hash code.
-	 * </p>
-	 * 
-	 * @return The hash code calculated from the remaining <code>int</code>s.
-	 */
-	public int hashCode() {
-		int myPosition = position;
-		int hash = 0;
-		while (myPosition < limit) {
-			hash = hash + get(myPosition++);
-		}
-		return hash;
-	}
-
-	/**
-	 * Returns true if this buffer is direct.
-	 * <p>
-	 * A int buffer is direct, if it is based on a byte buffer and the byte
-	 * buffer is direct.
-	 * </p>
-	 * 
-	 * @return True if this buffer is direct.
-	 */
-	public abstract boolean isDirect();
-
-	/**
-	 * Returns the byte order used by this buffer when converting
-	 * <code>int</code>s from/to <code>byte</code>s.
-	 * <p>
-	 * If this buffer is not based on a byte buffer, then always return the
-	 * platform's native byte order.
-	 * </p>
-	 * 
-	 * @return The byte order used by this buffer when converting
-	 *         <code>int</code>s from/to <code>byte</code>s.
-	 */
-	public abstract ByteOrder order();
-
-	/**
-	 * Child class implements this method to realize <code>array()</code>.
-	 * 
-	 * @return see <code>array()</code>
-	 */
-	abstract int[] protectedArray();
-
-	/**
-	 * Child class implements this method to realize <code>arrayOffset()</code>.
-	 * 
-	 * @return see <code>arrayOffset()</code>
-	 */
-	abstract int protectedArrayOffset();
-
-	/**
-	 * Child class implements this method to realize <code>hasArray()</code>.
-	 * 
-	 * @return see <code>hasArray()</code>
-	 */
-	abstract boolean protectedHasArray();
-
-	/**
-	 * Writes the given int to the current position and increase the position by
-	 * 1.
-	 * 
-	 * @param i
-	 *            The int to write
-	 * @return This buffer
-	 * @exception BufferOverflowException
-	 *                If position is equal or greater than limit
-	 * @exception ReadOnlyBufferException
-	 *                If no changes may be made to the contents of this buffer
-	 */
-	public abstract IntBuffer put(int i);
-
-	/**
-	 * Writes <code>int</code>s in the given int array to the current
-	 * position and increase the position by the number of <code>int</code>s
-	 * written.
-	 * <p>
-	 * Calling this method has the same effect as
-	 * <code>put(src, 0, src.length)</code>.
-	 * </p>
-	 * 
-	 * @param src
-	 *            The source int array
-	 * @return This buffer
-	 * @exception BufferOverflowException
-	 *                If <code>remaining()</code> is less than
-	 *                <code>src.length</code>
-	 * @exception ReadOnlyBufferException
-	 *                If no changes may be made to the contents of this buffer
-	 */
-	public final IntBuffer put(int[] src) {
-		return put(src, 0, src.length);
-	}
-
-	/**
-	 * Writes <code>int</code>s in the given int array, starting from the
-	 * specified offset, to the current position and increase the position by
-	 * the number of <code>int</code>s written.
-	 * 
-	 * @param src
-	 *            The source int array
-	 * @param off
-	 *            The offset of int array, must be no less than zero and no
-	 *            greater than <code>src.length</code>
-	 * @param len
-	 *            The number of <code>int</code>s to write, must be no less
-	 *            than zero and no greater than <code>src.length - off</code>
-	 * @return This buffer
-	 * @exception BufferOverflowException
-	 *                If <code>remaining()</code> is less than
-	 *                <code>len</code>
-	 * @exception IndexOutOfBoundsException
-	 *                If either <code>off</code> or <code>len</code> is
-	 *                invalid
-	 * @exception ReadOnlyBufferException
-	 *                If no changes may be made to the contents of this buffer
-	 */
-	public IntBuffer put(int[] src, int off, int len) {
+        if (len > remaining()) {
+            throw new BufferUnderflowException();
+        }
+        for (int i = off; i < off + len; i++) {
+            dest[i] = get();
+        }
+        return this;
+    }
+
+    /**
+     * Returns a int at the specified index, and the position is not changed.
+     * 
+     * @param index
+     *            The index, must be no less than zero and less than limit
+     * @return A int at the specified index.
+     * @exception IndexOutOfBoundsException
+     *                If index is invalid
+     */
+    public abstract int get(int index);
+
+    /**
+     * Returns whether this buffer is based on a int array and is read/write.
+     * <p>
+     * If this buffer is readonly, then false is returned.
+     * </p>
+     * 
+     * @return Whether this buffer is based on a int array and is read/write.
+     */
+    public final boolean hasArray() {
+        return protectedHasArray();
+    }
+
+    /**
+     * Hash code is calculated from the remaining <code>int</code>s.
+     * <p>
+     * Position, limit, capacity and mark don't affect the hash code.
+     * </p>
+     * 
+     * @return The hash code calculated from the remaining <code>int</code>s.
+     */
+    @Override
+    public int hashCode() {
+        int myPosition = position;
+        int hash = 0;
+        while (myPosition < limit) {
+            hash = hash + get(myPosition++);
+        }
+        return hash;
+    }
+
+    /**
+     * Returns true if this buffer is direct.
+     * <p>
+     * A int buffer is direct, if it is based on a byte buffer and the byte
+     * buffer is direct.
+     * </p>
+     * 
+     * @return True if this buffer is direct.
+     */
+    public abstract boolean isDirect();
+
+    /**
+     * Returns the byte order used by this buffer when converting
+     * <code>int</code>s from/to <code>byte</code>s.
+     * <p>
+     * If this buffer is not based on a byte buffer, then always return the
+     * platform's native byte order.
+     * </p>
+     * 
+     * @return The byte order used by this buffer when converting
+     *         <code>int</code>s from/to <code>byte</code>s.
+     */
+    public abstract ByteOrder order();
+
+    /**
+     * Child class implements this method to realize <code>array()</code>.
+     * 
+     * @return see <code>array()</code>
+     */
+    abstract int[] protectedArray();
+
+    /**
+     * Child class implements this method to realize <code>arrayOffset()</code>.
+     * 
+     * @return see <code>arrayOffset()</code>
+     */
+    abstract int protectedArrayOffset();
+
+    /**
+     * Child class implements this method to realize <code>hasArray()</code>.
+     * 
+     * @return see <code>hasArray()</code>
+     */
+    abstract boolean protectedHasArray();
+
+    /**
+     * Writes the given int to the current position and increase the position by
+     * 1.
+     * 
+     * @param i
+     *            The int to write
+     * @return This buffer
+     * @exception BufferOverflowException
+     *                If position is equal or greater than limit
+     * @exception ReadOnlyBufferException
+     *                If no changes may be made to the contents of this buffer
+     */
+    public abstract IntBuffer put(int i);
+
+    /**
+     * Writes <code>int</code>s in the given int array to the current
+     * position and increase the position by the number of <code>int</code>s
+     * written.
+     * <p>
+     * Calling this method has the same effect as
+     * <code>put(src, 0, src.length)</code>.
+     * </p>
+     * 
+     * @param src
+     *            The source int array
+     * @return This buffer
+     * @exception BufferOverflowException
+     *                If <code>remaining()</code> is less than
+     *                <code>src.length</code>
+     * @exception ReadOnlyBufferException
+     *                If no changes may be made to the contents of this buffer
+     */
+    public final IntBuffer put(int[] src) {
+        return put(src, 0, src.length);
+    }
+
+    /**
+     * Writes <code>int</code>s in the given int array, starting from the
+     * specified offset, to the current position and increase the position by
+     * the number of <code>int</code>s written.
+     * 
+     * @param src
+     *            The source int array
+     * @param off
+     *            The offset of int array, must be no less than zero and no
+     *            greater than <code>src.length</code>
+     * @param len
+     *            The number of <code>int</code>s to write, must be no less
+     *            than zero and no greater than <code>src.length - off</code>
+     * @return This buffer
+     * @exception BufferOverflowException
+     *                If <code>remaining()</code> is less than
+     *                <code>len</code>
+     * @exception IndexOutOfBoundsException
+     *                If either <code>off</code> or <code>len</code> is
+     *                invalid
+     * @exception ReadOnlyBufferException
+     *                If no changes may be made to the contents of this buffer
+     */
+    public IntBuffer put(int[] src, int off, int len) {
         int length = src.length;
-        if (off < 0 || len < 0 || (long)len + (long)off > length) {
+        if (off < 0 || len < 0 || (long) len + (long) off > length) {
             throw new IndexOutOfBoundsException();
         }
-        
-		if (len > remaining()) {
-			throw new BufferOverflowException();
-		}
-		for (int i = off; i < off + len; i++) {
-			put(src[i]);
-		}
-		return this;
-	}
-
-	/**
-	 * Writes all the remaining <code>int</code>s of the <code>src</code>
-	 * int buffer to this buffer's current position, and increase both buffers'
-	 * position by the number of <code>int</code>s copied.
-	 * 
-	 * @param src
-	 *            The source int buffer
-	 * @return This buffer
-	 * @exception BufferOverflowException
-	 *                If <code>src.remaining()</code> is greater than this
-	 *                buffer's <code>remaining()</code>
-	 * @exception IllegalArgumentException
-	 *                If <code>src</code> is this buffer
-	 * @exception ReadOnlyBufferException
-	 *                If no changes may be made to the contents of this buffer
-	 */
-	public IntBuffer put(IntBuffer src) {
-		if (src == this) {
-			throw new IllegalArgumentException();
-		}
-		if (src.remaining() > remaining()) {
-			throw new BufferOverflowException();
-		}
+
+        if (len > remaining()) {
+            throw new BufferOverflowException();
+        }
+        for (int i = off; i < off + len; i++) {
+            put(src[i]);
+        }
+        return this;
+    }
+
+    /**
+     * Writes all the remaining <code>int</code>s of the <code>src</code>
+     * int buffer to this buffer's current position, and increase both buffers'
+     * position by the number of <code>int</code>s copied.
+     * 
+     * @param src
+     *            The source int buffer
+     * @return This buffer
+     * @exception BufferOverflowException
+     *                If <code>src.remaining()</code> is greater than this
+     *                buffer's <code>remaining()</code>
+     * @exception IllegalArgumentException
+     *                If <code>src</code> is this buffer
+     * @exception ReadOnlyBufferException
+     *                If no changes may be made to the contents of this buffer
+     */
+    public IntBuffer put(IntBuffer src) {
+        if (src == this) {
+            throw new IllegalArgumentException();
+        }
+        if (src.remaining() > remaining()) {
+            throw new BufferOverflowException();
+        }
         int[] contents = new int[src.remaining()];
         src.get(contents);
         put(contents);
-		return this;
-	}
+        return this;
+    }
 
-	/**
-	 * Write a int to the specified index of this buffer and the position is not
-	 * changed.
-	 * 
-	 * @param index
-	 *            The index, must be no less than zero and less than the limit
-	 * @param i
-	 *            The int to write
-	 * @return This buffer
-	 * @exception IndexOutOfBoundsException
-	 *                If index is invalid
-	 * @exception ReadOnlyBufferException
-	 *                If no changes may be made to the contents of this buffer
-	 */
-	public abstract IntBuffer put(int index, int i);
-
-	/**
-	 * Returns a sliced buffer that shares content with this buffer.
-	 * <p>
-	 * The sliced buffer's capacity will be this buffer's
-	 * <code>remaining()</code>, and its zero position will correspond to
-	 * this buffer's current position. The new buffer's position will be 0,
-	 * limit will be its capacity, and its mark is unset. The new buffer's
-	 * readonly property and byte order are same as this buffer.
-	 * </p>
-	 * <p>
-	 * The new buffer shares content with this buffer, which means either
-	 * buffer's change of content will be visible to the other. The two buffer's
-	 * position, limit and mark are independent.
-	 * </p>
-	 * 
-	 * @return A sliced buffer that shares content with this buffer.
-	 */
-	public abstract IntBuffer slice();
-
-	/**
-	 * Returns a string represents the state of this int buffer.
-	 * 
-	 * @return A string represents the state of this int buffer.
-	 */
-	public String toString() {
-		StringBuffer buf = new StringBuffer();
-		buf.append(getClass().getName());
-		buf.append(", status: capacity="); //$NON-NLS-1$
-		buf.append(capacity());
-		buf.append(" position="); //$NON-NLS-1$
-		buf.append(position());
-		buf.append(" limit="); //$NON-NLS-1$
-		buf.append(limit());
-		return buf.toString();
-	}
+    /**
+     * Write a int to the specified index of this buffer and the position is not
+     * changed.
+     * 
+     * @param index
+     *            The index, must be no less than zero and less than the limit
+     * @param i
+     *            The int to write
+     * @return This buffer
+     * @exception IndexOutOfBoundsException
+     *                If index is invalid
+     * @exception ReadOnlyBufferException
+     *                If no changes may be made to the contents of this buffer
+     */
+    public abstract IntBuffer put(int index, int i);
+
+    /**
+     * Returns a sliced buffer that shares content with this buffer.
+     * <p>
+     * The sliced buffer's capacity will be this buffer's
+     * <code>remaining()</code>, and its zero position will correspond to
+     * this buffer's current position. The new buffer's position will be 0,
+     * limit will be its capacity, and its mark is unset. The new buffer's
+     * readonly property and byte order are same as this buffer.
+     * </p>
+     * <p>
+     * The new buffer shares content with this buffer, which means either
+     * buffer's change of content will be visible to the other. The two buffer's
+     * position, limit and mark are independent.
+     * </p>
+     * 
+     * @return A sliced buffer that shares content with this buffer.
+     */
+    public abstract IntBuffer slice();
+
+    /**
+     * Returns a string represents the state of this int buffer.
+     * 
+     * @return A string represents the state of this int buffer.
+     */
+    @Override
+    public String toString() {
+        StringBuffer buf = new StringBuffer();
+        buf.append(getClass().getName());
+        buf.append(", status: capacity="); //$NON-NLS-1$
+        buf.append(capacity());
+        buf.append(" position="); //$NON-NLS-1$
+        buf.append(position());
+        buf.append(" limit="); //$NON-NLS-1$
+        buf.append(limit());
+        return buf.toString();
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/IntToByteBufferAdapter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/IntToByteBufferAdapter.java?rev=578502&r1=578501&r2=578502&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/IntToByteBufferAdapter.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/IntToByteBufferAdapter.java Sat Sep 22 14:24:54 2007
@@ -19,7 +19,6 @@
 import org.apache.harmony.nio.internal.DirectBuffer;
 import org.apache.harmony.luni.platform.PlatformAddress;
 
-
 /**
  * This class wraps a byte buffer to be a int buffer.
  * <p>
@@ -35,163 +34,172 @@
  */
 final class IntToByteBufferAdapter extends IntBuffer implements DirectBuffer {
 
-	static IntBuffer wrap(ByteBuffer byteBuffer) {
-		return new IntToByteBufferAdapter(byteBuffer.slice());
-	}
-
-	private final ByteBuffer byteBuffer;
-
-	IntToByteBufferAdapter(ByteBuffer byteBuffer) {
-		super((byteBuffer.capacity() >> 2));
-		this.byteBuffer = byteBuffer;
-		this.byteBuffer.clear();
-	}
-        
-        public int getByteCapacity() {
-            if (byteBuffer instanceof DirectBuffer) {
-                return ((DirectBuffer)byteBuffer).getByteCapacity();
-            } else {
-                assert false : byteBuffer;
-                return -1;
-            }            
-        }
-
-        public PlatformAddress getEffectiveAddress() {
-            if (byteBuffer instanceof DirectBuffer) {
-                return ((DirectBuffer)byteBuffer).getEffectiveAddress();
-            } else {
-                assert false : byteBuffer;
-                return null;
-            }
-        }
-            
-        public PlatformAddress getBaseAddress() {
-            if (byteBuffer instanceof DirectBuffer) {
-                return ((DirectBuffer)byteBuffer).getBaseAddress();
-            } else {
-                assert false : byteBuffer;
-                return null;
-            }
-        }
-            
-        public boolean isAddressValid() {
-            if (byteBuffer instanceof DirectBuffer) {
-                return ((DirectBuffer)byteBuffer).isAddressValid();
-            } else {
-                assert false : byteBuffer;
-                return false;
-            }
-        }
-
-        public void addressValidityCheck() {
-            if (byteBuffer instanceof DirectBuffer) {
-                ((DirectBuffer)byteBuffer).addressValidityCheck();
-            } else {
-                assert false : byteBuffer;
-            }
-        }
-            
-        public void free() {
-            if (byteBuffer instanceof DirectBuffer) {
-                ((DirectBuffer)byteBuffer).free();
-            } else {
-                assert false : byteBuffer;
-            }   
-        }
-
-
-	public IntBuffer asReadOnlyBuffer() {
-		IntToByteBufferAdapter buf = new IntToByteBufferAdapter(byteBuffer
-				.asReadOnlyBuffer());
-		buf.limit = limit;
-		buf.position = position;
-		buf.mark = mark;
-		return buf;
-	}
-
-	public IntBuffer compact() {
-		if (byteBuffer.isReadOnly()) {
-			throw new ReadOnlyBufferException();
-		}
-		byteBuffer.limit(limit << 2);
-		byteBuffer.position(position << 2);
-		byteBuffer.compact();
-		byteBuffer.clear();
-		position = limit - position;
-		limit = capacity;
-		mark = UNSET_MARK;
-		return this;
-	}
-
-	public IntBuffer duplicate() {
-		IntToByteBufferAdapter buf = new IntToByteBufferAdapter(byteBuffer
-				.duplicate());
-		buf.limit = limit;
-		buf.position = position;
-		buf.mark = mark;
-		return buf;
-	}
-
-	public int get() {
-		if (position == limit) {
-			throw new BufferUnderflowException();
-		}
-		return byteBuffer.getInt(position++ << 2);
-	}
-
-	public int get(int index) {
-		if (index < 0 || index >= limit) {
-			throw new IndexOutOfBoundsException();
-		}
-		return byteBuffer.getInt(index << 2);
-	}
-
-	public boolean isDirect() {
-		return byteBuffer.isDirect();
-	}
-
-	public boolean isReadOnly() {
-		return byteBuffer.isReadOnly();
-	}
-
-	public ByteOrder order() {
-		return byteBuffer.order();
-	}
-
-	protected int[] protectedArray() {
-		throw new UnsupportedOperationException();
-	}
-
-	protected int protectedArrayOffset() {
-		throw new UnsupportedOperationException();
-	}
-
-	protected boolean protectedHasArray() {
-		return false;
-	}
-
-	public IntBuffer put(int c) {
-		if (position == limit) {
-			throw new BufferOverflowException();
-		}
-		byteBuffer.putInt(position++ << 2, c);
-		return this;
-	}
-
-	public IntBuffer put(int index, int c) {
-		if (index < 0 || index >= limit) {
-			throw new IndexOutOfBoundsException();
-		}
-		byteBuffer.putInt(index << 2, c);
-		return this;
-	}
-
-	public IntBuffer slice() {
-		byteBuffer.limit(limit << 2);
-		byteBuffer.position(position << 2);
-		IntBuffer result = new IntToByteBufferAdapter(byteBuffer.slice());
-		byteBuffer.clear();
-		return result;
-	}
+    static IntBuffer wrap(ByteBuffer byteBuffer) {
+        return new IntToByteBufferAdapter(byteBuffer.slice());
+    }
+
+    private final ByteBuffer byteBuffer;
+
+    IntToByteBufferAdapter(ByteBuffer byteBuffer) {
+        super((byteBuffer.capacity() >> 2));
+        this.byteBuffer = byteBuffer;
+        this.byteBuffer.clear();
+    }
+
+    public int getByteCapacity() {
+        if (byteBuffer instanceof DirectBuffer) {
+            return ((DirectBuffer) byteBuffer).getByteCapacity();
+        }
+        assert false : byteBuffer;
+        return -1;
+    }
+
+    public PlatformAddress getEffectiveAddress() {
+        if (byteBuffer instanceof DirectBuffer) {
+            return ((DirectBuffer) byteBuffer).getEffectiveAddress();
+        }
+        assert false : byteBuffer;
+        return null;
+    }
+
+    public PlatformAddress getBaseAddress() {
+        if (byteBuffer instanceof DirectBuffer) {
+            return ((DirectBuffer) byteBuffer).getBaseAddress();
+        }
+        assert false : byteBuffer;
+        return null;
+    }
+
+    public boolean isAddressValid() {
+        if (byteBuffer instanceof DirectBuffer) {
+            return ((DirectBuffer) byteBuffer).isAddressValid();
+        }
+        assert false : byteBuffer;
+        return false;
+    }
+
+    public void addressValidityCheck() {
+        if (byteBuffer instanceof DirectBuffer) {
+            ((DirectBuffer) byteBuffer).addressValidityCheck();
+        } else {
+            assert false : byteBuffer;
+        }
+    }
+
+    public void free() {
+        if (byteBuffer instanceof DirectBuffer) {
+            ((DirectBuffer) byteBuffer).free();
+        } else {
+            assert false : byteBuffer;
+        }
+    }
+
+    @Override
+    public IntBuffer asReadOnlyBuffer() {
+        IntToByteBufferAdapter buf = new IntToByteBufferAdapter(byteBuffer
+                .asReadOnlyBuffer());
+        buf.limit = limit;
+        buf.position = position;
+        buf.mark = mark;
+        return buf;
+    }
+
+    @Override
+    public IntBuffer compact() {
+        if (byteBuffer.isReadOnly()) {
+            throw new ReadOnlyBufferException();
+        }
+        byteBuffer.limit(limit << 2);
+        byteBuffer.position(position << 2);
+        byteBuffer.compact();
+        byteBuffer.clear();
+        position = limit - position;
+        limit = capacity;
+        mark = UNSET_MARK;
+        return this;
+    }
+
+    @Override
+    public IntBuffer duplicate() {
+        IntToByteBufferAdapter buf = new IntToByteBufferAdapter(byteBuffer
+                .duplicate());
+        buf.limit = limit;
+        buf.position = position;
+        buf.mark = mark;
+        return buf;
+    }
+
+    @Override
+    public int get() {
+        if (position == limit) {
+            throw new BufferUnderflowException();
+        }
+        return byteBuffer.getInt(position++ << 2);
+    }
+
+    @Override
+    public int get(int index) {
+        if (index < 0 || index >= limit) {
+            throw new IndexOutOfBoundsException();
+        }
+        return byteBuffer.getInt(index << 2);
+    }
+
+    @Override
+    public boolean isDirect() {
+        return byteBuffer.isDirect();
+    }
+
+    @Override
+    public boolean isReadOnly() {
+        return byteBuffer.isReadOnly();
+    }
+
+    @Override
+    public ByteOrder order() {
+        return byteBuffer.order();
+    }
+
+    @Override
+    protected int[] protectedArray() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    protected int protectedArrayOffset() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    protected boolean protectedHasArray() {
+        return false;
+    }
+
+    @Override
+    public IntBuffer put(int c) {
+        if (position == limit) {
+            throw new BufferOverflowException();
+        }
+        byteBuffer.putInt(position++ << 2, c);
+        return this;
+    }
+
+    @Override
+    public IntBuffer put(int index, int c) {
+        if (index < 0 || index >= limit) {
+            throw new IndexOutOfBoundsException();
+        }
+        byteBuffer.putInt(index << 2, c);
+        return this;
+    }
+
+    @Override
+    public IntBuffer slice() {
+        byteBuffer.limit(limit << 2);
+        byteBuffer.position(position << 2);
+        IntBuffer result = new IntToByteBufferAdapter(byteBuffer.slice());
+        byteBuffer.clear();
+        return result;
+    }
 
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/InvalidMarkException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/InvalidMarkException.java?rev=578502&r1=578501&r2=578502&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/InvalidMarkException.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/InvalidMarkException.java Sat Sep 22 14:24:54 2007
@@ -16,7 +16,6 @@
 
 package java.nio;
 
-
 /**
  * A <code>InvalidMarkException</code> is thrown when <code>reset()</code>
  * is called on a buffer, but there is no mark set previously.
@@ -24,12 +23,12 @@
  */
 public class InvalidMarkException extends IllegalStateException {
 
-	private static final long serialVersionUID = 1698329710438510774L;
+    private static final long serialVersionUID = 1698329710438510774L;
 
-	/**
-	 * Constructs an <code>InvalidMarkException</code>.
-	 */
-	public InvalidMarkException() {
-		super();
-	}
+    /**
+     * Constructs an <code>InvalidMarkException</code>.
+     */
+    public InvalidMarkException() {
+        super();
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/LongArrayBuffer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/LongArrayBuffer.java?rev=578502&r1=578501&r2=578502&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/LongArrayBuffer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/LongArrayBuffer.java Sat Sep 22 14:24:54 2007
@@ -31,57 +31,62 @@
  */
 abstract class LongArrayBuffer extends LongBuffer {
 
-	protected final long[] backingArray;
+    protected final long[] backingArray;
 
-	protected final int offset;
+    protected final int offset;
 
-	LongArrayBuffer(long[] array) {
-		this(array.length, array, 0);
-	}
-
-	LongArrayBuffer(int capacity) {
-		this(capacity, new long[capacity], 0);
-	}
-
-	LongArrayBuffer(int capacity, long[] backingArray, int offset) {
-		super(capacity);
-		this.backingArray = backingArray;
-		this.offset = offset;
-	}
-
-	public final long get() {
-		if (position == limit) {
-			throw new BufferUnderflowException();
-		}
-		return backingArray[offset + position++];
-	}
-
-	public final long get(int index) {
-		if (index < 0 || index >= limit) {
-			throw new IndexOutOfBoundsException();
-		}
-		return backingArray[offset + index];
-	}
+    LongArrayBuffer(long[] array) {
+        this(array.length, array, 0);
+    }
+
+    LongArrayBuffer(int capacity) {
+        this(capacity, new long[capacity], 0);
+    }
+
+    LongArrayBuffer(int capacity, long[] backingArray, int offset) {
+        super(capacity);
+        this.backingArray = backingArray;
+        this.offset = offset;
+    }
+
+    @Override
+    public final long get() {
+        if (position == limit) {
+            throw new BufferUnderflowException();
+        }
+        return backingArray[offset + position++];
+    }
 
+    @Override
+    public final long get(int index) {
+        if (index < 0 || index >= limit) {
+            throw new IndexOutOfBoundsException();
+        }
+        return backingArray[offset + index];
+    }
+
+    @Override
     public final LongBuffer get(long[] dest, int off, int len) {
         int length = dest.length;
-        if (off < 0 || len < 0 || (long)len + (long)off > length) {
+        if (off < 0 || len < 0 || (long) len + (long) off > length) {
             throw new IndexOutOfBoundsException();
         }
         if (len > remaining()) {
             throw new BufferUnderflowException();
         }
-        System.arraycopy(backingArray, offset+position, dest, off, len);
+        System.arraycopy(backingArray, offset + position, dest, off, len);
         position += len;
         return this;
     }
-    
-	public final boolean isDirect() {
-		return false;
-	}
-
-	public final ByteOrder order() {
-		return ByteOrder.nativeOrder();
-	}
+
+    @Override
+    public final boolean isDirect() {
+        return false;
+    }
+
+    @Override
+    public final ByteOrder order() {
+        return ByteOrder.nativeOrder();
+    }
 
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/LongBuffer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/LongBuffer.java?rev=578502&r1=578501&r2=578502&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/LongBuffer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/java/nio/LongBuffer.java Sat Sep 22 14:24:54 2007
@@ -31,538 +31,542 @@
  * </ul>
  * </p>
  */
-public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer> {
+public abstract class LongBuffer extends Buffer implements
+        Comparable<LongBuffer> {
 
-	/**
-	 * Creates a long buffer based on a new allocated long array.
-	 * 
-	 * @param capacity
-	 *            The capacity of the new buffer
-	 * @return The created long buffer
-	 * @throws IllegalArgumentException
-	 *             If <code>capacity</code> is less than zero
-	 */
-	public static LongBuffer allocate(int capacity) {
-		if (capacity < 0) {
-			throw new IllegalArgumentException();
-		}
-		return BufferFactory.newLongBuffer(capacity);
-	}
-
-	/**
-	 * Creates a new long buffer by wrapping the given long array.
-	 * <p>
-	 * Calling this method has the same effect as
-	 * <code>wrap(array, 0, array.length)</code>.
-	 * </p>
-	 * 
-	 * @param array
-	 *            The long array which the new buffer will be based on
-	 * @return The created long buffer
-	 */
-	public static LongBuffer wrap(long[] array) {
-		return wrap(array, 0, array.length);
-	}
-
-	/**
-	 * Creates new a long buffer by wrapping the given long array.
-	 * <p>
-	 * The new buffer's position will be <code>start</code>, limit will be
-	 * <code>start + len</code>, capacity will be the length of the array.
-	 * </p>
-	 * 
-	 * @param array
-	 *            The long array which the new buffer will be based on
-	 * @param start
-	 *            The start index, must be no less than zero and no greater than
-	 *            <code>array.length</code>
-	 * @param len
-	 *            The length, must be no less than zero and no greater than
-	 *            <code>array.length - start</code>
-	 * @return The created long buffer
-	 * @exception IndexOutOfBoundsException
-	 *                If either <code>start</code> or <code>len</code> is
-	 *                invalid
-	 */
-	public static LongBuffer wrap(long[] array, int start, int len) {
-                if (array == null) {
-                        throw new NullPointerException();
-                }
-                if (start < 0 || len < 0 || (long)len + (long)start > array.length) {
-                        throw new IndexOutOfBoundsException();
-                }
-
-		LongBuffer buf = BufferFactory.newLongBuffer(array);
-		buf.position = start;
-		buf.limit = start + len;
-
-		return buf;
-	}
-
-	/**
-	 * Constructs a <code>LongBuffer</code> with given capacity.
-	 * 
-	 * @param capacity
-	 *            The capacity of the buffer
-	 */
-	LongBuffer(int capacity) {
-		super(capacity);
-	}
-
-	/**
-	 * Returns the long array which this buffer is based on, if there's one.
-	 * 
-	 * @return The long array which this buffer is based on
-	 * @exception ReadOnlyBufferException
-	 *                If this buffer is based on an array, but it is readonly
-	 * @exception UnsupportedOperationException
-	 *                If this buffer is not based on an array
-	 */
-	public final long[] array() {
-		return protectedArray();
-	}
-
-	/**
-	 * Returns the offset of the long array which this buffer is based on, if
-	 * there's one.
-	 * <p>
-	 * The offset is the index of the array corresponds to the zero position of
-	 * the buffer.
-	 * </p>
-	 * 
-	 * @return The offset of the long array which this buffer is based on
-	 * @exception ReadOnlyBufferException
-	 *                If this buffer is based on an array, but it is readonly
-	 * @exception UnsupportedOperationException
-	 *                If this buffer is not based on an array
-	 */
-	public final int arrayOffset() {
-		return protectedArrayOffset();
-	}
-
-	/**
-	 * Returns a readonly buffer that shares content with this buffer.
-	 * <p>
-	 * The returned buffer is guaranteed to be a new instance, even this buffer
-	 * is readonly itself. The new buffer's position, limit, capacity and mark
-	 * are the same as this buffer.
-	 * </p>
-	 * <p>
-	 * The new buffer shares content with this buffer, which means this buffer's
-	 * change of content will be visible to the new buffer. The two buffer's
-	 * position, limit and mark are independent.
-	 * </p>
-	 * 
-	 * @return A readonly version of this buffer.
-	 */
-	public abstract LongBuffer asReadOnlyBuffer();
-
-	/**
-	 * Compacts this long buffer.
-	 * <p>
-	 * The remaining <code>long</code>s will be moved to the head of the
-	 * buffer, staring from position zero. Then the position is set to
-	 * <code>remaining()</code>; the limit is set to capacity; the mark is
-	 * cleared.
-	 * </p>
-	 * 
-	 * @return This buffer
-	 * @exception ReadOnlyBufferException
-	 *                If no changes may be made to the contents of this buffer
-	 */
-	public abstract LongBuffer compact();
-
-	/**
-	 * Compare the remaining <code>long</code>s of this buffer to another
-	 * long buffer's remaining <code>long</code>s.
-	 * 
-	 * @param otherBuffer
-	 *            Another long buffer
-	 * @return a negative value if this is less than <code>other</code>; 0 if
-	 *         this equals to <code>other</code>; a positive value if this is
-	 *         greater than <code>other</code>
-	 * @exception ClassCastException
-	 *                If <code>other</code> is not a long buffer
-	 */
-	public int compareTo(LongBuffer otherBuffer) {
-		int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
-				: otherBuffer.remaining();
-		int thisPos = position;
-		int otherPos = otherBuffer.position;
-		long thisByte, otherByte;
-		while (compareRemaining > 0) {
-			thisByte = get(thisPos);
-			otherByte = otherBuffer.get(otherPos);
-			if (thisByte != otherByte) {
-				return thisByte < otherByte ? -1 : 1;
-			}
-			thisPos++;
-			otherPos++;
-			compareRemaining--;
-		}
-		return remaining() - otherBuffer.remaining();
-	}
-
-	/**
-	 * Returns a duplicated buffer that shares content with this buffer.
-	 * <p>
-	 * The duplicated buffer's position, limit, capacity and mark are the same
-	 * as this buffer. The duplicated buffer's readonly property and byte order
-	 * are same as this buffer too.
-	 * </p>
-	 * <p>
-	 * The new buffer shares content with this buffer, which means either
-	 * buffer's change of content will be visible to the other. The two buffer's
-	 * position, limit and mark are independent.
-	 * </p>
-	 * 
-	 * @return A duplicated buffer that shares content with this buffer.
-	 */
-	public abstract LongBuffer duplicate();
-
-	/**
-	 * Tests whether this long buffer equals to another object.
-	 * <p>
-	 * If <code>other</code> is not a long buffer, then false is returned.
-	 * </p>
-	 * <p>
-	 * Two long buffers are equals if, and only if, their remaining
-	 * <code>long</code>s are exactly the same. Position, limit, capacity and
-	 * mark are not considered.
-	 * </p>
-	 * 
-	 * @param other
-	 *            the object to be compared against
-	 * @return Whether this long buffer equals to another object.
-	 */
-	public boolean equals(Object other) {
-		if (!(other instanceof LongBuffer)) {
-			return false;
-		}
-		LongBuffer otherBuffer = (LongBuffer) other;
-
-		if (remaining() != otherBuffer.remaining()) {
-			return false;
-		}
-
-		int myPosition = position;
-		int otherPosition = otherBuffer.position;
-		boolean equalSoFar = true;
-		while (equalSoFar && (myPosition < limit)) {
-			equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++);
-		}
-
-		return equalSoFar;
-	}
-
-	/**
-	 * Returns the long at the current position and increase the position by 1.
-	 * 
-	 * @return The long at the current position.
-	 * @exception BufferUnderflowException
-	 *                If the position is equal or greater than limit
-	 */
-	public abstract long get();
-
-	/**
-	 * Reads <code>long</code>s from the current position into the specified
-	 * long array and increase the position by the number of <code>long</code>s
-	 * read.
-	 * <p>
-	 * Calling this method has the same effect as
-	 * <code>get(dest, 0, dest.length)</code>.
-	 * </p>
-	 * 
-	 * @param dest
-	 *            The destination long array
-	 * @return This buffer
-	 * @exception BufferUnderflowException
-	 *                if <code>dest.length</code> is greater than
-	 *                <code>remaining()</code>
-	 */
-	public LongBuffer get(long[] dest) {
-		return get(dest, 0, dest.length);
-	}
-
-	/**
-	 * Reads <code>long</code>s from the current position into the specified
-	 * long array, starting from the specified offset, and increase the position
-	 * by the number of <code>long</code>s read.
-	 * 
-	 * @param dest
-	 *            The target long array
-	 * @param off
-	 *            The offset of the long array, must be no less than zero and no
-	 *            greater than <code>dest.length</code>
-	 * @param len
-	 *            The number of <code>long</code>s to read, must be no less
-	 *            than zero and no greater than <code>dest.length - off</code>
-	 * @return This buffer
-	 * @exception IndexOutOfBoundsException
-	 *                If either <code>off</code> or <code>len</code> is
-	 *                invalid
-	 * @exception BufferUnderflowException
-	 *                If <code>len</code> is greater than
-	 *                <code>remaining()</code>
-	 */
-	public LongBuffer get(long[] dest, int off, int len) {
+    /**
+     * Creates a long buffer based on a new allocated long array.
+     * 
+     * @param capacity
+     *            The capacity of the new buffer
+     * @return The created long buffer
+     * @throws IllegalArgumentException
+     *             If <code>capacity</code> is less than zero
+     */
+    public static LongBuffer allocate(int capacity) {
+        if (capacity < 0) {
+            throw new IllegalArgumentException();
+        }
+        return BufferFactory.newLongBuffer(capacity);
+    }
+
+    /**
+     * Creates a new long buffer by wrapping the given long array.
+     * <p>
+     * Calling this method has the same effect as
+     * <code>wrap(array, 0, array.length)</code>.
+     * </p>
+     * 
+     * @param array
+     *            The long array which the new buffer will be based on
+     * @return The created long buffer
+     */
+    public static LongBuffer wrap(long[] array) {
+        return wrap(array, 0, array.length);
+    }
+
+    /**
+     * Creates new a long buffer by wrapping the given long array.
+     * <p>
+     * The new buffer's position will be <code>start</code>, limit will be
+     * <code>start + len</code>, capacity will be the length of the array.
+     * </p>
+     * 
+     * @param array
+     *            The long array which the new buffer will be based on
+     * @param start
+     *            The start index, must be no less than zero and no greater than
+     *            <code>array.length</code>
+     * @param len
+     *            The length, must be no less than zero and no greater than
+     *            <code>array.length - start</code>
+     * @return The created long buffer
+     * @exception IndexOutOfBoundsException
+     *                If either <code>start</code> or <code>len</code> is
+     *                invalid
+     */
+    public static LongBuffer wrap(long[] array, int start, int len) {
+        if (array == null) {
+            throw new NullPointerException();
+        }
+        if (start < 0 || len < 0 || (long) len + (long) start > array.length) {
+            throw new IndexOutOfBoundsException();
+        }
+
+        LongBuffer buf = BufferFactory.newLongBuffer(array);
+        buf.position = start;
+        buf.limit = start + len;
+
+        return buf;
+    }
+
+    /**
+     * Constructs a <code>LongBuffer</code> with given capacity.
+     * 
+     * @param capacity
+     *            The capacity of the buffer
+     */
+    LongBuffer(int capacity) {
+        super(capacity);
+    }
+
+    /**
+     * Returns the long array which this buffer is based on, if there's one.
+     * 
+     * @return The long array which this buffer is based on
+     * @exception ReadOnlyBufferException
+     *                If this buffer is based on an array, but it is readonly
+     * @exception UnsupportedOperationException
+     *                If this buffer is not based on an array
+     */
+    public final long[] array() {
+        return protectedArray();
+    }
+
+    /**
+     * Returns the offset of the long array which this buffer is based on, if
+     * there's one.
+     * <p>
+     * The offset is the index of the array corresponds to the zero position of
+     * the buffer.
+     * </p>
+     * 
+     * @return The offset of the long array which this buffer is based on
+     * @exception ReadOnlyBufferException
+     *                If this buffer is based on an array, but it is readonly
+     * @exception UnsupportedOperationException
+     *                If this buffer is not based on an array
+     */
+    public final int arrayOffset() {
+        return protectedArrayOffset();
+    }
+
+    /**
+     * Returns a readonly buffer that shares content with this buffer.
+     * <p>
+     * The returned buffer is guaranteed to be a new instance, even this buffer
+     * is readonly itself. The new buffer's position, limit, capacity and mark
+     * are the same as this buffer.
+     * </p>
+     * <p>
+     * The new buffer shares content with this buffer, which means this buffer's
+     * change of content will be visible to the new buffer. The two buffer's
+     * position, limit and mark are independent.
+     * </p>
+     * 
+     * @return A readonly version of this buffer.
+     */
+    public abstract LongBuffer asReadOnlyBuffer();
+
+    /**
+     * Compacts this long buffer.
+     * <p>
+     * The remaining <code>long</code>s will be moved to the head of the
+     * buffer, staring from position zero. Then the position is set to
+     * <code>remaining()</code>; the limit is set to capacity; the mark is
+     * cleared.
+     * </p>
+     * 
+     * @return This buffer
+     * @exception ReadOnlyBufferException
+     *                If no changes may be made to the contents of this buffer
+     */
+    public abstract LongBuffer compact();
+
+    /**
+     * Compare the remaining <code>long</code>s of this buffer to another
+     * long buffer's remaining <code>long</code>s.
+     * 
+     * @param otherBuffer
+     *            Another long buffer
+     * @return a negative value if this is less than <code>other</code>; 0 if
+     *         this equals to <code>other</code>; a positive value if this is
+     *         greater than <code>other</code>
+     * @exception ClassCastException
+     *                If <code>other</code> is not a long buffer
+     */
+    public int compareTo(LongBuffer otherBuffer) {
+        int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
+                : otherBuffer.remaining();
+        int thisPos = position;
+        int otherPos = otherBuffer.position;
+        long thisByte, otherByte;
+        while (compareRemaining > 0) {
+            thisByte = get(thisPos);
+            otherByte = otherBuffer.get(otherPos);
+            if (thisByte != otherByte) {
+                return thisByte < otherByte ? -1 : 1;
+            }
+            thisPos++;
+            otherPos++;
+            compareRemaining--;
+        }
+        return remaining() - otherBuffer.remaining();
+    }
+
+    /**
+     * Returns a duplicated buffer that shares content with this buffer.
+     * <p>
+     * The duplicated buffer's position, limit, capacity and mark are the same
+     * as this buffer. The duplicated buffer's readonly property and byte order
+     * are same as this buffer too.
+     * </p>
+     * <p>
+     * The new buffer shares content with this buffer, which means either
+     * buffer's change of content will be visible to the other. The two buffer's
+     * position, limit and mark are independent.
+     * </p>
+     * 
+     * @return A duplicated buffer that shares content with this buffer.
+     */
+    public abstract LongBuffer duplicate();
+
+    /**
+     * Tests whether this long buffer equals to another object.
+     * <p>
+     * If <code>other</code> is not a long buffer, then false is returned.
+     * </p>
+     * <p>
+     * Two long buffers are equals if, and only if, their remaining
+     * <code>long</code>s are exactly the same. Position, limit, capacity and
+     * mark are not considered.
+     * </p>
+     * 
+     * @param other
+     *            the object to be compared against
+     * @return Whether this long buffer equals to another object.
+     */
+    @Override
+    public boolean equals(Object other) {
+        if (!(other instanceof LongBuffer)) {
+            return false;
+        }
+        LongBuffer otherBuffer = (LongBuffer) other;
+
+        if (remaining() != otherBuffer.remaining()) {
+            return false;
+        }
+
+        int myPosition = position;
+        int otherPosition = otherBuffer.position;
+        boolean equalSoFar = true;
+        while (equalSoFar && (myPosition < limit)) {
+            equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++);
+        }
+
+        return equalSoFar;
+    }
+
+    /**
+     * Returns the long at the current position and increase the position by 1.
+     * 
+     * @return The long at the current position.
+     * @exception BufferUnderflowException
+     *                If the position is equal or greater than limit
+     */
+    public abstract long get();
+
+    /**
+     * Reads <code>long</code>s from the current position into the specified
+     * long array and increase the position by the number of <code>long</code>s
+     * read.
+     * <p>
+     * Calling this method has the same effect as
+     * <code>get(dest, 0, dest.length)</code>.
+     * </p>
+     * 
+     * @param dest
+     *            The destination long array
+     * @return This buffer
+     * @exception BufferUnderflowException
+     *                if <code>dest.length</code> is greater than
+     *                <code>remaining()</code>
+     */
+    public LongBuffer get(long[] dest) {
+        return get(dest, 0, dest.length);
+    }
+
+    /**
+     * Reads <code>long</code>s from the current position into the specified
+     * long array, starting from the specified offset, and increase the position
+     * by the number of <code>long</code>s read.
+     * 
+     * @param dest
+     *            The target long array
+     * @param off
+     *            The offset of the long array, must be no less than zero and no
+     *            greater than <code>dest.length</code>
+     * @param len
+     *            The number of <code>long</code>s to read, must be no less
+     *            than zero and no greater than <code>dest.length - off</code>
+     * @return This buffer
+     * @exception IndexOutOfBoundsException
+     *                If either <code>off</code> or <code>len</code> is
+     *                invalid
+     * @exception BufferUnderflowException
+     *                If <code>len</code> is greater than
+     *                <code>remaining()</code>
+     */
+    public LongBuffer get(long[] dest, int off, int len) {
         int length = dest.length;
-        if (off < 0 || len < 0 || (long)len + (long)off > length) {
+        if (off < 0 || len < 0 || (long) len + (long) off > length) {
             throw new IndexOutOfBoundsException();
         }
-        
-		if (len > remaining()) {
-			throw new BufferUnderflowException();
-		}
-		for (int i = off; i < off + len; i++) {
-			dest[i] = get();
-		}
-		return this;
-	}
-
-	/**
-	 * Returns a long at the specified index, and the position is not changed.
-	 * 
-	 * @param index
-	 *            The index, must be no less than zero and less than limit
-	 * @return A long at the specified index.
-	 * @exception IndexOutOfBoundsException
-	 *                If index is invalid
-	 */
-	public abstract long get(int index);
-
-	/**
-	 * Returns whether this buffer is based on a long array and is read/write.
-	 * <p>
-	 * If this buffer is readonly, then false is returned.
-	 * </p>
-	 * 
-	 * @return Whether this buffer is based on a long array and is read/write.
-	 */
-	public final boolean hasArray() {
-		return protectedHasArray();
-	}
-
-	/**
-	 * Hash code is calculated from the remaining <code>long</code>s.
-	 * <p>
-	 * Position, limit, capacity and mark don't affect the hash code.
-	 * </p>
-	 * 
-	 * @return The hash code calculated from the remaining <code>long</code>s.
-	 */
-	public int hashCode() {
-		int myPosition = position;
-		int hash = 0;
-		long l;
-		while (myPosition < limit) {
-			l = get(myPosition++);
-			hash = hash + ((int) l) ^ ((int) (l >> 32));
-		}
-		return hash;
-	}
-
-	/**
-	 * Returns true if this buffer is direct.
-	 * <p>
-	 * A direct buffer will try its best to take advantage of native memory APIs
-	 * and it may not stay in java heap, thus not affected by GC.
-	 * </p>
-	 * <p>
-	 * A long buffer is direct, if it is based on a byte buffer and the byte
-	 * buffer is direct.
-	 * </p>
-	 * 
-	 * @return True if this buffer is direct.
-	 */
-	public abstract boolean isDirect();
-
-	/**
-	 * Returns the byte order used by this buffer when converting
-	 * <code>long</code>s from/to <code>byte</code>s.
-	 * <p>
-	 * If this buffer is not based on a byte buffer, then always return the
-	 * platform's native byte order.
-	 * </p>
-	 * 
-	 * @return The byte order used by this buffer when converting
-	 *         <code>long</code>s from/to <code>byte</code>s.
-	 */
-	public abstract ByteOrder order();
-
-	/**
-	 * Child class implements this method to realize <code>array()</code>.
-	 * 
-	 * @return see <code>array()</code>
-	 */
-	abstract long[] protectedArray();
-
-	/**
-	 * Child class implements this method to realize <code>arrayOffset()</code>.
-	 * 
-	 * @return see <code>arrayOffset()</code>
-	 */
-	abstract int protectedArrayOffset();
-
-	/**
-	 * Child class implements this method to realize <code>hasArray()</code>.
-	 * 
-	 * @return see <code>hasArray()</code>
-	 */
-	abstract boolean protectedHasArray();
-
-	/**
-	 * Writes the given long to the current position and increase the position
-	 * by 1.
-	 * 
-	 * @param l
-	 *            The long to write
-	 * @return This buffer
-	 * @exception BufferOverflowException
-	 *                If position is equal or greater than limit
-	 * @exception ReadOnlyBufferException
-	 *                If no changes may be made to the contents of this buffer
-	 */
-	public abstract LongBuffer put(long l);
-
-	/**
-	 * Writes <code>long</code>s in the given long array to the current
-	 * position and increase the position by the number of <code>long</code>s
-	 * written.
-	 * <p>
-	 * Calling this method has the same effect as
-	 * <code>put(src, 0, src.length)</code>.
-	 * </p>
-	 * 
-	 * @param src
-	 *            The source long array
-	 * @return This buffer
-	 * @exception BufferOverflowException
-	 *                If <code>remaining()</code> is less than
-	 *                <code>src.length</code>
-	 * @exception ReadOnlyBufferException
-	 *                If no changes may be made to the contents of this buffer
-	 */
-	public final LongBuffer put(long[] src) {
-		return put(src, 0, src.length);
-	}
-
-	/**
-	 * Writes <code>long</code>s in the given long array, starting from the
-	 * specified offset, to the current position and increase the position by
-	 * the number of <code>long</code>s written.
-	 * 
-	 * @param src
-	 *            The source long array
-	 * @param off
-	 *            The offset of long array, must be no less than zero and no
-	 *            greater than <code>src.length</code>
-	 * @param len
-	 *            The number of <code>long</code>s to write, must be no less
-	 *            than zero and no greater than <code>src.length - off</code>
-	 * @return This buffer
-	 * @exception BufferOverflowException
-	 *                If <code>remaining()</code> is less than
-	 *                <code>len</code>
-	 * @exception IndexOutOfBoundsException
-	 *                If either <code>off</code> or <code>len</code> is
-	 *                invalid
-	 * @exception ReadOnlyBufferException
-	 *                If no changes may be made to the contents of this buffer
-	 */
-	public LongBuffer put(long[] src, int off, int len) {
+
+        if (len > remaining()) {
+            throw new BufferUnderflowException();
+        }
+        for (int i = off; i < off + len; i++) {
+            dest[i] = get();
+        }
+        return this;
+    }
+
+    /**
+     * Returns a long at the specified index, and the position is not changed.
+     * 
+     * @param index
+     *            The index, must be no less than zero and less than limit
+     * @return A long at the specified index.
+     * @exception IndexOutOfBoundsException
+     *                If index is invalid
+     */
+    public abstract long get(int index);
+
+    /**
+     * Returns whether this buffer is based on a long array and is read/write.
+     * <p>
+     * If this buffer is readonly, then false is returned.
+     * </p>
+     * 
+     * @return Whether this buffer is based on a long array and is read/write.
+     */
+    public final boolean hasArray() {
+        return protectedHasArray();
+    }
+
+    /**
+     * Hash code is calculated from the remaining <code>long</code>s.
+     * <p>
+     * Position, limit, capacity and mark don't affect the hash code.
+     * </p>
+     * 
+     * @return The hash code calculated from the remaining <code>long</code>s.
+     */
+    @Override
+    public int hashCode() {
+        int myPosition = position;
+        int hash = 0;
+        long l;
+        while (myPosition < limit) {
+            l = get(myPosition++);
+            hash = hash + ((int) l) ^ ((int) (l >> 32));
+        }
+        return hash;
+    }
+
+    /**
+     * Returns true if this buffer is direct.
+     * <p>
+     * A direct buffer will try its best to take advantage of native memory APIs
+     * and it may not stay in java heap, thus not affected by GC.
+     * </p>
+     * <p>
+     * A long buffer is direct, if it is based on a byte buffer and the byte
+     * buffer is direct.
+     * </p>
+     * 
+     * @return True if this buffer is direct.
+     */
+    public abstract boolean isDirect();
+
+    /**
+     * Returns the byte order used by this buffer when converting
+     * <code>long</code>s from/to <code>byte</code>s.
+     * <p>
+     * If this buffer is not based on a byte buffer, then always return the
+     * platform's native byte order.
+     * </p>
+     * 
+     * @return The byte order used by this buffer when converting
+     *         <code>long</code>s from/to <code>byte</code>s.
+     */
+    public abstract ByteOrder order();
+
+    /**
+     * Child class implements this method to realize <code>array()</code>.
+     * 
+     * @return see <code>array()</code>
+     */
+    abstract long[] protectedArray();
+
+    /**
+     * Child class implements this method to realize <code>arrayOffset()</code>.
+     * 
+     * @return see <code>arrayOffset()</code>
+     */
+    abstract int protectedArrayOffset();
+
+    /**
+     * Child class implements this method to realize <code>hasArray()</code>.
+     * 
+     * @return see <code>hasArray()</code>
+     */
+    abstract boolean protectedHasArray();
+
+    /**
+     * Writes the given long to the current position and increase the position
+     * by 1.
+     * 
+     * @param l
+     *            The long to write
+     * @return This buffer
+     * @exception BufferOverflowException
+     *                If position is equal or greater than limit
+     * @exception ReadOnlyBufferException
+     *                If no changes may be made to the contents of this buffer
+     */
+    public abstract LongBuffer put(long l);
+
+    /**
+     * Writes <code>long</code>s in the given long array to the current
+     * position and increase the position by the number of <code>long</code>s
+     * written.
+     * <p>
+     * Calling this method has the same effect as
+     * <code>put(src, 0, src.length)</code>.
+     * </p>
+     * 
+     * @param src
+     *            The source long array
+     * @return This buffer
+     * @exception BufferOverflowException
+     *                If <code>remaining()</code> is less than
+     *                <code>src.length</code>
+     * @exception ReadOnlyBufferException
+     *                If no changes may be made to the contents of this buffer
+     */
+    public final LongBuffer put(long[] src) {
+        return put(src, 0, src.length);
+    }
+
+    /**
+     * Writes <code>long</code>s in the given long array, starting from the
+     * specified offset, to the current position and increase the position by
+     * the number of <code>long</code>s written.
+     * 
+     * @param src
+     *            The source long array
+     * @param off
+     *            The offset of long array, must be no less than zero and no
+     *            greater than <code>src.length</code>
+     * @param len
+     *            The number of <code>long</code>s to write, must be no less
+     *            than zero and no greater than <code>src.length - off</code>
+     * @return This buffer
+     * @exception BufferOverflowException
+     *                If <code>remaining()</code> is less than
+     *                <code>len</code>
+     * @exception IndexOutOfBoundsException
+     *                If either <code>off</code> or <code>len</code> is
+     *                invalid
+     * @exception ReadOnlyBufferException
+     *                If no changes may be made to the contents of this buffer
+     */
+    public LongBuffer put(long[] src, int off, int len) {
         int length = src.length;
-        if (off < 0 || len < 0 || (long)len + (long)off > length) {
+        if (off < 0 || len < 0 || (long) len + (long) off > length) {
             throw new IndexOutOfBoundsException();
         }
-        
-		if (len > remaining()) {
-			throw new BufferOverflowException();
-		}
-		for (int i = off; i < off + len; i++) {
-			put(src[i]);
-		}
-		return this;
-	}
-
-	/**
-	 * Writes all the remaining <code>long</code>s of the <code>src</code>
-	 * long buffer to this buffer's current position, and increase both buffers'
-	 * position by the number of <code>long</code>s copied.
-	 * 
-	 * @param src
-	 *            The source long buffer
-	 * @return This buffer
-	 * @exception BufferOverflowException
-	 *                If <code>src.remaining()</code> is greater than this
-	 *                buffer's <code>remaining()</code>
-	 * @exception IllegalArgumentException
-	 *                If <code>src</code> is this buffer
-	 * @exception ReadOnlyBufferException
-	 *                If no changes may be made to the contents of this buffer
-	 */
-	public LongBuffer put(LongBuffer src) {
-		if (src == this) {
-			throw new IllegalArgumentException();
-		}
-		if (src.remaining() > remaining()) {
-			throw new BufferOverflowException();
-		}
+
+        if (len > remaining()) {
+            throw new BufferOverflowException();
+        }
+        for (int i = off; i < off + len; i++) {
+            put(src[i]);
+        }
+        return this;
+    }
+
+    /**
+     * Writes all the remaining <code>long</code>s of the <code>src</code>
+     * long buffer to this buffer's current position, and increase both buffers'
+     * position by the number of <code>long</code>s copied.
+     * 
+     * @param src
+     *            The source long buffer
+     * @return This buffer
+     * @exception BufferOverflowException
+     *                If <code>src.remaining()</code> is greater than this
+     *                buffer's <code>remaining()</code>
+     * @exception IllegalArgumentException
+     *                If <code>src</code> is this buffer
+     * @exception ReadOnlyBufferException
+     *                If no changes may be made to the contents of this buffer
+     */
+    public LongBuffer put(LongBuffer src) {
+        if (src == this) {
+            throw new IllegalArgumentException();
+        }
+        if (src.remaining() > remaining()) {
+            throw new BufferOverflowException();
+        }
         long[] contents = new long[src.remaining()];
         src.get(contents);
         put(contents);
-		return this;
-	}
+        return this;
+    }
 
-	/**
-	 * Write a long to the specified index of this buffer and the position is
-	 * not changed.
-	 * 
-	 * @param index
-	 *            The index, must be no less than zero and less than the limit
-	 * @param l
-	 *            The long to write
-	 * @return This buffer
-	 * @exception IndexOutOfBoundsException
-	 *                If index is invalid
-	 * @exception ReadOnlyBufferException
-	 *                If no changes may be made to the contents of this buffer
-	 */
-	public abstract LongBuffer put(int index, long l);
-
-	/**
-	 * Returns a sliced buffer that shares content with this buffer.
-	 * <p>
-	 * The sliced buffer's capacity will be this buffer's
-	 * <code>remaining()</code>, and its zero position will correspond to
-	 * this buffer's current position. The new buffer's position will be 0,
-	 * limit will be its capacity, and its mark is unset. The new buffer's
-	 * readonly property and byte order are same as this buffer.
-	 * </p>
-	 * <p>
-	 * The new buffer shares content with this buffer, which means either
-	 * buffer's change of content will be visible to the other. The two buffer's
-	 * position, limit and mark are independent.
-	 * </p>
-	 * 
-	 * @return A sliced buffer that shares content with this buffer.
-	 */
-	public abstract LongBuffer slice();
-
-	/**
-	 * Returns a string represents the state of this long buffer.
-	 * 
-	 * @return A string represents the state of this long buffer.
-	 */
-	public String toString() {
-		StringBuffer buf = new StringBuffer();
-		buf.append(getClass().getName());
-		buf.append(", status: capacity="); //$NON-NLS-1$
-		buf.append(capacity());
-		buf.append(" position="); //$NON-NLS-1$
-		buf.append(position());
-		buf.append(" limit="); //$NON-NLS-1$
-		buf.append(limit());
-		return buf.toString();
-	}
+    /**
+     * Write a long to the specified index of this buffer and the position is
+     * not changed.
+     * 
+     * @param index
+     *            The index, must be no less than zero and less than the limit
+     * @param l
+     *            The long to write
+     * @return This buffer
+     * @exception IndexOutOfBoundsException
+     *                If index is invalid
+     * @exception ReadOnlyBufferException
+     *                If no changes may be made to the contents of this buffer
+     */
+    public abstract LongBuffer put(int index, long l);
+
+    /**
+     * Returns a sliced buffer that shares content with this buffer.
+     * <p>
+     * The sliced buffer's capacity will be this buffer's
+     * <code>remaining()</code>, and its zero position will correspond to
+     * this buffer's current position. The new buffer's position will be 0,
+     * limit will be its capacity, and its mark is unset. The new buffer's
+     * readonly property and byte order are same as this buffer.
+     * </p>
+     * <p>
+     * The new buffer shares content with this buffer, which means either
+     * buffer's change of content will be visible to the other. The two buffer's
+     * position, limit and mark are independent.
+     * </p>
+     * 
+     * @return A sliced buffer that shares content with this buffer.
+     */
+    public abstract LongBuffer slice();
+
+    /**
+     * Returns a string represents the state of this long buffer.
+     * 
+     * @return A string represents the state of this long buffer.
+     */
+    @Override
+    public String toString() {
+        StringBuffer buf = new StringBuffer();
+        buf.append(getClass().getName());
+        buf.append(", status: capacity="); //$NON-NLS-1$
+        buf.append(capacity());
+        buf.append(" position="); //$NON-NLS-1$
+        buf.append(position());
+        buf.append(" limit="); //$NON-NLS-1$
+        buf.append(limit());
+        return buf.toString();
+    }
 }



Mime
View raw message