Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 59431 invoked from network); 21 Sep 2007 13:06:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Sep 2007 13:06:55 -0000 Received: (qmail 19061 invoked by uid 500); 21 Sep 2007 13:06:46 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 19044 invoked by uid 500); 21 Sep 2007 13:06:46 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 19035 invoked by uid 99); 21 Sep 2007 13:06:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Sep 2007 06:06:46 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Sep 2007 13:06:52 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 754431A9851; Fri, 21 Sep 2007 06:06:10 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r578091 [6/8] - /harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ Date: Fri, 21 Sep 2007 13:06:01 -0000 To: commits@harmony.apache.org From: tellison@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070921130610.754431A9851@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/LongBuffer.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/LongBuffer.java?rev=578091&r1=578090&r2=578091&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/LongBuffer.java (original) +++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/LongBuffer.java Fri Sep 21 06:05:59 2007 @@ -31,538 +31,542 @@ * *

*/ -public abstract class LongBuffer extends Buffer implements Comparable { +public abstract class LongBuffer extends Buffer implements + Comparable { - /** - * 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 capacity 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. - *

- * Calling this method has the same effect as - * wrap(array, 0, array.length). - *

- * - * @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. - *

- * The new buffer's position will be start, limit will be - * start + len, capacity will be the length of the array. - *

- * - * @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 - * array.length - * @param len - * The length, must be no less than zero and no greater than - * array.length - start - * @return The created long buffer - * @exception IndexOutOfBoundsException - * If either start or len 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 LongBuffer 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. - *

- * The offset is the index of the array corresponds to the zero position of - * the buffer. - *

- * - * @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. - *

- * 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. - *

- *

- * 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. - *

- * - * @return A readonly version of this buffer. - */ - public abstract LongBuffer asReadOnlyBuffer(); - - /** - * Compacts this long buffer. - *

- * The remaining longs will be moved to the head of the - * buffer, staring from position zero. Then the position is set to - * remaining(); the limit is set to capacity; the mark is - * cleared. - *

- * - * @return This buffer - * @exception ReadOnlyBufferException - * If no changes may be made to the contents of this buffer - */ - public abstract LongBuffer compact(); - - /** - * Compare the remaining longs of this buffer to another - * long buffer's remaining longs. - * - * @param otherBuffer - * Another long buffer - * @return a negative value if this is less than other; 0 if - * this equals to other; a positive value if this is - * greater than other - * @exception ClassCastException - * If other 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. - *

- * 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. - *

- *

- * 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. - *

- * - * @return A duplicated buffer that shares content with this buffer. - */ - public abstract LongBuffer duplicate(); - - /** - * Tests whether this long buffer equals to another object. - *

- * If other is not a long buffer, then false is returned. - *

- *

- * Two long buffers are equals if, and only if, their remaining - * longs are exactly the same. Position, limit, capacity and - * mark are not considered. - *

- * - * @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 longs from the current position into the specified - * long array and increase the position by the number of longs - * read. - *

- * Calling this method has the same effect as - * get(dest, 0, dest.length). - *

- * - * @param dest - * The destination long array - * @return This buffer - * @exception BufferUnderflowException - * if dest.length is greater than - * remaining() - */ - public LongBuffer get(long[] dest) { - return get(dest, 0, dest.length); - } - - /** - * Reads longs from the current position into the specified - * long array, starting from the specified offset, and increase the position - * by the number of longs 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 dest.length - * @param len - * The number of longs to read, must be no less - * than zero and no greater than dest.length - off - * @return This buffer - * @exception IndexOutOfBoundsException - * If either off or len is - * invalid - * @exception BufferUnderflowException - * If len is greater than - * remaining() - */ - 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 capacity 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. + *

+ * Calling this method has the same effect as + * wrap(array, 0, array.length). + *

+ * + * @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. + *

+ * The new buffer's position will be start, limit will be + * start + len, capacity will be the length of the array. + *

+ * + * @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 + * array.length + * @param len + * The length, must be no less than zero and no greater than + * array.length - start + * @return The created long buffer + * @exception IndexOutOfBoundsException + * If either start or len 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 LongBuffer 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. + *

+ * The offset is the index of the array corresponds to the zero position of + * the buffer. + *

+ * + * @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. + *

+ * 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. + *

+ *

+ * 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. + *

+ * + * @return A readonly version of this buffer. + */ + public abstract LongBuffer asReadOnlyBuffer(); + + /** + * Compacts this long buffer. + *

+ * The remaining longs will be moved to the head of the + * buffer, staring from position zero. Then the position is set to + * remaining(); the limit is set to capacity; the mark is + * cleared. + *

+ * + * @return This buffer + * @exception ReadOnlyBufferException + * If no changes may be made to the contents of this buffer + */ + public abstract LongBuffer compact(); + + /** + * Compare the remaining longs of this buffer to another + * long buffer's remaining longs. + * + * @param otherBuffer + * Another long buffer + * @return a negative value if this is less than other; 0 if + * this equals to other; a positive value if this is + * greater than other + * @exception ClassCastException + * If other 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. + *

+ * 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. + *

+ *

+ * 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. + *

+ * + * @return A duplicated buffer that shares content with this buffer. + */ + public abstract LongBuffer duplicate(); + + /** + * Tests whether this long buffer equals to another object. + *

+ * If other is not a long buffer, then false is returned. + *

+ *

+ * Two long buffers are equals if, and only if, their remaining + * longs are exactly the same. Position, limit, capacity and + * mark are not considered. + *

+ * + * @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 longs from the current position into the specified + * long array and increase the position by the number of longs + * read. + *

+ * Calling this method has the same effect as + * get(dest, 0, dest.length). + *

+ * + * @param dest + * The destination long array + * @return This buffer + * @exception BufferUnderflowException + * if dest.length is greater than + * remaining() + */ + public LongBuffer get(long[] dest) { + return get(dest, 0, dest.length); + } + + /** + * Reads longs from the current position into the specified + * long array, starting from the specified offset, and increase the position + * by the number of longs 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 dest.length + * @param len + * The number of longs to read, must be no less + * than zero and no greater than dest.length - off + * @return This buffer + * @exception IndexOutOfBoundsException + * If either off or len is + * invalid + * @exception BufferUnderflowException + * If len is greater than + * remaining() + */ + 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. - *

- * If this buffer is readonly, then false is returned. - *

- * - * @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 longs. - *

- * Position, limit, capacity and mark don't affect the hash code. - *

- * - * @return The hash code calculated from the remaining longs. - */ - 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. - *

- * 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. - *

- *

- * A long buffer is direct, if it is based on a byte buffer and the byte - * buffer is direct. - *

- * - * @return True if this buffer is direct. - */ - public abstract boolean isDirect(); - - /** - * Returns the byte order used by this buffer when converting - * longs from/to bytes. - *

- * If this buffer is not based on a byte buffer, then always return the - * platform's native byte order. - *

- * - * @return The byte order used by this buffer when converting - * longs from/to bytes. - */ - public abstract ByteOrder order(); - - /** - * Child class implements this method to realize array(). - * - * @return see array() - */ - abstract long[] protectedArray(); - - /** - * Child class implements this method to realize arrayOffset(). - * - * @return see arrayOffset() - */ - abstract int protectedArrayOffset(); - - /** - * Child class implements this method to realize hasArray(). - * - * @return see hasArray() - */ - 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 longs in the given long array to the current - * position and increase the position by the number of longs - * written. - *

- * Calling this method has the same effect as - * put(src, 0, src.length). - *

- * - * @param src - * The source long array - * @return This buffer - * @exception BufferOverflowException - * If remaining() is less than - * src.length - * @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 longs in the given long array, starting from the - * specified offset, to the current position and increase the position by - * the number of longs written. - * - * @param src - * The source long array - * @param off - * The offset of long array, must be no less than zero and no - * greater than src.length - * @param len - * The number of longs to write, must be no less - * than zero and no greater than src.length - off - * @return This buffer - * @exception BufferOverflowException - * If remaining() is less than - * len - * @exception IndexOutOfBoundsException - * If either off or len 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. + *

+ * If this buffer is readonly, then false is returned. + *

+ * + * @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 longs. + *

+ * Position, limit, capacity and mark don't affect the hash code. + *

+ * + * @return The hash code calculated from the remaining longs. + */ + @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. + *

+ * 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. + *

+ *

+ * A long buffer is direct, if it is based on a byte buffer and the byte + * buffer is direct. + *

+ * + * @return True if this buffer is direct. + */ + public abstract boolean isDirect(); + + /** + * Returns the byte order used by this buffer when converting + * longs from/to bytes. + *

+ * If this buffer is not based on a byte buffer, then always return the + * platform's native byte order. + *

+ * + * @return The byte order used by this buffer when converting + * longs from/to bytes. + */ + public abstract ByteOrder order(); + + /** + * Child class implements this method to realize array(). + * + * @return see array() + */ + abstract long[] protectedArray(); + + /** + * Child class implements this method to realize arrayOffset(). + * + * @return see arrayOffset() + */ + abstract int protectedArrayOffset(); + + /** + * Child class implements this method to realize hasArray(). + * + * @return see hasArray() + */ + 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 longs in the given long array to the current + * position and increase the position by the number of longs + * written. + *

+ * Calling this method has the same effect as + * put(src, 0, src.length). + *

+ * + * @param src + * The source long array + * @return This buffer + * @exception BufferOverflowException + * If remaining() is less than + * src.length + * @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 longs in the given long array, starting from the + * specified offset, to the current position and increase the position by + * the number of longs written. + * + * @param src + * The source long array + * @param off + * The offset of long array, must be no less than zero and no + * greater than src.length + * @param len + * The number of longs to write, must be no less + * than zero and no greater than src.length - off + * @return This buffer + * @exception BufferOverflowException + * If remaining() is less than + * len + * @exception IndexOutOfBoundsException + * If either off or len 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 longs of the src - * long buffer to this buffer's current position, and increase both buffers' - * position by the number of longs copied. - * - * @param src - * The source long buffer - * @return This buffer - * @exception BufferOverflowException - * If src.remaining() is greater than this - * buffer's remaining() - * @exception IllegalArgumentException - * If src 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 longs of the src + * long buffer to this buffer's current position, and increase both buffers' + * position by the number of longs copied. + * + * @param src + * The source long buffer + * @return This buffer + * @exception BufferOverflowException + * If src.remaining() is greater than this + * buffer's remaining() + * @exception IllegalArgumentException + * If src 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. - *

- * The sliced buffer's capacity will be this buffer's - * remaining(), 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. - *

- *

- * 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. - *

- * - * @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. + *

+ * The sliced buffer's capacity will be this buffer's + * remaining(), 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. + *

+ *

+ * 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. + *

+ * + * @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(); + } } Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/LongToByteBufferAdapter.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/LongToByteBufferAdapter.java?rev=578091&r1=578090&r2=578091&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/LongToByteBufferAdapter.java (original) +++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/LongToByteBufferAdapter.java Fri Sep 21 06:05:59 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 long buffer. *

