From 9c6e39007ec6a48988c948c38745755f3f3b230d Mon Sep 17 00:00:00 2001
From: Colin Alworth The default byte order of byte buffer is always {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}
diff --git a/src/main/java/java/nio/CharBuffer.java b/src/main/java/java/nio/CharBuffer.java
index e3be4630..4314e7e1 100644
--- a/src/main/java/java/nio/CharBuffer.java
+++ b/src/main/java/java/nio/CharBuffer.java
@@ -55,29 +55,6 @@ public abstract class CharBuffer extends Buffer
super(capacity);
}
- /** Returns the char array which this buffer is based on, if there is one.
- *
- * @return the char array which this buffer is based on.
- * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only.
- * @exception UnsupportedOperationException if this buffer is not based on an array.
- */
- public final char[] array () {
- return protectedArray();
- }
-
- /** Returns the offset of the char array which this buffer is based on, if there is one.
- *
- * The offset is the index of the array corresponds to the zero position of the buffer.
- * The returned buffer is guaranteed to be a new instance, even if this buffer is read-only
* itself. The new buffer's position, limit, capacity and mark are the same as this buffer's.
@@ -236,15 +213,6 @@ public CharBuffer get (char[] dest, int off, int len) {
*/
public abstract char get (int index);
- /** Indicates whether this buffer is based on a char array and is read/write.
- *
- * @return {@code true} if this buffer is based on a byte array and provides read/write access,
- * {@code false} otherwise.
- */
- public final boolean hasArray () {
- return protectedHasArray();
- }
-
/** Calculates this buffer's hash code from the remaining chars. The position, limit, capacity
* and mark don't affect the hash code.
*
@@ -259,16 +227,6 @@ public int hashCode () {
return hash;
}
- /** Indicates whether this buffer is direct. A direct buffer will try its best to take
- * advantage of native memory APIs and it may not stay in the Java heap, so it is not affected
- * by garbage collection.
- * A char buffer is direct if it is based on a byte buffer and the byte buffer is direct.
- *
The returned buffer is guaranteed to be a new instance, even if this buffer is read-only * itself. The new buffer's position, limit, capacity and mark are the same as this buffer's. @@ -219,15 +196,6 @@ public DoubleBuffer get (double[] dest, int off, int len) { */ public abstract double get (int index); - /** Indicates whether this buffer is based on a double array and is read/write. - * - * @return {@code true} if this buffer is based on a double array and provides read/write - * access, {@code false} otherwise. - */ - public final boolean hasArray () { - return protectedHasArray(); - } - // /** // * Calculates this buffer's hash code from the remaining chars. The // * position, limit, capacity and mark don't affect the hash code. @@ -245,16 +213,6 @@ public final boolean hasArray () { // return hash; // } - /** Indicates whether this buffer is direct. A direct buffer will try its best to take advantage - * of native memory APIs and it may not stay in the Java heap, so it is not affected by garbage - * collection. - *
A double buffer is direct if it is based on a byte buffer and the byte buffer is direct. - *
- * - * @return {@code true} if this buffer is direct, {@code false} otherwise. - */ - public abstract boolean isDirect (); - /** Returns the byte order used by this buffer when converting doubles from/to bytes. *If this buffer is not based on a byte buffer, then this always returns the platform's * native byte order.
@@ -263,21 +221,6 @@ public final boolean hasArray () { */ public abstract ByteOrder order (); - /** Child class implements this method to realize {@code array()}. - * - * @see #array() */ - abstract double[] protectedArray (); - - /** Child class implements this method to realize {@code arrayOffset()}. - * - * @see #arrayOffset() */ - abstract int protectedArrayOffset (); - - /** Child class implements this method to realize {@code hasArray()}. - * - * @see #hasArray() */ - abstract boolean protectedHasArray (); - /** Writes the given double to the current position and increases the position by 1. * * @param d the double to write. diff --git a/src/main/java/java/nio/FloatBuffer.java b/src/main/java/java/nio/FloatBuffer.java index 78d8c993..16340935 100644 --- a/src/main/java/java/nio/FloatBuffer.java +++ b/src/main/java/java/nio/FloatBuffer.java @@ -221,15 +221,6 @@ public float get (int index) { return (float)(double)floatArray.getAt(index); } - /** Indicates whether this buffer is based on a float array and is read/write. - * - * @return {@code true} if this buffer is based on a float array and provides read/write - * access, {@code false} otherwise. - */ - public final boolean hasArray () { - return false; - } - // /** // * Calculates this buffer's hash code from the remaining chars. The // * position, limit, capacity and mark don't affect the hash code. @@ -246,18 +237,6 @@ public final boolean hasArray () { // return hash; // } - /** Indicates whether this buffer is direct. A direct buffer will try its best to take - * advantage of native memory APIs and it may not stay in the Java heap, so it is not affected - * by garbage collection. - *A float buffer is direct if it is based on a byte buffer and the byte buffer is direct. - *
- * - * @return {@code true} if this buffer is direct, {@code false} otherwise. - */ - public boolean isDirect () { - return true; - } - /** Returns the byte order used by this buffer when converting floats from/to bytes. *If this buffer is not based on a byte buffer, then always return the platform's native * byte order.
diff --git a/src/main/java/java/nio/IntBuffer.java b/src/main/java/java/nio/IntBuffer.java index 2c47a274..20f04ad7 100644 --- a/src/main/java/java/nio/IntBuffer.java +++ b/src/main/java/java/nio/IntBuffer.java @@ -224,15 +224,6 @@ public int get (int index) { return (int)(double)intArray.getAt(index); } - /** Indicates whether this buffer is based on a int array and is read/write. - * - * @return {@code true} if this buffer is based on a int array and provides read/write access, - * {@code false} otherwise. - */ - public final boolean hasArray () { - return false; - } - /** Calculates this buffer's hash code from the remaining chars. The position, limit, capacity * and mark don't affect the hash code. * @@ -247,19 +238,6 @@ public int hashCode () { return hash; } - /** Indicates whether this buffer is direct. A direct buffer will try its best to take - * advantage of native memory APIs and it may not stay in the Java heap, so it is not affected - * by garbage collection. - *- * An int buffer is direct if it is based on a byte buffer and the byte buffer is direct. - *
- * - * @return {@code true} if this buffer is direct, {@code false} otherwise. - */ - public boolean isDirect () { - return true; - } - /** Returns the byte order used by this buffer when converting ints from/to bytes. *If this buffer is not based on a byte buffer, then always return the platform's native * byte order.
diff --git a/src/main/java/java/nio/LongBuffer.java b/src/main/java/java/nio/LongBuffer.java index 7aac116f..728e8172 100644 --- a/src/main/java/java/nio/LongBuffer.java +++ b/src/main/java/java/nio/LongBuffer.java @@ -52,29 +52,6 @@ public abstract class LongBuffer extends Buffer implements ComparableThe returned buffer is guaranteed to be a new instance, even if this buffer is read-only * itself. The new buffer's position, limit, capacity and mark are the same as this buffer's. @@ -219,15 +196,6 @@ public LongBuffer get (long[] dest, int off, int len) { */ public abstract long get (int index); - /** Indicates whether this buffer is based on a long array and is read/write. - * - * @return {@code true} if this buffer is based on a long array and provides read/write access, - * {@code false} otherwise. - */ - public final boolean hasArray () { - return protectedHasArray(); - } - /** Calculates this buffer's hash code from the remaining chars. The position, limit, capacity * and mark don't affect the hash code. * @@ -244,17 +212,6 @@ public int hashCode () { return hash; } - /** Indicates whether this buffer is direct. A direct buffer will try its best to take - * advantage of native memory APIs and it may not stay in the Java heap, so it is not affected - * by garbage collection. - *
- * A long buffer is direct if it is based on a byte buffer and the byte buffer is direct. - *
- * - * @return {@code true} if this buffer is direct, {@code false} otherwise. - */ - 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.
@@ -263,21 +220,6 @@ public int hashCode () { */ public abstract ByteOrder order (); - /** Child class implements this method to realize {@code array()}. - * - * @return see {@code array()} */ - abstract long[] protectedArray (); - - /** Child class implements this method to realize {@code arrayOffset()}. - * - * @return see {@code arrayOffset()} */ - abstract int protectedArrayOffset (); - - /** Child class implements this method to realize {@code hasArray()}. - * - * @return see {@code hasArray()} */ - abstract boolean protectedHasArray (); - /** Writes the given long to the current position and increases the position by 1. * * @param l the long to write. diff --git a/src/main/java/java/nio/ShortBuffer.java b/src/main/java/java/nio/ShortBuffer.java index b11415d2..9da1bf84 100644 --- a/src/main/java/java/nio/ShortBuffer.java +++ b/src/main/java/java/nio/ShortBuffer.java @@ -217,15 +217,6 @@ public short get (int index) { return (short)(double)shortArray.getAt(index); } - /** Indicates whether this buffer is based on a short array and is read/write. - * - * @return {@code true} if this buffer is based on a short array and provides read/write - * access, {@code false} otherwise. - */ - public final boolean hasArray () { - return false; - } - /** Calculates this buffer's hash code from the remaining chars. The position, limit, capacity * and mark don't affect the hash code. * @@ -240,18 +231,6 @@ public int hashCode () { return hash; } - /** Indicates whether this buffer is direct. A direct buffer will try its best to take - * advantage of native memory APIs and it may not stay in the Java heap, so it is not affected - * by garbage collection. - *A short buffer is direct if it is based on a byte buffer and the byte buffer is direct. - *
- * - * @return {@code true} if this buffer is direct, {@code false} otherwise. - */ - public boolean isDirect () { - return true; - } - /** Returns the byte order used by this buffer when converting shorts from/to bytes. *If this buffer is not based on a byte buffer, then always return the platform's native * byte order.