@@ -35,162 +34,172 @@ */ final class LongToByteBufferAdapter extends LongBuffer implements DirectBuffer { - static LongBuffer wrap(ByteBuffer byteBuffer) { - return new LongToByteBufferAdapter(byteBuffer.slice()); - } - - private final ByteBuffer byteBuffer; - - LongToByteBufferAdapter(ByteBuffer byteBuffer) { - super((byteBuffer.capacity() >> 3)); - 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 LongBuffer asReadOnlyBuffer() { - LongToByteBufferAdapter buf = new LongToByteBufferAdapter(byteBuffer - .asReadOnlyBuffer()); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - public LongBuffer compact() { - if (byteBuffer.isReadOnly()) { - throw new ReadOnlyBufferException(); - } - byteBuffer.limit(limit << 3); - byteBuffer.position(position << 3); - byteBuffer.compact(); - byteBuffer.clear(); - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - public LongBuffer duplicate() { - LongToByteBufferAdapter buf = new LongToByteBufferAdapter(byteBuffer - .duplicate()); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - public long get() { - if (position == limit) { - throw new BufferUnderflowException(); - } - return byteBuffer.getLong(position++ << 3); - } - - public long get(int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return byteBuffer.getLong(index << 3); - } - - public boolean isDirect() { - return byteBuffer.isDirect(); - } - - public boolean isReadOnly() { - return byteBuffer.isReadOnly(); - } - - public ByteOrder order() { - return byteBuffer.order(); - } - - protected long[] protectedArray() { - throw new UnsupportedOperationException(); - } - - protected int protectedArrayOffset() { - throw new UnsupportedOperationException(); - } - - protected boolean protectedHasArray() { - return false; - } - - public LongBuffer put(long c) { - if (position == limit) { - throw new BufferOverflowException(); - } - byteBuffer.putLong(position++ << 3, c); - return this; - } - - public LongBuffer put(int index, long c) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - byteBuffer.putLong(index << 3, c); - return this; - } - - public LongBuffer slice() { - byteBuffer.limit(limit << 3); - byteBuffer.position(position << 3); - LongBuffer result = new LongToByteBufferAdapter(byteBuffer.slice()); - byteBuffer.clear(); - return result; - } + static LongBuffer wrap(ByteBuffer byteBuffer) { + return new LongToByteBufferAdapter(byteBuffer.slice()); + } + + private final ByteBuffer byteBuffer; + + LongToByteBufferAdapter(ByteBuffer byteBuffer) { + super((byteBuffer.capacity() >> 3)); + 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 LongBuffer asReadOnlyBuffer() { + LongToByteBufferAdapter buf = new LongToByteBufferAdapter(byteBuffer + .asReadOnlyBuffer()); + buf.limit = limit; + buf.position = position; + buf.mark = mark; + return buf; + } + + @Override + public LongBuffer compact() { + if (byteBuffer.isReadOnly()) { + throw new ReadOnlyBufferException(); + } + byteBuffer.limit(limit << 3); + byteBuffer.position(position << 3); + byteBuffer.compact(); + byteBuffer.clear(); + position = limit - position; + limit = capacity; + mark = UNSET_MARK; + return this; + } + + @Override + public LongBuffer duplicate() { + LongToByteBufferAdapter buf = new LongToByteBufferAdapter(byteBuffer + .duplicate()); + buf.limit = limit; + buf.position = position; + buf.mark = mark; + return buf; + } + + @Override + public long get() { + if (position == limit) { + throw new BufferUnderflowException(); + } + return byteBuffer.getLong(position++ << 3); + } + + @Override + public long get(int index) { + if (index < 0 || index >= limit) { + throw new IndexOutOfBoundsException(); + } + return byteBuffer.getLong(index << 3); + } + + @Override + public boolean isDirect() { + return byteBuffer.isDirect(); + } + + @Override + public boolean isReadOnly() { + return byteBuffer.isReadOnly(); + } + + @Override + public ByteOrder order() { + return byteBuffer.order(); + } + + @Override + protected long[] protectedArray() { + throw new UnsupportedOperationException(); + } + + @Override + protected int protectedArrayOffset() { + throw new UnsupportedOperationException(); + } + + @Override + protected boolean protectedHasArray() { + return false; + } + + @Override + public LongBuffer put(long c) { + if (position == limit) { + throw new BufferOverflowException(); + } + byteBuffer.putLong(position++ << 3, c); + return this; + } + + @Override + public LongBuffer put(int index, long c) { + if (index < 0 || index >= limit) { + throw new IndexOutOfBoundsException(); + } + byteBuffer.putLong(index << 3, c); + return this; + } + + @Override + public LongBuffer slice() { + byteBuffer.limit(limit << 3); + byteBuffer.position(position << 3); + LongBuffer result = new LongToByteBufferAdapter(byteBuffer.slice()); + byteBuffer.clear(); + return result; + } } Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBuffer.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBuffer.java?rev=578091&r1=578090&r2=578091&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBuffer.java (original) +++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBuffer.java Fri Sep 21 06:05:59 2007 @@ -21,7 +21,6 @@ import org.apache.harmony.luni.platform.PlatformAddress; import org.apache.harmony.nio.internal.DirectBuffer; - /** * MappedByteBuffer is a special kind of direct byte buffer, * which maps a region of file to memory. @@ -58,37 +57,39 @@ super(capa); mapMode = mode; switch (mapMode) { - case IMemorySystem.MMAP_READ_ONLY: - wrapped = new ReadOnlyDirectByteBuffer(addr, capa, offset); - break; - case IMemorySystem.MMAP_READ_WRITE: - case IMemorySystem.MMAP_WRITE_COPY: - wrapped = new ReadWriteDirectByteBuffer(addr, capa, offset); - break; - default: - throw new IllegalArgumentException(); + case IMemorySystem.MMAP_READ_ONLY: + wrapped = new ReadOnlyDirectByteBuffer(addr, capa, offset); + break; + case IMemorySystem.MMAP_READ_WRITE: + case IMemorySystem.MMAP_WRITE_COPY: + wrapped = new ReadWriteDirectByteBuffer(addr, capa, offset); + break; + default: + throw new IllegalArgumentException(); } addr.autoFree(); } - /** - * Returns true if this buffer's content is loaded. - * - * @return True if this buffer's content is loaded. - */ - public final boolean isLoaded() { - return ((MappedPlatformAddress)((DirectBuffer) wrapped).getBaseAddress()).mmapIsLoaded(); - } - - /** - * Loads this buffer's content into memory. - * - * @return This buffer - */ - public final MappedByteBuffer load() { - ((MappedPlatformAddress)((DirectBuffer) wrapped).getBaseAddress()).mmapLoad(); - return this; - } + /** + * Returns true if this buffer's content is loaded. + * + * @return True if this buffer's content is loaded. + */ + public final boolean isLoaded() { + return ((MappedPlatformAddress) ((DirectBuffer) wrapped) + .getBaseAddress()).mmapIsLoaded(); + } + + /** + * Loads this buffer's content into memory. + * + * @return This buffer + */ + public final MappedByteBuffer load() { + ((MappedPlatformAddress) ((DirectBuffer) wrapped).getBaseAddress()) + .mmapLoad(); + return this; + } /** * Writes all changes of the buffer to the mapped file. @@ -100,7 +101,8 @@ */ public final MappedByteBuffer force() { if (mapMode == IMemorySystem.MMAP_READ_WRITE) { - ((MappedPlatformAddress)((DirectBuffer) wrapped).getBaseAddress()).mmapFlush(); + ((MappedPlatformAddress) ((DirectBuffer) wrapped).getBaseAddress()) + .mmapFlush(); } return this; } Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBufferAdapter.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBufferAdapter.java?rev=578091&r1=578090&r2=578091&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBufferAdapter.java (original) +++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBufferAdapter.java Fri Sep 21 06:05:59 2007 @@ -20,8 +20,8 @@ import org.apache.harmony.luni.platform.PlatformAddress; import org.apache.harmony.nio.internal.DirectBuffer; - -final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBuffer { +final class MappedByteBufferAdapter extends MappedByteBuffer implements + DirectBuffer { private static final int CHAR_SIZE = 2; @@ -34,280 +34,325 @@ private static final int FLOAT_SIZE = 4; private static final int DOUBLE_SIZE = 8; - + public MappedByteBufferAdapter(ByteBuffer buffer) { - super(buffer); - } + super(buffer); + } + + public MappedByteBufferAdapter(PlatformAddress addr, int capa, int offset, + int mode) { + super(addr, capa, offset, mode); + } + + @Override + public CharBuffer asCharBuffer() { + return this.wrapped.asCharBuffer(); + } + + @Override + public DoubleBuffer asDoubleBuffer() { + return this.wrapped.asDoubleBuffer(); + } + + @Override + public FloatBuffer asFloatBuffer() { + return this.wrapped.asFloatBuffer(); + } + + @Override + public IntBuffer asIntBuffer() { + return this.wrapped.asIntBuffer(); + } + + @Override + public LongBuffer asLongBuffer() { + return this.wrapped.asLongBuffer(); + } + + @Override + public ByteBuffer asReadOnlyBuffer() { + MappedByteBufferAdapter buf = new MappedByteBufferAdapter(this.wrapped + .asReadOnlyBuffer()); + buf.limit = this.limit; + buf.position = this.position; + buf.mark = this.mark; + return buf; + } + + @Override + public ShortBuffer asShortBuffer() { + return this.wrapped.asShortBuffer(); + } + + @Override + public ByteBuffer compact() { + if (this.wrapped.isReadOnly()) { + throw new ReadOnlyBufferException(); + } + this.wrapped.limit(this.limit); + this.wrapped.position(this.position); + this.wrapped.compact(); + this.wrapped.clear(); + this.position = this.limit - this.position; + this.limit = this.capacity; + this.mark = UNSET_MARK; + return this; + } + + @Override + public ByteBuffer duplicate() { + MappedByteBufferAdapter buf = new MappedByteBufferAdapter(this.wrapped + .duplicate()); + buf.limit = this.limit; + buf.position = this.position; + buf.mark = this.mark; + return buf; + } + + @Override + public byte get() { + byte result = this.wrapped.get(); + this.position++; + return result; + } + + @Override + public byte get(int index) { + return this.wrapped.get(index); + } + + @Override + public char getChar() { + char result = this.wrapped.getChar(); + this.position += CHAR_SIZE; + return result; + } + + @Override + public char getChar(int index) { + return this.wrapped.getChar(index); + } + + @Override + public double getDouble() { + double result = this.wrapped.getDouble(); + this.position += DOUBLE_SIZE; + return result; + } + + @Override + public double getDouble(int index) { + return this.wrapped.getDouble(index); + } + + public PlatformAddress getEffectiveAddress() { + return ((DirectBuffer) this.wrapped).getEffectiveAddress(); + } + + @Override + public float getFloat() { + float result = this.wrapped.getFloat(); + this.position += FLOAT_SIZE; + return result; + } + + @Override + public float getFloat(int index) { + return this.wrapped.getFloat(index); + } + + @Override + public int getInt() { + int result = this.wrapped.getInt(); + this.position += INTEGER_SIZE; + return result; + } + + @Override + public int getInt(int index) { + return this.wrapped.getInt(index); + } + + @Override + public long getLong() { + long result = this.wrapped.getLong(); + this.position += LONG_SIZE; + return result; + } + + @Override + public long getLong(int index) { + return this.wrapped.getLong(index); + } + + @Override + public short getShort() { + short result = this.wrapped.getShort(); + this.position += SHORT_SIZE; + return result; + } + + @Override + public short getShort(int index) { + return this.wrapped.getShort(index); + } + + @Override + public boolean isDirect() { + return true; + } + + @Override + public boolean isReadOnly() { + return this.wrapped.isReadOnly(); + } + + @Override + ByteBuffer orderImpl(ByteOrder byteOrder) { + super.orderImpl(byteOrder); + return this.wrapped.order(byteOrder); + } + + @Override + public ByteBuffer put(byte b) { + this.wrapped.put(b); + this.position++; + return this; + } + + @Override + public ByteBuffer put(byte[] src, int off, int len) { + this.wrapped.position(this.position); + this.wrapped.put(src, off, len); + this.position += len; + return this; + } + + @Override + public ByteBuffer put(int index, byte b) { + this.wrapped.put(index, b); + return this; + } + + @Override + public ByteBuffer putChar(char value) { + this.wrapped.putChar(value); + this.position += CHAR_SIZE; + return this; + } + + @Override + public ByteBuffer putChar(int index, char value) { + this.wrapped.putChar(index, value); + return this; + } + + @Override + public ByteBuffer putDouble(double value) { + this.wrapped.putDouble(value); + this.position += DOUBLE_SIZE; + return this; + } + + @Override + public ByteBuffer putDouble(int index, double value) { + this.wrapped.putDouble(index, value); + return this; + } + + @Override + public ByteBuffer putFloat(float value) { + this.wrapped.putFloat(value); + this.position += FLOAT_SIZE; + return this; + } + + @Override + public ByteBuffer putFloat(int index, float value) { + this.wrapped.putFloat(index, value); + return this; + } + + @Override + public ByteBuffer putInt(int index, int value) { + this.wrapped.putInt(index, value); + return this; + } + + @Override + public ByteBuffer putInt(int value) { + this.wrapped.putInt(value); + this.position += INTEGER_SIZE; + return this; + } + + @Override + public ByteBuffer putLong(int index, long value) { + this.wrapped.putLong(index, value); + return this; + } + + @Override + public ByteBuffer putLong(long value) { + this.wrapped.putLong(value); + this.position += LONG_SIZE; + return this; + } + + @Override + public ByteBuffer putShort(int index, short value) { + this.wrapped.putShort(index, value); + return this; + } + + @Override + public ByteBuffer putShort(short value) { + this.wrapped.putShort(value); + this.position += SHORT_SIZE; + return this; + } + + @Override + public ByteBuffer slice() { + this.wrapped.limit(this.limit); + this.wrapped.position(this.position); + MappedByteBufferAdapter result = new MappedByteBufferAdapter( + this.wrapped.slice()); + this.wrapped.clear(); + return result; + } + + @Override + byte[] protectedArray() { + return this.wrapped.protectedArray(); + } + + @Override + int protectedArrayOffset() { + return this.wrapped.protectedArrayOffset(); + } + + @Override + boolean protectedHasArray() { + return this.wrapped.protectedHasArray(); + } + + public PlatformAddress getBaseAddress() { + return this.wrapped.getBaseAddress(); + } + + public boolean isAddressValid() { + return this.wrapped.isAddressValid(); + } + + public void addressValidityCheck() { + this.wrapped.addressValidityCheck(); + } + + public void free() { + this.wrapped.free(); + } - public MappedByteBufferAdapter(PlatformAddress addr, int capa, int offset, - int mode) { - super(addr, capa, offset, mode); - } - - public CharBuffer asCharBuffer() { - return this.wrapped.asCharBuffer(); - } - - public DoubleBuffer asDoubleBuffer() { - return this.wrapped.asDoubleBuffer(); - } - - public FloatBuffer asFloatBuffer() { - return this.wrapped.asFloatBuffer(); - } - - public IntBuffer asIntBuffer() { - return this.wrapped.asIntBuffer(); - } - - public LongBuffer asLongBuffer() { - return this.wrapped.asLongBuffer(); - } - - public ByteBuffer asReadOnlyBuffer() { - MappedByteBufferAdapter buf = new MappedByteBufferAdapter(this.wrapped - .asReadOnlyBuffer()); - buf.limit = this.limit; - buf.position = this.position; - buf.mark = this.mark; - return buf; - } - - public ShortBuffer asShortBuffer() { - return this.wrapped.asShortBuffer(); - } - - public ByteBuffer compact() { - if (this.wrapped.isReadOnly()) { - throw new ReadOnlyBufferException(); - } - this.wrapped.limit(this.limit); - this.wrapped.position(this.position); - this.wrapped.compact(); - this.wrapped.clear(); - this.position = this.limit - this.position; - this.limit = this.capacity; - this.mark = UNSET_MARK; - return this; - } - - public ByteBuffer duplicate() { - MappedByteBufferAdapter buf = new MappedByteBufferAdapter(this.wrapped - .duplicate()); - buf.limit = this.limit; - buf.position = this.position; - buf.mark = this.mark; - return buf; - } - - public byte get() { - byte result = this.wrapped.get(); - this.position++; - return result; - } - - public byte get(int index) { - return this.wrapped.get(index); - } - - public char getChar() { - char result = this.wrapped.getChar(); - this.position += CHAR_SIZE; - return result; - } - - public char getChar(int index) { - return this.wrapped.getChar(index); - } - - public double getDouble() { - double result = this.wrapped.getDouble(); - this.position += DOUBLE_SIZE; - return result; - } - - public double getDouble(int index) { - return this.wrapped.getDouble(index); - } - - public PlatformAddress getEffectiveAddress() { - return ((DirectBuffer) this.wrapped).getEffectiveAddress(); - } - - public float getFloat() { - float result = this.wrapped.getFloat(); - this.position += FLOAT_SIZE; - return result; - } - - public float getFloat(int index) { - return this.wrapped.getFloat(index); - } - - public int getInt() { - int result = this.wrapped.getInt(); - this.position += INTEGER_SIZE; - return result; - } - - public int getInt(int index) { - return this.wrapped.getInt(index); - } - - public long getLong() { - long result = this.wrapped.getLong(); - this.position += LONG_SIZE; - return result; - } - - public long getLong(int index) { - return this.wrapped.getLong(index); - } - - public short getShort() { - short result = this.wrapped.getShort(); - this.position += SHORT_SIZE; - return result; - } - - public short getShort(int index) { - return this.wrapped.getShort(index); - } - - public boolean isDirect() { - return true; - } - - public boolean isReadOnly() { - return this.wrapped.isReadOnly(); - } - - ByteBuffer orderImpl(ByteOrder byteOrder) { - super.orderImpl(byteOrder); - return this.wrapped.order(byteOrder); - } - - public ByteBuffer put(byte b) { - this.wrapped.put(b); - this.position++; - return this; - } - - public ByteBuffer put(byte[] src, int off, int len) { - this.wrapped.position(this.position); - this.wrapped.put(src, off, len); - this.position += len; - return this; - } - - public ByteBuffer put(int index, byte b) { - this.wrapped.put(index, b); - return this; - } - - public ByteBuffer putChar(char value) { - this.wrapped.putChar(value); - this.position += CHAR_SIZE; - return this; - } - - public ByteBuffer putChar(int index, char value) { - this.wrapped.putChar(index, value); - return this; - } - - public ByteBuffer putDouble(double value) { - this.wrapped.putDouble(value); - this.position += DOUBLE_SIZE; - return this; - } - - public ByteBuffer putDouble(int index, double value) { - this.wrapped.putDouble(index, value); - return this; - } - - public ByteBuffer putFloat(float value) { - this.wrapped.putFloat(value); - this.position += FLOAT_SIZE; - return this; - } - - public ByteBuffer putFloat(int index, float value) { - this.wrapped.putFloat(index, value); - return this; - } - - public ByteBuffer putInt(int index, int value) { - this.wrapped.putInt(index, value); - return this; - } - - public ByteBuffer putInt(int value) { - this.wrapped.putInt(value); - this.position += INTEGER_SIZE; - return this; - } - - public ByteBuffer putLong(int index, long value) { - this.wrapped.putLong(index, value); - return this; - } - - public ByteBuffer putLong(long value) { - this.wrapped.putLong(value); - this.position += LONG_SIZE; - return this; - } - - public ByteBuffer putShort(int index, short value) { - this.wrapped.putShort(index, value); - return this; - } - - public ByteBuffer putShort(short value) { - this.wrapped.putShort(value); - this.position += SHORT_SIZE; - return this; - } - - public ByteBuffer slice() { - this.wrapped.limit(this.limit); - this.wrapped.position(this.position); - MappedByteBufferAdapter result = new MappedByteBufferAdapter( - this.wrapped.slice()); - this.wrapped.clear(); - return result; - } - - byte[] protectedArray() { - return this.wrapped.protectedArray(); - } - - int protectedArrayOffset() { - return this.wrapped.protectedArrayOffset(); - } - - boolean protectedHasArray() { - return this.wrapped.protectedHasArray(); - } - - public PlatformAddress getBaseAddress() { - return this.wrapped.getBaseAddress(); - } - - public boolean isAddressValid() { - return this.wrapped.isAddressValid(); - } - - public void addressValidityCheck() { - this.wrapped.addressValidityCheck(); - } - - public void free() { - this.wrapped.free(); - } - public int getByteCapacity() { return wrapped.getByteCapacity(); } Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyBufferException.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyBufferException.java?rev=578091&r1=578090&r2=578091&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyBufferException.java (original) +++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyBufferException.java Fri Sep 21 06:05:59 2007 @@ -16,7 +16,6 @@ package java.nio; - /** * A ReadOnlyBufferException is thrown when some write operation * is called on a readonly buffer. @@ -24,12 +23,12 @@ */ public class ReadOnlyBufferException extends UnsupportedOperationException { - private static final long serialVersionUID = -1210063976496234090L; + private static final long serialVersionUID = -1210063976496234090L; - /** - * Constructs a ReadOnlyBufferException. - */ - public ReadOnlyBufferException() { - super(); - } + /** + * Constructs a ReadOnlyBufferException. + */ + public ReadOnlyBufferException() { + super(); + } } Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyCharArrayBuffer.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyCharArrayBuffer.java?rev=578091&r1=578090&r2=578091&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyCharArrayBuffer.java (original) +++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyCharArrayBuffer.java Fri Sep 21 06:05:59 2007 @@ -31,72 +31,86 @@ */ final class ReadOnlyCharArrayBuffer extends CharArrayBuffer { - static ReadOnlyCharArrayBuffer copy(CharArrayBuffer other, int markOfOther) { - ReadOnlyCharArrayBuffer buf = new ReadOnlyCharArrayBuffer(other - .capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadOnlyCharArrayBuffer(int capacity, char[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public CharBuffer asReadOnlyBuffer() { - return duplicate(); - } - - public CharBuffer compact() { - throw new ReadOnlyBufferException(); - } - - public CharBuffer duplicate() { - return copy(this, mark); - } - - public boolean isReadOnly() { - return true; - } - - protected char[] protectedArray() { - throw new ReadOnlyBufferException(); - } - - protected int protectedArrayOffset() { - throw new ReadOnlyBufferException(); - } - - protected boolean protectedHasArray() { - return false; - } - - public CharBuffer put(char c) { - throw new ReadOnlyBufferException(); - } - - public CharBuffer put(int index, char c) { - throw new ReadOnlyBufferException(); - } + static ReadOnlyCharArrayBuffer copy(CharArrayBuffer other, int markOfOther) { + ReadOnlyCharArrayBuffer buf = new ReadOnlyCharArrayBuffer(other + .capacity(), other.backingArray, other.offset); + buf.limit = other.limit(); + buf.position = other.position(); + buf.mark = markOfOther; + return buf; + } + + ReadOnlyCharArrayBuffer(int capacity, char[] backingArray, int arrayOffset) { + super(capacity, backingArray, arrayOffset); + } + + @Override + public CharBuffer asReadOnlyBuffer() { + return duplicate(); + } + + @Override + public CharBuffer compact() { + throw new ReadOnlyBufferException(); + } + + @Override + public CharBuffer duplicate() { + return copy(this, mark); + } + + @Override + public boolean isReadOnly() { + return true; + } + + @Override + protected char[] protectedArray() { + throw new ReadOnlyBufferException(); + } + + @Override + protected int protectedArrayOffset() { + throw new ReadOnlyBufferException(); + } + + @Override + protected boolean protectedHasArray() { + return false; + } + + @Override + public CharBuffer put(char c) { + throw new ReadOnlyBufferException(); + } + @Override + public CharBuffer put(int index, char c) { + throw new ReadOnlyBufferException(); + } + + @Override public final CharBuffer put(char[] src, int off, int len) { throw new ReadOnlyBufferException(); } - + + @Override public final CharBuffer put(CharBuffer src) { throw new ReadOnlyBufferException(); } + @Override public CharBuffer put(String src, int start, int end) { - if ((start < 0 ) || (end < 0) || (long)start + (long)end > src.length()) { + if ((start < 0) || (end < 0) + || (long) start + (long) end > src.length()) { throw new IndexOutOfBoundsException(); } throw new ReadOnlyBufferException(); } - public CharBuffer slice() { - return new ReadOnlyCharArrayBuffer(remaining(), backingArray, offset - + position); - } + @Override + public CharBuffer slice() { + return new ReadOnlyCharArrayBuffer(remaining(), backingArray, offset + + position); + } } Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyDirectByteBuffer.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyDirectByteBuffer.java?rev=578091&r1=578090&r2=578091&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyDirectByteBuffer.java (original) +++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyDirectByteBuffer.java Fri Sep 21 06:05:59 2007 @@ -33,103 +33,122 @@ */ final class ReadOnlyDirectByteBuffer extends DirectByteBuffer { - static ReadOnlyDirectByteBuffer copy(DirectByteBuffer other, int markOfOther) { - ReadOnlyDirectByteBuffer buf = new ReadOnlyDirectByteBuffer( - other.safeAddress, other.capacity(), other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - buf.order(other.order()); - return buf; - } - - protected ReadOnlyDirectByteBuffer(SafeAddress address, int capacity, - int offset) { - super(address, capacity, offset); - } + static ReadOnlyDirectByteBuffer copy(DirectByteBuffer other, int markOfOther) { + ReadOnlyDirectByteBuffer buf = new ReadOnlyDirectByteBuffer( + other.safeAddress, other.capacity(), other.offset); + buf.limit = other.limit(); + buf.position = other.position(); + buf.mark = markOfOther; + buf.order(other.order()); + return buf; + } + + protected ReadOnlyDirectByteBuffer(SafeAddress address, int capacity, + int offset) { + super(address, capacity, offset); + } protected ReadOnlyDirectByteBuffer(PlatformAddress address, int capacity, int offset) { super(new SafeAddress(address), capacity, offset); } - - public ByteBuffer asReadOnlyBuffer() { - return copy(this, mark); - } - - public ByteBuffer compact() { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer duplicate() { - return copy(this, mark); - } - - public boolean isReadOnly() { - return true; - } - - public ByteBuffer put(byte value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer put(int index, byte value) { - throw new ReadOnlyBufferException(); - } + @Override + public ByteBuffer asReadOnlyBuffer() { + return copy(this, mark); + } + + @Override + public ByteBuffer compact() { + throw new ReadOnlyBufferException(); + } + + @Override + public ByteBuffer duplicate() { + return copy(this, mark); + } + + @Override + public boolean isReadOnly() { + return true; + } + + @Override + public ByteBuffer put(byte value) { + throw new ReadOnlyBufferException(); + } + + @Override + public ByteBuffer put(int index, byte value) { + throw new ReadOnlyBufferException(); + } + + @Override public ByteBuffer put(byte[] src, int off, int len) { throw new ReadOnlyBufferException(); } - - public ByteBuffer putDouble(double value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putDouble(int index, double value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putFloat(float value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putFloat(int index, float value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putInt(int value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putInt(int index, int value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putLong(int index, long value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putLong(long value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putShort(int index, short value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putShort(short value) { - throw new ReadOnlyBufferException(); - } - + + @Override + public ByteBuffer putDouble(double value) { + throw new ReadOnlyBufferException(); + } + + @Override + public ByteBuffer putDouble(int index, double value) { + throw new ReadOnlyBufferException(); + } + + @Override + public ByteBuffer putFloat(float value) { + throw new ReadOnlyBufferException(); + } + + @Override + public ByteBuffer putFloat(int index, float value) { + throw new ReadOnlyBufferException(); + } + + @Override + public ByteBuffer putInt(int value) { + throw new ReadOnlyBufferException(); + } + + @Override + public ByteBuffer putInt(int index, int value) { + throw new ReadOnlyBufferException(); + } + + @Override + public ByteBuffer putLong(int index, long value) { + throw new ReadOnlyBufferException(); + } + + @Override + public ByteBuffer putLong(long value) { + throw new ReadOnlyBufferException(); + } + + @Override + public ByteBuffer putShort(int index, short value) { + throw new ReadOnlyBufferException(); + } + + @Override + public ByteBuffer putShort(short value) { + throw new ReadOnlyBufferException(); + } + + @Override public ByteBuffer put(ByteBuffer buf) { throw new ReadOnlyBufferException(); } - public ByteBuffer slice() { - ReadOnlyDirectByteBuffer buf = new ReadOnlyDirectByteBuffer( - safeAddress, remaining(), offset + position); - buf.order = order; - return buf; - } + @Override + public ByteBuffer slice() { + ReadOnlyDirectByteBuffer buf = new ReadOnlyDirectByteBuffer( + safeAddress, remaining(), offset + position); + buf.order = order; + return buf; + } } Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyDoubleArrayBuffer.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyDoubleArrayBuffer.java?rev=578091&r1=578090&r2=578091&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyDoubleArrayBuffer.java (original) +++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyDoubleArrayBuffer.java Fri Sep 21 06:05:59 2007 @@ -31,68 +31,80 @@ */ final class ReadOnlyDoubleArrayBuffer extends DoubleArrayBuffer { - static ReadOnlyDoubleArrayBuffer copy(DoubleArrayBuffer other, - int markOfOther) { - ReadOnlyDoubleArrayBuffer buf = new ReadOnlyDoubleArrayBuffer(other - .capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadOnlyDoubleArrayBuffer(int capacity, double[] backingArray, - int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public DoubleBuffer asReadOnlyBuffer() { - return duplicate(); - } - - public DoubleBuffer compact() { - throw new ReadOnlyBufferException(); - } - - public DoubleBuffer duplicate() { - return copy(this, mark); - } - - public boolean isReadOnly() { - return true; - } - - protected double[] protectedArray() { - throw new ReadOnlyBufferException(); - } - - protected int protectedArrayOffset() { - throw new ReadOnlyBufferException(); - } - - protected boolean protectedHasArray() { - return false; - } - - public DoubleBuffer put(double c) { - throw new ReadOnlyBufferException(); - } - - public DoubleBuffer put(int index, double c) { - throw new ReadOnlyBufferException(); - } + static ReadOnlyDoubleArrayBuffer copy(DoubleArrayBuffer other, + int markOfOther) { + ReadOnlyDoubleArrayBuffer buf = new ReadOnlyDoubleArrayBuffer(other + .capacity(), other.backingArray, other.offset); + buf.limit = other.limit(); + buf.position = other.position(); + buf.mark = markOfOther; + return buf; + } + + ReadOnlyDoubleArrayBuffer(int capacity, double[] backingArray, + int arrayOffset) { + super(capacity, backingArray, arrayOffset); + } + + @Override + public DoubleBuffer asReadOnlyBuffer() { + return duplicate(); + } + + @Override + public DoubleBuffer compact() { + throw new ReadOnlyBufferException(); + } + + @Override + public DoubleBuffer duplicate() { + return copy(this, mark); + } + + @Override + public boolean isReadOnly() { + return true; + } + + @Override + protected double[] protectedArray() { + throw new ReadOnlyBufferException(); + } + @Override + protected int protectedArrayOffset() { + throw new ReadOnlyBufferException(); + } + + @Override + protected boolean protectedHasArray() { + return false; + } + + @Override + public DoubleBuffer put(double c) { + throw new ReadOnlyBufferException(); + } + + @Override + public DoubleBuffer put(int index, double c) { + throw new ReadOnlyBufferException(); + } + + @Override public final DoubleBuffer put(double[] src, int off, int len) { throw new ReadOnlyBufferException(); } - + + @Override public final DoubleBuffer put(DoubleBuffer buf) { throw new ReadOnlyBufferException(); } - - public DoubleBuffer slice() { - return new ReadOnlyDoubleArrayBuffer(remaining(), backingArray, offset - + position); - } + + @Override + public DoubleBuffer slice() { + return new ReadOnlyDoubleArrayBuffer(remaining(), backingArray, offset + + position); + } } Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyFloatArrayBuffer.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyFloatArrayBuffer.java?rev=578091&r1=578090&r2=578091&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyFloatArrayBuffer.java (original) +++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyFloatArrayBuffer.java Fri Sep 21 06:05:59 2007 @@ -31,66 +31,78 @@ */ final class ReadOnlyFloatArrayBuffer extends FloatArrayBuffer { - static ReadOnlyFloatArrayBuffer copy(FloatArrayBuffer other, int markOfOther) { - ReadOnlyFloatArrayBuffer buf = new ReadOnlyFloatArrayBuffer(other - .capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadOnlyFloatArrayBuffer(int capacity, float[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public FloatBuffer asReadOnlyBuffer() { - return duplicate(); - } - - public FloatBuffer compact() { - throw new ReadOnlyBufferException(); - } - - public FloatBuffer duplicate() { - return copy(this, mark); - } - - public boolean isReadOnly() { - return true; - } - - protected float[] protectedArray() { - throw new ReadOnlyBufferException(); - } - - protected int protectedArrayOffset() { - throw new ReadOnlyBufferException(); - } - - protected boolean protectedHasArray() { - return false; - } - - public FloatBuffer put(float c) { - throw new ReadOnlyBufferException(); - } - - public FloatBuffer put(int index, float c) { - throw new ReadOnlyBufferException(); - } - + static ReadOnlyFloatArrayBuffer copy(FloatArrayBuffer other, int markOfOther) { + ReadOnlyFloatArrayBuffer buf = new ReadOnlyFloatArrayBuffer(other + .capacity(), other.backingArray, other.offset); + buf.limit = other.limit(); + buf.position = other.position(); + buf.mark = markOfOther; + return buf; + } + + ReadOnlyFloatArrayBuffer(int capacity, float[] backingArray, int arrayOffset) { + super(capacity, backingArray, arrayOffset); + } + + @Override + public FloatBuffer asReadOnlyBuffer() { + return duplicate(); + } + + @Override + public FloatBuffer compact() { + throw new ReadOnlyBufferException(); + } + + @Override + public FloatBuffer duplicate() { + return copy(this, mark); + } + + @Override + public boolean isReadOnly() { + return true; + } + + @Override + protected float[] protectedArray() { + throw new ReadOnlyBufferException(); + } + + @Override + protected int protectedArrayOffset() { + throw new ReadOnlyBufferException(); + } + + @Override + protected boolean protectedHasArray() { + return false; + } + + @Override + public FloatBuffer put(float c) { + throw new ReadOnlyBufferException(); + } + + @Override + public FloatBuffer put(int index, float c) { + throw new ReadOnlyBufferException(); + } + + @Override public FloatBuffer put(FloatBuffer buf) { throw new ReadOnlyBufferException(); } + @Override public final FloatBuffer put(float[] src, int off, int len) { throw new ReadOnlyBufferException(); } - - public FloatBuffer slice() { - return new ReadOnlyFloatArrayBuffer(remaining(), backingArray, offset - + position); - } + + @Override + public FloatBuffer slice() { + return new ReadOnlyFloatArrayBuffer(remaining(), backingArray, offset + + position); + } } Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyHeapByteBuffer.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyHeapByteBuffer.java?rev=578091&r1=578090&r2=578091&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyHeapByteBuffer.java (original) +++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ReadOnlyHeapByteBuffer.java Fri Sep 21 06:05:59 2007 @@ -31,108 +31,130 @@ */ final class ReadOnlyHeapByteBuffer extends HeapByteBuffer { - static ReadOnlyHeapByteBuffer copy(HeapByteBuffer other, int markOfOther) { - ReadOnlyHeapByteBuffer buf = new ReadOnlyHeapByteBuffer( - other.backingArray, other.capacity(), other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - buf.order(other.order()); - return buf; - } - - ReadOnlyHeapByteBuffer(byte[] backingArray, int capacity, int arrayOffset) { - super(backingArray, capacity, arrayOffset); - } - - public ByteBuffer asReadOnlyBuffer() { - return copy(this, mark); - } - - public ByteBuffer compact() { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer duplicate() { - return copy(this, mark); - } - - public boolean isReadOnly() { - return true; - } - - protected byte[] protectedArray() { - throw new ReadOnlyBufferException(); - } - - protected int protectedArrayOffset() { - throw new ReadOnlyBufferException(); - } - - protected boolean protectedHasArray() { - return false; - } - - public ByteBuffer put(byte b) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer put(int index, byte b) { - throw new ReadOnlyBufferException(); - } + static ReadOnlyHeapByteBuffer copy(HeapByteBuffer other, int markOfOther) { + ReadOnlyHeapByteBuffer buf = new ReadOnlyHeapByteBuffer( + other.backingArray, other.capacity(), other.offset); + buf.limit = other.limit(); + buf.position = other.position(); + buf.mark = markOfOther; + buf.order(other.order()); + return buf; + } + + ReadOnlyHeapByteBuffer(byte[] backingArray, int capacity, int arrayOffset) { + super(backingArray, capacity, arrayOffset); + } + + @Override + public ByteBuffer asReadOnlyBuffer() { + return copy(this, mark); + } + + @Override + public ByteBuffer compact() { + throw new ReadOnlyBufferException(); + } + + @Override + public ByteBuffer duplicate() { + return copy(this, mark); + } + + @Override + public boolean isReadOnly() { + return true; + } + + @Override + protected byte[] protectedArray() { + throw new ReadOnlyBufferException(); + } + + @Override + protected int protectedArrayOffset() { + throw new ReadOnlyBufferException(); + } + + @Override + protected boolean protectedHasArray() { + return false; + } + + @Override + public ByteBuffer put(byte b) { + throw new ReadOnlyBufferException(); + } + @Override + public ByteBuffer put(int index, byte b) { + throw new ReadOnlyBufferException(); + } + + @Override public ByteBuffer put(byte[] src, int off, int len) { throw new ReadOnlyBufferException(); } - - public ByteBuffer putDouble(double value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putDouble(int index, double value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putFloat(float value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putFloat(int index, float value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putInt(int value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putInt(int index, int value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putLong(int index, long value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putLong(long value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putShort(int index, short value) { - throw new ReadOnlyBufferException(); - } + @Override + public ByteBuffer putDouble(double value) { + throw new ReadOnlyBufferException(); + } + + @Override + public ByteBuffer putDouble(int index, double value) { + throw new ReadOnlyBufferException(); + } + + @Override + public ByteBuffer putFloat(float value) { + throw new ReadOnlyBufferException(); + } + + @Override + public ByteBuffer putFloat(int index, float value) { + throw new ReadOnlyBufferException(); + } + + @Override + public ByteBuffer putInt(int value) { + throw new ReadOnlyBufferException(); + } + + @Override + public ByteBuffer putInt(int index, int value) { + throw new ReadOnlyBufferException(); + } + + @Override + public ByteBuffer putLong(int index, long value) { + throw new ReadOnlyBufferException(); + } + + @Override + public ByteBuffer putLong(long value) { + throw new ReadOnlyBufferException(); + } + + @Override + public ByteBuffer putShort(int index, short value) { + throw new ReadOnlyBufferException(); + } + + @Override public ByteBuffer putShort(short value) { throw new ReadOnlyBufferException(); } - + + @Override public ByteBuffer put(ByteBuffer buf) { throw new ReadOnlyBufferException(); } - public ByteBuffer slice() { - ReadOnlyHeapByteBuffer slice = new ReadOnlyHeapByteBuffer(backingArray, - remaining(), offset + position); - slice.order = order; - return slice; - } + @Override + public ByteBuffer slice() { + ReadOnlyHeapByteBuffer slice = new ReadOnlyHeapByteBuffer(backingArray, + remaining(), offset + position); + slice.order = order; + return slice; + } }