aboutsummaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog74
-rw-r--r--libjava/Makefile.am19
-rw-r--r--libjava/Makefile.in50
-rw-r--r--libjava/gnu/java/nio/ByteBufferImpl.java386
-rw-r--r--libjava/gnu/java/nio/CharBufferImpl.java146
-rw-r--r--libjava/gnu/java/nio/DoubleBufferImpl.java118
-rw-r--r--libjava/gnu/java/nio/FloatBufferImpl.java112
-rw-r--r--libjava/gnu/java/nio/IntBufferImpl.java116
-rw-r--r--libjava/gnu/java/nio/LongBufferImpl.java114
-rw-r--r--libjava/gnu/java/nio/ShortBufferImpl.java124
10 files changed, 753 insertions, 506 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 466fd09..57cf35c 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,5 +1,79 @@
2003-02-11 Michael Koch <konqueror@gmx.de>
+ * gnu/java/nio/ByteBufferImpl.java:
+ Reformated and removed some code.
+ (backing_buffer): Removed.
+ (array_offset): Removed.
+ (ro): Renamed to readOnly.
+ (ByteBufferImpl): Use parent constructor, initialize readOnly.
+ * gnu/java/nio/CharBufferImpl.java:
+ Reformated and removed some code.
+ (array_offset): Removed.
+ (ro): Renamed to readOnly.
+ (CharBufferImpl): Use parent constructor, initialize readOnly.
+ (inc_pos): Removed.
+ (order): New method.
+ * gnu/java/nio/DoubleBufferImpl.java:
+ Reformated and removed some code.
+ (array_offset): Removed.
+ (ro): Renamed to readOnly.
+ (DoubleBufferImpl): Use parent constructor, initialize readOnly.
+ (inc_pos): Removed.
+ (order): New method.
+ * gnu/java/nio/FloatBufferImpl.java:
+ Reformated and removed some code.
+ (array_offset): Removed.
+ (ro): Renamed to readOnly.
+ (FloatBufferImpl): Use parent constructor, initialize readOnly.
+ (inc_pos): Removed.
+ (order): New method.
+ * gnu/java/nio/IntBufferImpl.java:
+ Reformated and removed some code.
+ (array_offset): Removed.
+ (ro): Renamed to readOnly.
+ (IntBufferImpl): Use parent constructor, initialize readOnly.
+ (inc_pos): Removed.
+ (order): New method.
+ * gnu/java/nio/LongBufferImpl.java:
+ Reformated and removed some code.
+ (array_offset): Removed.
+ (ro): Renamed to readOnly.
+ (LongBufferImpl): Use parent constructor, initialize readOnly.
+ (inc_pos): Removed.
+ (order): New method.
+ * gnu/java/nio/ShortBufferImpl.java:
+ Reformated and removed some code.
+ (array_offset): Removed.
+ (ro): Renamed to readOnly.
+ (ShortBufferImpl): Use parent constructor, initialize readOnly.
+ (inc_pos): Removed.
+ (order): New method.
+ * Makefile.am
+ (ordinary_java_source_files): Added the following files:
+ gnu/java/nio/ByteBufferImpl.java
+ gnu/java/nio/CharBufferImpl.java
+ gnu/java/nio/DoubleBufferImpl.java
+ gnu/java/nio/FloatBufferImpl.java
+ gnu/java/nio/IntBufferImpl.java
+ gnu/java/nio/LongBufferImpl.java
+ gnu/java/nio/ShortBufferImpl.java
+ java/nio/DoubleBuffer.java
+ java/nio/FloatBuffer.java
+ java/nio/IntBuffer.java
+ java/nio/LongBuffer.java
+ java/nio/ShortBuffer.java
+ (nat_source_files): Added the following files:
+ gnu/java/nio/natByteBufferImpl.cc
+ gnu/java/nio/natCharBufferImpl.cc
+ gnu/java/nio/natDoubleBufferImpl.cc
+ gnu/java/nio/natFloatBufferImpl.cc
+ gnu/java/nio/natIntBufferImpl.cc
+ gnu/java/nio/natLongBufferImpl.cc
+ gnu/java/nio/natShortBufferImpl.cc
+ * Makefile.in: Regenerated.
+
+2003-02-11 Michael Koch <konqueror@gmx.de>
+
* gnu/java/nio/natCharBufferImpl.cc
(nio_cast): Removed.
(nio_put_*): Removed.
diff --git a/libjava/Makefile.am b/libjava/Makefile.am
index 28b67a3..f8911f2 100644
--- a/libjava/Makefile.am
+++ b/libjava/Makefile.am
@@ -2037,6 +2037,13 @@ gnu/java/locale/LocaleInformation_zh_HK.java \
gnu/java/locale/LocaleInformation_zh_SG.java \
gnu/java/locale/LocaleInformation_zh_TW.java \
gnu/java/math/MPN.java \
+gnu/java/nio/ByteBufferImpl.java \
+gnu/java/nio/CharBufferImpl.java \
+gnu/java/nio/DoubleBufferImpl.java \
+gnu/java/nio/FloatBufferImpl.java \
+gnu/java/nio/IntBufferImpl.java \
+gnu/java/nio/LongBufferImpl.java \
+gnu/java/nio/ShortBufferImpl.java \
gnu/java/nio/charset/ISO_8859_1.java \
gnu/java/nio/charset/Provider.java \
gnu/java/nio/charset/US_ASCII.java \
@@ -2139,9 +2146,14 @@ java/nio/BufferUnderflowException.java \
java/nio/ByteBuffer.java \
java/nio/ByteOrder.java \
java/nio/CharBuffer.java \
+java/nio/DoubleBuffer.java \
+java/nio/FloatBuffer.java \
+java/nio/IntBuffer.java \
java/nio/InvalidMarkException.java \
+java/nio/LongBuffer.java \
java/nio/MappedByteBuffer.java \
java/nio/ReadOnlyBufferException.java \
+java/nio/ShortBuffer.java \
java/nio/channels/AlreadyConnectedException.java \
java/nio/channels/AsynchronousCloseException.java \
java/nio/channels/ByteChannel.java \
@@ -2431,6 +2443,13 @@ gnu/gcj/runtime/natSharedLibLoader.cc \
gnu/gcj/runtime/natStackTrace.cc \
gnu/gcj/runtime/natStringBuffer.cc \
gnu/gcj/runtime/natVMClassLoader.cc \
+gnu/java/nio/natByteBufferImpl.cc \
+gnu/java/nio/natCharBufferImpl.cc \
+gnu/java/nio/natDoubleBufferImpl.cc \
+gnu/java/nio/natFloatBufferImpl.cc \
+gnu/java/nio/natIntBufferImpl.cc \
+gnu/java/nio/natLongBufferImpl.cc \
+gnu/java/nio/natShortBufferImpl.cc \
java/io/natFile.cc \
java/io/natFileDescriptor.cc \
java/io/natObjectInputStream.cc \
diff --git a/libjava/Makefile.in b/libjava/Makefile.in
index 06c9a297..de89377 100644
--- a/libjava/Makefile.in
+++ b/libjava/Makefile.in
@@ -1797,6 +1797,13 @@ gnu/java/locale/LocaleInformation_zh_HK.java \
gnu/java/locale/LocaleInformation_zh_SG.java \
gnu/java/locale/LocaleInformation_zh_TW.java \
gnu/java/math/MPN.java \
+gnu/java/nio/ByteBufferImpl.java \
+gnu/java/nio/CharBufferImpl.java \
+gnu/java/nio/DoubleBufferImpl.java \
+gnu/java/nio/FloatBufferImpl.java \
+gnu/java/nio/IntBufferImpl.java \
+gnu/java/nio/LongBufferImpl.java \
+gnu/java/nio/ShortBufferImpl.java \
gnu/java/nio/charset/ISO_8859_1.java \
gnu/java/nio/charset/Provider.java \
gnu/java/nio/charset/US_ASCII.java \
@@ -1899,9 +1906,14 @@ java/nio/BufferUnderflowException.java \
java/nio/ByteBuffer.java \
java/nio/ByteOrder.java \
java/nio/CharBuffer.java \
+java/nio/DoubleBuffer.java \
+java/nio/FloatBuffer.java \
+java/nio/IntBuffer.java \
java/nio/InvalidMarkException.java \
+java/nio/LongBuffer.java \
java/nio/MappedByteBuffer.java \
java/nio/ReadOnlyBufferException.java \
+java/nio/ShortBuffer.java \
java/nio/channels/AlreadyConnectedException.java \
java/nio/channels/AsynchronousCloseException.java \
java/nio/channels/ByteChannel.java \
@@ -2190,6 +2202,13 @@ gnu/gcj/runtime/natSharedLibLoader.cc \
gnu/gcj/runtime/natStackTrace.cc \
gnu/gcj/runtime/natStringBuffer.cc \
gnu/gcj/runtime/natVMClassLoader.cc \
+gnu/java/nio/natByteBufferImpl.cc \
+gnu/java/nio/natCharBufferImpl.cc \
+gnu/java/nio/natDoubleBufferImpl.cc \
+gnu/java/nio/natFloatBufferImpl.cc \
+gnu/java/nio/natIntBufferImpl.cc \
+gnu/java/nio/natLongBufferImpl.cc \
+gnu/java/nio/natShortBufferImpl.cc \
java/io/natFile.cc \
java/io/natFileDescriptor.cc \
java/io/natObjectInputStream.cc \
@@ -2361,8 +2380,14 @@ gnu/gcj/io/shs.lo gnu/gcj/protocol/core/natCoreInputStream.lo \
gnu/gcj/runtime/natFinalizerThread.lo gnu/gcj/runtime/natFirstThread.lo \
gnu/gcj/runtime/natNameFinder.lo gnu/gcj/runtime/natSharedLibLoader.lo \
gnu/gcj/runtime/natStackTrace.lo gnu/gcj/runtime/natStringBuffer.lo \
-gnu/gcj/runtime/natVMClassLoader.lo java/io/natFile.lo \
-java/io/natFileDescriptor.lo java/io/natObjectInputStream.lo \
+gnu/gcj/runtime/natVMClassLoader.lo gnu/java/nio/natByteBufferImpl.lo \
+gnu/java/nio/natCharBufferImpl.lo gnu/java/nio/natDoubleBufferImpl.lo \
+gnu/java/nio/natFloatBufferImpl.lo gnu/java/nio/natIntBufferImpl.lo \
+gnu/java/nio/natLongBufferImpl.lo \
+gnu/java/nio/natSelectorImpl.lo \
+gnu/java/nio/natShortBufferImpl.lo \
+java/io/natFile.lo java/io/natFileDescriptor.lo \
+java/io/natObjectInputStream.lo \
java/io/natObjectOutputStream.lo java/io/natVMObjectStreamClass.lo \
java/lang/natCharacter.lo java/lang/natClass.lo \
java/lang/natClassLoader.lo java/lang/natConcreteProcess.lo \
@@ -2820,7 +2845,13 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/gnu/java/locale/LocaleInformation_zh_HK.P \
.deps/gnu/java/locale/LocaleInformation_zh_SG.P \
.deps/gnu/java/locale/LocaleInformation_zh_TW.P \
-.deps/gnu/java/math/MPN.P .deps/gnu/java/nio/charset/ISO_8859_1.P \
+.deps/gnu/java/math/MPN.P .deps/gnu/java/nio/ByteBufferImpl.P \
+.deps/gnu/java/nio/CharBufferImpl.P \
+.deps/gnu/java/nio/DoubleBufferImpl.P \
+.deps/gnu/java/nio/FloatBufferImpl.P .deps/gnu/java/nio/IntBufferImpl.P \
+.deps/gnu/java/nio/LongBufferImpl.P \
+.deps/gnu/java/nio/ShortBufferImpl.P \
+.deps/gnu/java/nio/charset/ISO_8859_1.P \
.deps/gnu/java/nio/charset/Provider.P \
.deps/gnu/java/nio/charset/US_ASCII.P \
.deps/gnu/java/nio/charset/UTF_16.P \
@@ -2829,6 +2860,13 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/gnu/java/nio/charset/UTF_16Encoder.P \
.deps/gnu/java/nio/charset/UTF_16LE.P \
.deps/gnu/java/nio/charset/UTF_8.P \
+.deps/gnu/java/nio/natByteBufferImpl.P \
+.deps/gnu/java/nio/natCharBufferImpl.P \
+.deps/gnu/java/nio/natDoubleBufferImpl.P \
+.deps/gnu/java/nio/natFloatBufferImpl.P \
+.deps/gnu/java/nio/natIntBufferImpl.P \
+.deps/gnu/java/nio/natLongBufferImpl.P \
+.deps/gnu/java/nio/natShortBufferImpl.P \
.deps/gnu/java/rmi/RMIMarshalledObjectInputStream.P \
.deps/gnu/java/rmi/RMIMarshalledObjectOutputStream.P \
.deps/gnu/java/rmi/dgc/DGCImpl.P .deps/gnu/java/rmi/dgc/DGCImpl_Skel.P \
@@ -3298,8 +3336,10 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/nio/BufferOverflowException.P \
.deps/java/nio/BufferUnderflowException.P .deps/java/nio/ByteBuffer.P \
.deps/java/nio/ByteOrder.P .deps/java/nio/CharBuffer.P \
-.deps/java/nio/InvalidMarkException.P .deps/java/nio/MappedByteBuffer.P \
-.deps/java/nio/ReadOnlyBufferException.P \
+.deps/java/nio/DoubleBuffer.P .deps/java/nio/FloatBuffer.P \
+.deps/java/nio/IntBuffer.P .deps/java/nio/InvalidMarkException.P \
+.deps/java/nio/LongBuffer.P .deps/java/nio/MappedByteBuffer.P \
+.deps/java/nio/ReadOnlyBufferException.P .deps/java/nio/ShortBuffer.P \
.deps/java/nio/channels/AlreadyConnectedException.P \
.deps/java/nio/channels/AsynchronousCloseException.P \
.deps/java/nio/channels/ByteChannel.P \
diff --git a/libjava/gnu/java/nio/ByteBufferImpl.java b/libjava/gnu/java/nio/ByteBufferImpl.java
index 54fba24..19783e5 100644
--- a/libjava/gnu/java/nio/ByteBufferImpl.java
+++ b/libjava/gnu/java/nio/ByteBufferImpl.java
@@ -43,37 +43,35 @@ import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.LongBuffer;
+import java.nio.ReadOnlyBufferException;
import java.nio.ShortBuffer;
+/**
+ * This is a Heap memory implementation
+ */
public final class ByteBufferImpl extends ByteBuffer
{
- private byte[] backing_buffer;
- private int array_offset;
- private boolean ro;
-
+ private boolean readOnly;
+
public ByteBufferImpl (int cap, int off, int lim)
{
- this.cap = cap;
- limit (lim);
- position (off);
- this.backing_buffer = new byte[cap];
+ super (cap, lim, off, 0);
+ this.backing_buffer = new byte [cap];
+ readOnly = false;
}
public ByteBufferImpl (byte[] array, int off, int lim)
{
- this.cap = array.length;
- limit (lim);
- position (off);
+ super (array.length, lim, off, 0);
this.backing_buffer = array;
+ readOnly = false;
}
public ByteBufferImpl (ByteBufferImpl copy)
{
- this.cap = copy.capacity ();
- limit (copy.limit ());
- position (copy.position ());
- ro = copy.ro;
+ super (copy.capacity (), copy.limit (), copy.position (), 0);
backing_buffer = copy.backing_buffer;
+ readOnly = copy.isReadOnly ();
}
void inc_pos (int toAdd)
@@ -89,52 +87,140 @@ public final class ByteBufferImpl extends ByteBuffer
private static native byte[] nio_cast(float[]copy);
private static native byte[] nio_cast(double[]copy);
+ ByteBufferImpl (byte[] copy)
+ {
+ super (copy.length, copy.length, 0, 0);
+ this.backing_buffer = copy != null ? nio_cast (copy) : null;
+ readOnly = false;
+ }
- ByteBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native byte nio_get_Byte(ByteBufferImpl b, int index, int limit);
- private static native void nio_put_Byte(ByteBufferImpl b, int index, int limit, byte value);
- public ByteBuffer asByteBuffer() { ByteBufferImpl res = new ByteBufferImpl(backing_buffer); res.limit((limit()*1)/1); return res; }
+ private static native byte nio_get_Byte (ByteBufferImpl b, int index, int limit);
+
+ private static native void nio_put_Byte (ByteBufferImpl b, int index, int limit, byte value);
+
+ public ByteBuffer asByteBuffer ()
+ {
+ ByteBufferImpl res = new ByteBufferImpl (backing_buffer);
+ res.limit ((limit () * 1) / 1);
+ return res;
+ }
- ByteBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native char nio_get_Char(ByteBufferImpl b, int index, int limit);
- private static native void nio_put_Char(ByteBufferImpl b, int index, int limit, char value);
- public CharBuffer asCharBuffer() { CharBufferImpl res = new CharBufferImpl(backing_buffer); res.limit((limit()*2)/1); return res; }
+ ByteBufferImpl (char[] copy)
+ {
+ super (copy.length * 2, copy.length * 2, 0, 0);
+ this.backing_buffer = copy != null ? nio_cast (copy) : null;
+ readOnly = false;
+ }
- ByteBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native short nio_get_Short(ByteBufferImpl b, int index, int limit);
- private static native void nio_put_Short(ByteBufferImpl b, int index, int limit, short value);
- public ShortBuffer asShortBuffer() { ShortBufferImpl res = new ShortBufferImpl(backing_buffer); res.limit((limit()*2)/1); return res; }
+ private static native char nio_get_Char (ByteBufferImpl b, int index, int limit);
- ByteBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native int nio_get_Int(ByteBufferImpl b, int index, int limit);
- private static native void nio_put_Int(ByteBufferImpl b, int index, int limit, int value);
- public IntBuffer asIntBuffer() { IntBufferImpl res = new IntBufferImpl(backing_buffer); res.limit((limit()*4)/1); return res; }
+ private static native void nio_put_Char (ByteBufferImpl b, int index, int limit, char value);
- ByteBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native long nio_get_Long(ByteBufferImpl b, int index, int limit);
- private static native void nio_put_Long(ByteBufferImpl b, int index, int limit, long value);
- public LongBuffer asLongBuffer() { LongBufferImpl res = new LongBufferImpl(backing_buffer); res.limit((limit()*8)/1); return res; }
+ public CharBuffer asCharBuffer ()
+ {
+ CharBufferImpl res = new CharBufferImpl (backing_buffer);
+ res.limit ((limit () * 2) / 1);
+ return res;
+ }
- ByteBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native float nio_get_Float(ByteBufferImpl b, int index, int limit);
- private static native void nio_put_Float(ByteBufferImpl b, int index, int limit, float value);
- public FloatBuffer asFloatBuffer() { FloatBufferImpl res = new FloatBufferImpl(backing_buffer); res.limit((limit()*4)/1); return res; }
+ ByteBufferImpl (short[] copy)
+ {
+ super (copy.length, copy.length, 0, 0);
+ this.backing_buffer = copy != null ? nio_cast (copy) : null;
+ readOnly = false;
+ }
+
+ private static native short nio_get_Short (ByteBufferImpl b, int index, int limit);
+
+ private static native void nio_put_Short (ByteBufferImpl b, int index, int limit, short value);
+
+ public ShortBuffer asShortBuffer ()
+ {
+ ShortBufferImpl res = new ShortBufferImpl (backing_buffer);
+ res.limit ((limit () * 2) / 1);
+ return res;
+ }
- ByteBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native double nio_get_Double(ByteBufferImpl b, int index, int limit);
- private static native void nio_put_Double(ByteBufferImpl b, int index, int limit, double value);
- public DoubleBuffer asDoubleBuffer() { DoubleBufferImpl res = new DoubleBufferImpl(backing_buffer); res.limit((limit()*8)/1); return res; }
+ ByteBufferImpl (int[] copy)
+ {
+ super (copy.length * 4, copy.length * 4, 0, 0);
+ this.backing_buffer = copy != null ? nio_cast(copy) : null;
+ readOnly = false;
+ }
+
+ private static native int nio_get_Int (ByteBufferImpl b, int index, int limit);
+
+ private static native void nio_put_Int (ByteBufferImpl b, int index, int limit, int value);
+
+ public IntBuffer asIntBuffer ()
+ {
+ IntBufferImpl res = new IntBufferImpl (backing_buffer);
+ res.limit ((limit() * 4) / 1);
+ return res;
+ }
+
+ ByteBufferImpl (long[] copy)
+ {
+ super (copy.length * 8, copy.length * 8, 0, 0);
+ this.backing_buffer = copy != null ? nio_cast (copy) : null;
+ readOnly = false;
+ }
+
+ private static native long nio_get_Long (ByteBufferImpl b, int index, int limit);
+
+ private static native void nio_put_Long (ByteBufferImpl b, int index, int limit, long value);
+
+ public LongBuffer asLongBuffer ()
+ {
+ LongBufferImpl res = new LongBufferImpl (backing_buffer);
+ res.limit ((limit() * 8) / 1);
+ return res;
+ }
+
+ ByteBufferImpl (float[] copy)
+ {
+ super (copy.length * 4, copy.length * 4, 0, 0);
+ this.backing_buffer = copy != null ? nio_cast (copy) : null;
+ readOnly = false;
+ }
+
+ private static native float nio_get_Float (ByteBufferImpl b, int index, int limit);
+
+ private static native void nio_put_Float (ByteBufferImpl b, int index, int limit, float value);
+
+ public FloatBuffer asFloatBuffer ()
+ {
+ FloatBufferImpl res = new FloatBufferImpl (backing_buffer);
+ res.limit ((limit() * 4) / 1);
+ return res;
+ }
+
+ ByteBufferImpl (double[] copy)
+ {
+ super (copy.length * 8, copy.length * 8, 0, 0);
+ this.backing_buffer = copy != null ? nio_cast (copy) : null;
+ readOnly = false;
+ }
+
+ private static native double nio_get_Double (ByteBufferImpl b, int index, int limit);
+
+ private static native void nio_put_Double (ByteBufferImpl b, int index, int limit, double value);
+
+ public DoubleBuffer asDoubleBuffer ()
+ {
+ DoubleBufferImpl res = new DoubleBufferImpl (backing_buffer);
+ res.limit ((limit () * 8) / 1);
+ return res;
+ }
public boolean isReadOnly()
{
- return ro;
+ return readOnly;
}
public ByteBuffer slice()
{
- ByteBufferImpl A = new ByteBufferImpl(this);
- A.array_offset = position();
- return A;
+ return new ByteBufferImpl(this);
}
public ByteBuffer duplicate()
@@ -145,7 +231,7 @@ public final class ByteBufferImpl extends ByteBuffer
public ByteBuffer asReadOnlyBuffer()
{
ByteBufferImpl a = new ByteBufferImpl(this);
- a.ro = true;
+ a.readOnly = true;
return a;
}
@@ -156,7 +242,7 @@ public final class ByteBufferImpl extends ByteBuffer
public boolean isDirect()
{
- return backing_buffer != null;
+ return false;
}
final public byte get()
@@ -168,6 +254,9 @@ public final class ByteBufferImpl extends ByteBuffer
final public ByteBuffer put(byte b)
{
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
backing_buffer[position()] = b;
position(position()+1);
return this;
@@ -180,14 +269,201 @@ public final class ByteBufferImpl extends ByteBuffer
final public ByteBuffer put(int index, byte b)
{
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
backing_buffer[index] = b;
return this;
}
- final public char getChar() { char a = nio_get_Char(this, position(), limit()); inc_pos(2); return a; } final public ByteBuffer putChar(char value) { nio_put_Char(this, position(), limit(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index, limit()); return a; } final public ByteBuffer putChar(int index, char value) { nio_put_Char(this, index, limit(), value); return this; };
- final public short getShort() { short a = nio_get_Short(this, position(), limit()); inc_pos(2); return a; } final public ByteBuffer putShort(short value) { nio_put_Short(this, position(), limit(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index, limit()); return a; } final public ByteBuffer putShort(int index, short value) { nio_put_Short(this, index, limit(), value); return this; };
- final public int getInt() { int a = nio_get_Int(this, position(), limit()); inc_pos(4); return a; } final public ByteBuffer putInt(int value) { nio_put_Int(this, position(), limit(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index, limit()); return a; } final public ByteBuffer putInt(int index, int value) { nio_put_Int(this, index, limit(), value); return this; };
- final public long getLong() { long a = nio_get_Long(this, position(), limit()); inc_pos(8); return a; } final public ByteBuffer putLong(long value) { nio_put_Long(this, position(), limit(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index, limit()); return a; } final public ByteBuffer putLong(int index, long value) { nio_put_Long(this, index, limit(), value); return this; };
- final public float getFloat() { float a = nio_get_Float(this, position(), limit()); inc_pos(4); return a; } final public ByteBuffer putFloat(float value) { nio_put_Float(this, position(), limit(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index, limit()); return a; } final public ByteBuffer putFloat(int index, float value) { nio_put_Float(this, index, limit(), value); return this; };
- final public double getDouble() { double a = nio_get_Double(this, position(), limit()); inc_pos(8); return a; } final public ByteBuffer putDouble(double value) { nio_put_Double(this, position(), limit(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index, limit()); return a; } final public ByteBuffer putDouble(int index, double value) { nio_put_Double(this, index, limit(), value); return this; };
+ final public char getChar ()
+ {
+ char a = nio_get_Char (this, position (), limit ());
+ inc_pos (2);
+ return a;
+ }
+
+ final public ByteBuffer putChar (char value)
+ {
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
+ nio_put_Char (this, position (), limit (), value);
+ inc_pos (2);
+ return this;
+ }
+
+ final public char getChar (int index)
+ {
+ char a = nio_get_Char (this, index, limit ());
+ return a;
+ }
+
+ final public ByteBuffer putChar (int index, char value)
+ {
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
+ nio_put_Char (this, index, limit (), value);
+ return this;
+ }
+
+ final public short getShort ()
+ {
+ short a = nio_get_Short (this, position (), limit ());
+ inc_pos (2);
+ return a;
+ }
+
+ final public ByteBuffer putShort (short value)
+ {
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
+ nio_put_Short (this, position (), limit(), value);
+ inc_pos (2);
+ return this;
+ }
+
+ final public short getShort (int index)
+ {
+ short a = nio_get_Short (this, index, limit ());
+ return a;
+ }
+
+ final public ByteBuffer putShort (int index, short value)
+ {
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
+ nio_put_Short (this, index, limit (), value);
+ return this;
+ }
+
+ final public int getInt ()
+ {
+ int a = nio_get_Int (this, position (), limit ());
+ inc_pos (4);
+ return a;
+ }
+
+ final public ByteBuffer putInt (int value)
+ {
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
+ nio_put_Int (this, position (), limit , value);
+ inc_pos (4);
+ return this;
+ }
+
+ final public int getInt (int index)
+ {
+ int a = nio_get_Int (this, index, limit ());
+ return a;
+ }
+
+ final public ByteBuffer putInt (int index, int value)
+ {
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
+ nio_put_Int(this, index, limit (), value);
+ return this;
+ }
+
+ final public long getLong ()
+ {
+ long a = nio_get_Long (this, position (), limit ());
+ inc_pos (8);
+ return a;
+ }
+
+ final public ByteBuffer putLong (long value)
+ {
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
+ nio_put_Long (this, position (), limit (), value);
+ inc_pos (8);
+ return this;
+ }
+
+ final public long getLong (int index)
+ {
+ long a = nio_get_Long (this, index, limit ());
+ return a;
+ }
+
+ final public ByteBuffer putLong (int index, long value)
+ {
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
+ nio_put_Long (this, index, limit (), value);
+ return this;
+ }
+
+ final public float getFloat ()
+ {
+ float a = nio_get_Float (this, position (), limit ());
+ inc_pos (4);
+ return a;
+ }
+
+ final public ByteBuffer putFloat (float value)
+ {
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
+ nio_put_Float (this, position (), limit (), value);
+ inc_pos (4);
+ return this;
+ }
+
+ final public float getFloat (int index)
+ {
+ float a = nio_get_Float (this, index, limit ());
+ return a;
+ }
+
+ final public ByteBuffer putFloat (int index, float value)
+ {
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
+ nio_put_Float (this, index, limit(), value);
+ return this;
+ }
+
+ final public double getDouble ()
+ {
+ double a = nio_get_Double (this, position (), limit ());
+ inc_pos (8);
+ return a;
+ }
+
+ final public ByteBuffer putDouble (double value)
+ {
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
+ nio_put_Double (this, position(), limit (), value);
+ inc_pos (8);
+ return this;
+ }
+
+ final public double getDouble (int index)
+ {
+ return nio_get_Double (this, index, limit ());
+ }
+
+ final public ByteBuffer putDouble (int index, double value)
+ {
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
+ nio_put_Double (this, index, limit (), value);
+ return this;
+ }
}
diff --git a/libjava/gnu/java/nio/CharBufferImpl.java b/libjava/gnu/java/nio/CharBufferImpl.java
index 399dd60..07a96fe 100644
--- a/libjava/gnu/java/nio/CharBufferImpl.java
+++ b/libjava/gnu/java/nio/CharBufferImpl.java
@@ -40,101 +40,65 @@ package gnu.java.nio;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.CharBuffer;
-import java.nio.DoubleBuffer;
-import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
-import java.nio.LongBuffer;
-import java.nio.ShortBuffer;
+import java.nio.ReadOnlyBufferException;
+/**
+ * This is a Heap memory implementation
+ */
public final class CharBufferImpl extends CharBuffer
{
- private boolean ro;
+ private boolean readOnly;
- private ByteOrder endian = ByteOrder.BIG_ENDIAN;
-
public CharBufferImpl(int cap, int off, int lim)
{
- this.backing_buffer = new char[cap];
- this.cap = cap;
- this.limit(lim);
- this.position(off);
+ super (cap, lim, off, 0);
+ this.backing_buffer = new char [cap];
+ readOnly = false;
}
public CharBufferImpl(char[] array, int off, int lim)
{
+ super (array.length, lim, off, 0);
this.backing_buffer = array;
- this.cap = array.length;
- this.limit(lim);
- this.position(off);
+ readOnly = false;
}
public CharBufferImpl (CharBufferImpl copy)
{
+ super (copy.capacity (), copy.limit (), copy.position (), 0);
backing_buffer = copy.backing_buffer;
- ro = copy.ro;
- limit (copy.limit());
- position (copy.position ());
+ readOnly = copy.isReadOnly ();
}
- void inc_pos (int a)
+ private static native char[] nio_cast (byte[] copy);
+
+ CharBufferImpl (byte[] copy)
{
- position (position () + a);
+ super (copy.length / 2, copy.length / 2, 0, 0);
+ this.backing_buffer = (copy != null ? nio_cast (copy) : null);
+ readOnly = false;
}
- CharBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native byte nio_get_Byte(CharBufferImpl b, int index, int limit);
- private static native void nio_put_Byte(CharBufferImpl b, int index, int limit, byte value);
- public ByteBuffer asByteBuffer() { ByteBufferImpl res = new ByteBufferImpl(backing_buffer); res.limit((limit()*1)/2); return res; }
-
- CharBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native char nio_get_Char(CharBufferImpl b, int index, int limit);
- private static native void nio_put_Char(CharBufferImpl b, int index, int limit, char value);
- public CharBuffer asCharBuffer() { CharBufferImpl res = new CharBufferImpl(backing_buffer); res.limit((limit()*2)/2); return res; }
-
- CharBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native short nio_get_Short(CharBufferImpl b, int index, int limit);
- private static native void nio_put_Short(CharBufferImpl b, int index, int limit, short value);
- public ShortBuffer asShortBuffer() { ShortBufferImpl res = new ShortBufferImpl(backing_buffer); res.limit((limit()*2)/2); return res; }
-
- CharBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native int nio_get_Int(CharBufferImpl b, int index, int limit);
- private static native void nio_put_Int(CharBufferImpl b, int index, int limit, int value);
- public IntBuffer asIntBuffer() { IntBufferImpl res = new IntBufferImpl(backing_buffer); res.limit((limit()*4)/2); return res; }
-
- CharBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native long nio_get_Long(CharBufferImpl b, int index, int limit);
- private static native void nio_put_Long(CharBufferImpl b, int index, int limit, long value);
- public LongBuffer asLongBuffer() { LongBufferImpl res = new LongBufferImpl(backing_buffer); res.limit((limit()*8)/2); return res; }
+ private static native byte nio_get_Byte (CharBufferImpl b, int index, int limit);
- CharBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native float nio_get_Float(CharBufferImpl b, int index, int limit);
- private static native void nio_put_Float(CharBufferImpl b, int index, int limit, float value);
- public FloatBuffer asFloatBuffer() { FloatBufferImpl res = new FloatBufferImpl(backing_buffer); res.limit((limit()*4)/2); return res; }
+ private static native void nio_put_Byte (CharBufferImpl b, int index, int limit, byte value);
- CharBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native double nio_get_Double(CharBufferImpl b, int index, int limit);
- private static native void nio_put_Double(CharBufferImpl b, int index, int limit, double value);
- public DoubleBuffer asDoubleBuffer() { DoubleBufferImpl res = new DoubleBufferImpl(backing_buffer); res.limit((limit()*8)/2); return res; }
-
- private static native char[] nio_cast(byte[]copy);
- private static native char[] nio_cast(char[]copy);
- private static native char[] nio_cast(short[]copy);
- private static native char[] nio_cast(long[]copy);
- private static native char[] nio_cast(int[]copy);
- private static native char[] nio_cast(float[]copy);
- private static native char[] nio_cast(double[]copy);
+ public ByteBuffer asByteBuffer ()
+ {
+ ByteBufferImpl res = new ByteBufferImpl (backing_buffer);
+ res.limit ((limit () * 1) / 2);
+ return res;
+ }
public boolean isReadOnly()
{
- return ro;
+ return readOnly;
}
public CharBuffer slice()
{
- CharBufferImpl buffer = new CharBufferImpl (this);
- buffer.array_offset = position ();
- return buffer;
+ return new CharBufferImpl (this);
}
public CharBuffer duplicate()
@@ -144,9 +108,9 @@ public final class CharBufferImpl extends CharBuffer
public CharBuffer asReadOnlyBuffer()
{
- CharBufferImpl a = new CharBufferImpl(this);
- a.ro = true;
- return a;
+ CharBufferImpl result = new CharBufferImpl (this);
+ result.readOnly = true;
+ return result;
}
public CharBuffer compact()
@@ -156,7 +120,7 @@ public final class CharBufferImpl extends CharBuffer
public boolean isDirect()
{
- return backing_buffer != null;
+ return false;
}
final public CharSequence subSequence (int start, int end)
@@ -172,6 +136,9 @@ public final class CharBufferImpl extends CharBuffer
position () + end);
}
+ /**
+ * Relative get method. Reads the next character from the buffer.
+ */
final public char get()
{
char e = backing_buffer[position()];
@@ -179,27 +146,54 @@ public final class CharBufferImpl extends CharBuffer
return e;
}
+ /**
+ * Relative put method. Writes <code>value</code> to the next position
+ * in the buffer.
+ *
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
final public CharBuffer put(char b)
{
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
backing_buffer[position()] = b;
position(position()+1);
return this;
}
-
- final public char getChar() { return get(); } final public CharBuffer putChar(char value) { return put(value); } final public char getChar(int index) { return get(index); } final public CharBuffer putChar(int index, char value) { return put(index, value); };
- final public short getShort() { short a = nio_get_Short(this, position(), limit()); inc_pos(2); return a; } final public CharBuffer putShort(short value) { nio_put_Short(this, position(), limit(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index, limit()); return a; } final public CharBuffer putShort(int index, short value) { nio_put_Short(this, index, limit(), value); return this; };
- final public int getInt() { int a = nio_get_Int(this, position(), limit()); inc_pos(4); return a; } final public CharBuffer putInt(int value) { nio_put_Int(this, position(), limit(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index, limit()); return a; } final public CharBuffer putInt(int index, int value) { nio_put_Int(this, index, limit(), value); return this; };
- final public long getLong() { long a = nio_get_Long(this, position(), limit()); inc_pos(8); return a; } final public CharBuffer putLong(long value) { nio_put_Long(this, position(), limit(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index, limit()); return a; } final public CharBuffer putLong(int index, long value) { nio_put_Long(this, index, limit(), value); return this; };
- final public float getFloat() { float a = nio_get_Float(this, position(), limit()); inc_pos(4); return a; } final public CharBuffer putFloat(float value) { nio_put_Float(this, position(), limit(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index, limit()); return a; } final public CharBuffer putFloat(int index, float value) { nio_put_Float(this, index, limit(), value); return this; };
- final public double getDouble() { double a = nio_get_Double(this, position(), limit()); inc_pos(8); return a; } final public CharBuffer putDouble(double value) { nio_put_Double(this, position(), limit(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index, limit()); return a; } final public CharBuffer putDouble(int index, double value) { nio_put_Double(this, index, limit(), value); return this; };
+ /**
+ * Absolute get method. Reads the character at position <code>index</code>.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ */
final public char get(int index)
{
+ if (index < 0
+ || index >= limit ())
+ throw new IndexOutOfBoundsException ();
+
return backing_buffer[index];
}
+ /**
+ * Absolute put method. Writes <code>value</value> to position
+ * <code>index</code> in the buffer.
+ *
+ * @exception IndexOutOfBoundsException If index is negative or not smaller
+ * than the buffer's limit.
+ * @exception ReadOnlyBufferException If this buffer is read-only.
+ */
final public CharBuffer put(int index, char b)
{
+ if (index < 0
+ || index >= limit ())
+ throw new IndexOutOfBoundsException ();
+
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
backing_buffer[index] = b;
return this;
}
@@ -207,6 +201,6 @@ public final class CharBufferImpl extends CharBuffer
public final ByteOrder order()
{
- return endian;
+ return ByteOrder.BIG_ENDIAN;
}
}
diff --git a/libjava/gnu/java/nio/DoubleBufferImpl.java b/libjava/gnu/java/nio/DoubleBufferImpl.java
index de0e671..9734875 100644
--- a/libjava/gnu/java/nio/DoubleBufferImpl.java
+++ b/libjava/gnu/java/nio/DoubleBufferImpl.java
@@ -38,100 +38,66 @@ exception statement from your version. */
package gnu.java.nio;
import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
+import java.nio.ByteOrder;
import java.nio.DoubleBuffer;
-import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
-import java.nio.LongBuffer;
-import java.nio.ShortBuffer;
+import java.nio.ReadOnlyBufferException;
+/**
+ * This is a Heap memory implementation
+ */
public final class DoubleBufferImpl extends DoubleBuffer
{
- private int array_offset;
- private boolean ro;
+ private boolean readOnly;
public DoubleBufferImpl(int cap, int off, int lim)
{
+ super (cap, lim, off, 0);
this.backing_buffer = new double[cap];
- this.cap = cap;
- this.limit(lim);
- this.position(off);
+ readOnly = false;
}
public DoubleBufferImpl(double[] array, int off, int lim)
{
+ super (array.length, lim, off, 0);
this.backing_buffer = array;
- this.cap = array.length;
- this.limit(lim);
- this.position(off);
+ readOnly = false;
}
public DoubleBufferImpl(DoubleBufferImpl copy)
{
+ super (copy.capacity (), copy.limit (), copy.position (), 0);
backing_buffer = copy.backing_buffer;
- ro = copy.ro;
- limit(copy.limit());
- position(copy.position());
+ readOnly = copy.isReadOnly ();
}
- void inc_pos(int a)
+ DoubleBufferImpl (byte[] copy)
{
- position(position() + a);
+ super (copy.length, copy.length, 0, 0);
+ this.backing_buffer = copy != null ? nio_cast (copy) : null;
+ readOnly = false;
}
-
- DoubleBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native byte nio_get_Byte(DoubleBufferImpl b, int index, int limit);
- private static native void nio_put_Byte(DoubleBufferImpl b, int index, int limit, byte value);
- public ByteBuffer asByteBuffer() { ByteBufferImpl res = new ByteBufferImpl(backing_buffer); res.limit((limit()*1)/8); return res; }
-
- DoubleBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native char nio_get_Char(DoubleBufferImpl b, int index, int limit);
- private static native void nio_put_Char(DoubleBufferImpl b, int index, int limit, char value);
- public CharBuffer asCharBuffer() { CharBufferImpl res = new CharBufferImpl(backing_buffer); res.limit((limit()*2)/8); return res; }
-
- DoubleBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native short nio_get_Short(DoubleBufferImpl b, int index, int limit);
- private static native void nio_put_Short(DoubleBufferImpl b, int index, int limit, short value);
- public ShortBuffer asShortBuffer() { ShortBufferImpl res = new ShortBufferImpl(backing_buffer); res.limit((limit()*2)/8); return res; }
- DoubleBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native int nio_get_Int(DoubleBufferImpl b, int index, int limit);
- private static native void nio_put_Int(DoubleBufferImpl b, int index, int limit, int value);
- public IntBuffer asIntBuffer() { IntBufferImpl res = new IntBufferImpl(backing_buffer); res.limit((limit()*4)/8); return res; }
+ private static native byte nio_get_Byte (DoubleBufferImpl b, int index, int limit);
- DoubleBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native long nio_get_Long(DoubleBufferImpl b, int index, int limit);
- private static native void nio_put_Long(DoubleBufferImpl b, int index, int limit, long value);
- public LongBuffer asLongBuffer() { LongBufferImpl res = new LongBufferImpl(backing_buffer); res.limit((limit()*8)/8); return res; }
+ private static native void nio_put_Byte (DoubleBufferImpl b, int index, int limit, byte value);
- DoubleBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native float nio_get_Float(DoubleBufferImpl b, int index, int limit);
- private static native void nio_put_Float(DoubleBufferImpl b, int index, int limit, float value);
- public FloatBuffer asFloatBuffer() { FloatBufferImpl res = new FloatBufferImpl(backing_buffer); res.limit((limit()*4)/8); return res; }
-
- DoubleBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native double nio_get_Double(DoubleBufferImpl b, int index, int limit);
- private static native void nio_put_Double(DoubleBufferImpl b, int index, int limit, double value);
- public DoubleBuffer asDoubleBuffer() { DoubleBufferImpl res = new DoubleBufferImpl(backing_buffer); res.limit((limit()*8)/8); return res; }
+ public ByteBuffer asByteBuffer ()
+ {
+ ByteBufferImpl res = new ByteBufferImpl (backing_buffer);
+ res.limit ((limit () * 1) / 8);
+ return res;
+ }
- private static native double[] nio_cast(byte[]copy);
- private static native double[] nio_cast(char[]copy);
- private static native double[] nio_cast(short[]copy);
- private static native double[] nio_cast(long[]copy);
- private static native double[] nio_cast(int[]copy);
- private static native double[] nio_cast(float[]copy);
- private static native double[] nio_cast(double[]copy);
+ private static native double[] nio_cast (byte[] copy);
- public boolean isReadOnly()
+ public boolean isReadOnly ()
{
- return ro;
+ return readOnly;
}
- public DoubleBuffer slice()
+ public DoubleBuffer slice ()
{
- DoubleBufferImpl A = new DoubleBufferImpl(this);
- A.array_offset = position();
- return A;
+ return new DoubleBufferImpl (this);
}
public DoubleBuffer duplicate()
@@ -141,9 +107,9 @@ public final class DoubleBufferImpl extends DoubleBuffer
public DoubleBuffer asReadOnlyBuffer()
{
- DoubleBufferImpl a = new DoubleBufferImpl(this);
- a.ro = true;
- return a;
+ DoubleBufferImpl result = new DoubleBufferImpl (this);
+ result.readOnly = true;
+ return result;
}
public DoubleBuffer compact()
@@ -153,7 +119,7 @@ public final class DoubleBufferImpl extends DoubleBuffer
public boolean isDirect()
{
- return backing_buffer != null;
+ return false;
}
final public double get()
@@ -165,6 +131,9 @@ public final class DoubleBufferImpl extends DoubleBuffer
final public DoubleBuffer put(double b)
{
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
backing_buffer[position()] = b;
position(position()+1);
return this;
@@ -177,14 +146,15 @@ public final class DoubleBufferImpl extends DoubleBuffer
final public DoubleBuffer put(int index, double b)
{
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
backing_buffer[index] = b;
return this;
}
-
- final public char getChar() { char a = nio_get_Char(this, position(), limit()); inc_pos(2); return a; } final public DoubleBuffer putChar(char value) { nio_put_Char(this, position(), limit(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index, limit()); return a; } final public DoubleBuffer putChar(int index, char value) { nio_put_Char(this, index, limit(), value); return this; };
- final public short getShort() { short a = nio_get_Short(this, position(), limit()); inc_pos(2); return a; } final public DoubleBuffer putShort(short value) { nio_put_Short(this, position(), limit(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index, limit()); return a; } final public DoubleBuffer putShort(int index, short value) { nio_put_Short(this, index, limit(), value); return this; };
- final public int getInt() { int a = nio_get_Int(this, position(), limit()); inc_pos(4); return a; } final public DoubleBuffer putInt(int value) { nio_put_Int(this, position(), limit(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index, limit()); return a; } final public DoubleBuffer putInt(int index, int value) { nio_put_Int(this, index, limit(), value); return this; };
- final public long getLong() { long a = nio_get_Long(this, position(), limit()); inc_pos(8); return a; } final public DoubleBuffer putLong(long value) { nio_put_Long(this, position(), limit(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index, limit()); return a; } final public DoubleBuffer putLong(int index, long value) { nio_put_Long(this, index, limit(), value); return this; };
- final public float getFloat() { float a = nio_get_Float(this, position(), limit()); inc_pos(4); return a; } final public DoubleBuffer putFloat(float value) { nio_put_Float(this, position(), limit(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index, limit()); return a; } final public DoubleBuffer putFloat(int index, float value) { nio_put_Float(this, index, limit(), value); return this; };
- final public double getDouble() { return get(); } final public DoubleBuffer putDouble(double value) { return put(value); } final public double getDouble(int index) { return get(index); } final public DoubleBuffer putDouble(int index, double value) { return put(index, value); };
+
+ final public ByteOrder order ()
+ {
+ return ByteOrder.BIG_ENDIAN;
+ }
}
diff --git a/libjava/gnu/java/nio/FloatBufferImpl.java b/libjava/gnu/java/nio/FloatBufferImpl.java
index bab4742..27a8dea 100644
--- a/libjava/gnu/java/nio/FloatBufferImpl.java
+++ b/libjava/gnu/java/nio/FloatBufferImpl.java
@@ -38,49 +38,49 @@ exception statement from your version. */
package gnu.java.nio;
import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.DoubleBuffer;
+import java.nio.ByteOrder;
import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
-import java.nio.LongBuffer;
-import java.nio.ShortBuffer;
+import java.nio.ReadOnlyBufferException;
+/**
+ * This is a Heap memory implementation
+ */
public final class FloatBufferImpl extends FloatBuffer
{
- private int array_offset;
- private boolean ro;
+ private boolean readOnly;
public FloatBufferImpl(int cap, int off, int lim)
{
- this.backing_buffer = new float[cap];
- this.cap = cap;
- this.limit(lim);
- this.position(off);
+ super (cap, lim, off, 0);
+ this.backing_buffer = new float [cap];
+ readOnly = false;
}
public FloatBufferImpl(float[] array, int off, int lim)
{
+ super (array.length, lim, off, 0);
this.backing_buffer = array;
- this.cap = array.length;
- this.limit(lim);
- this.position(off);
+ readOnly = false;
}
public FloatBufferImpl(FloatBufferImpl copy)
{
+ super (copy.capacity (), copy.limit (), copy.position (), 0);
backing_buffer = copy.backing_buffer;
- ro = copy.ro;
- limit(copy.limit());
- position(copy.position());
+ readOnly = copy.isReadOnly ();
}
- void inc_pos(int a)
+ private static native float[] nio_cast (byte[] copy);
+
+ FloatBufferImpl (byte[] copy)
{
- position(position() + a);
+ super (copy.length, copy.length, 0, 0);
+ this.backing_buffer = copy != null ? nio_cast (copy) : null;
+ readOnly = false;
}
-
- FloatBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast (copy) : null; }
+
private static native byte nio_get_Byte (FloatBufferImpl b, int index, int limit);
+
private static native void nio_put_Byte (FloatBufferImpl b, int index, int limit, byte value);
public ByteBuffer asByteBuffer()
@@ -90,54 +90,14 @@ public final class FloatBufferImpl extends FloatBuffer
return res;
}
- FloatBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native char nio_get_Char(FloatBufferImpl b, int index, int limit);
- private static native void nio_put_Char(FloatBufferImpl b, int index, int limit, char value);
- public CharBuffer asCharBuffer() { CharBufferImpl res = new CharBufferImpl(backing_buffer); res.limit((limit()*2)/4); return res; }
-
- FloatBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native short nio_get_Short(FloatBufferImpl b, int index, int limit);
- private static native void nio_put_Short(FloatBufferImpl b, int index, int limit, short value);
- public ShortBuffer asShortBuffer() { ShortBufferImpl res = new ShortBufferImpl(backing_buffer); res.limit((limit()*2)/4); return res; }
-
- FloatBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native int nio_get_Int(FloatBufferImpl b, int index, int limit);
- private static native void nio_put_Int(FloatBufferImpl b, int index, int limit, int value);
- public IntBuffer asIntBuffer() { IntBufferImpl res = new IntBufferImpl(backing_buffer); res.limit((limit()*4)/4); return res; }
-
- FloatBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native long nio_get_Long(FloatBufferImpl b, int index, int limit);
- private static native void nio_put_Long(FloatBufferImpl b, int index, int limit, long value);
- public LongBuffer asLongBuffer() { LongBufferImpl res = new LongBufferImpl(backing_buffer); res.limit((limit()*8)/4); return res; }
-
- FloatBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native float nio_get_Float(FloatBufferImpl b, int index, int limit);
- private static native void nio_put_Float(FloatBufferImpl b, int index, int limit, float value);
- public FloatBuffer asFloatBuffer() { FloatBufferImpl res = new FloatBufferImpl(backing_buffer); res.limit((limit()*4)/4); return res; }
-
- FloatBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native double nio_get_Double(FloatBufferImpl b, int index, int limit);
- private static native void nio_put_Double(FloatBufferImpl b, int index, int limit, double value);
- public DoubleBuffer asDoubleBuffer() { DoubleBufferImpl res = new DoubleBufferImpl(backing_buffer); res.limit((limit()*8)/4); return res; }
-
- private static native float[] nio_cast(byte[]copy);
- private static native float[] nio_cast(char[]copy);
- private static native float[] nio_cast(short[]copy);
- private static native float[] nio_cast(long[]copy);
- private static native float[] nio_cast(int[]copy);
- private static native float[] nio_cast(float[]copy);
- private static native float[] nio_cast(double[]copy);
-
- public boolean isReadOnly()
+ public boolean isReadOnly ()
{
- return ro;
+ return readOnly;
}
public FloatBuffer slice()
{
- FloatBufferImpl A = new FloatBufferImpl(this);
- A.array_offset = position();
- return A;
+ return new FloatBufferImpl (this);
}
public FloatBuffer duplicate()
@@ -147,9 +107,9 @@ public final class FloatBufferImpl extends FloatBuffer
public FloatBuffer asReadOnlyBuffer()
{
- FloatBufferImpl a = new FloatBufferImpl(this);
- a.ro = true;
- return a;
+ FloatBufferImpl result = new FloatBufferImpl (this);
+ result.readOnly = true;
+ return result;
}
public FloatBuffer compact()
@@ -159,7 +119,7 @@ public final class FloatBufferImpl extends FloatBuffer
public boolean isDirect()
{
- return backing_buffer != null;
+ return false;
}
final public float get()
@@ -171,6 +131,9 @@ public final class FloatBufferImpl extends FloatBuffer
final public FloatBuffer put(float b)
{
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
backing_buffer[position()] = b;
position(position()+1);
return this;
@@ -183,14 +146,15 @@ public final class FloatBufferImpl extends FloatBuffer
final public FloatBuffer put(int index, float b)
{
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
backing_buffer[index] = b;
return this;
}
- final public char getChar() { char a = nio_get_Char(this, position(), limit()); inc_pos(2); return a; } final public FloatBuffer putChar(char value) { nio_put_Char(this, position(), limit(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index, limit()); return a; } final public FloatBuffer putChar(int index, char value) { nio_put_Char(this, index, limit(), value); return this; };
- final public short getShort() { short a = nio_get_Short(this, position(), limit()); inc_pos(2); return a; } final public FloatBuffer putShort(short value) { nio_put_Short(this, position(), limit(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index, limit()); return a; } final public FloatBuffer putShort(int index, short value) { nio_put_Short(this, index, limit(), value); return this; };
- final public int getInt() { int a = nio_get_Int(this, position(), limit()); inc_pos(4); return a; } final public FloatBuffer putInt(int value) { nio_put_Int(this, position(), limit(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index, limit()); return a; } final public FloatBuffer putInt(int index, int value) { nio_put_Int(this, index, limit(), value); return this; };
- final public long getLong() { long a = nio_get_Long(this, position(), limit()); inc_pos(8); return a; } final public FloatBuffer putLong(long value) { nio_put_Long(this, position(), limit(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index, limit()); return a; } final public FloatBuffer putLong(int index, long value) { nio_put_Long(this, index, limit(), value); return this; };
- final public float getFloat() { return get(); } final public FloatBuffer putFloat(float value) { return put(value); } final public float getFloat(int index) { return get(index); } final public FloatBuffer putFloat(int index, float value) { return put(index, value); };
- final public double getDouble() { double a = nio_get_Double(this, position(), limit()); inc_pos(8); return a; } final public FloatBuffer putDouble(double value) { nio_put_Double(this, position(), limit(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index, limit()); return a; } final public FloatBuffer putDouble(int index, double value) { nio_put_Double(this, index, limit(), value); return this; };
+ final public ByteOrder order ()
+ {
+ return ByteOrder.BIG_ENDIAN;
+ }
}
diff --git a/libjava/gnu/java/nio/IntBufferImpl.java b/libjava/gnu/java/nio/IntBufferImpl.java
index cccc418..fda2d68 100644
--- a/libjava/gnu/java/nio/IntBufferImpl.java
+++ b/libjava/gnu/java/nio/IntBufferImpl.java
@@ -38,100 +38,66 @@ exception statement from your version. */
package gnu.java.nio;
import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.DoubleBuffer;
-import java.nio.FloatBuffer;
+import java.nio.ByteOrder;
import java.nio.IntBuffer;
-import java.nio.LongBuffer;
-import java.nio.ShortBuffer;
+import java.nio.ReadOnlyBufferException;
+/**
+ * This is a Heap memory implementation
+ */
public final class IntBufferImpl extends IntBuffer
{
- private int array_offset;
- private boolean ro;
+ private boolean readOnly;
public IntBufferImpl(int cap, int off, int lim)
{
+ super (cap, lim, off, 0);
this.backing_buffer = new int[cap];
- this.cap = cap;
- this.limit(lim);
- this.position(off);
+ readOnly = false;
}
public IntBufferImpl(int[] array, int off, int lim)
{
+ super (array.length, lim, off, 0);
this.backing_buffer = array;
- this.cap = array.length;
- this.limit(lim);
- this.position(off);
+ readOnly = false;
}
public IntBufferImpl(IntBufferImpl copy)
{
+ super (copy.capacity (), copy.limit (), copy.position (), 0);
backing_buffer = copy.backing_buffer;
- ro = copy.ro;
- limit(copy.limit());
- position(copy.position());
+ readOnly = copy.isReadOnly ();
}
- void inc_pos(int a)
+ private static native int[] nio_cast (byte[] copy);
+
+ IntBufferImpl (byte[] copy)
{
- position(position() + a);
+ super (copy.length, copy.length, 0, 0);
+ this.backing_buffer = copy != null ? nio_cast (copy) : null;
+ readOnly = false;
}
- IntBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native byte nio_get_Byte(IntBufferImpl b, int index, int limit);
- private static native void nio_put_Byte(IntBufferImpl b, int index, int limit, byte value);
- public ByteBuffer asByteBuffer() { ByteBufferImpl res = new ByteBufferImpl(backing_buffer); res.limit((limit()*1)/4); return res; }
-
- IntBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native char nio_get_Char(IntBufferImpl b, int index, int limit);
- private static native void nio_put_Char(IntBufferImpl b, int index, int limit, char value);
- public CharBuffer asCharBuffer() { CharBufferImpl res = new CharBufferImpl(backing_buffer); res.limit((limit()*2)/4); return res; }
-
- IntBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native short nio_get_Short(IntBufferImpl b, int index, int limit);
- private static native void nio_put_Short(IntBufferImpl b, int index, int limit, short value);
- public ShortBuffer asShortBuffer() { ShortBufferImpl res = new ShortBufferImpl(backing_buffer); res.limit((limit()*2)/4); return res; }
-
- IntBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native int nio_get_Int(IntBufferImpl b, int index, int limit);
- private static native void nio_put_Int(IntBufferImpl b, int index, int limit, int value);
- public IntBuffer asIntBuffer() { IntBufferImpl res = new IntBufferImpl(backing_buffer); res.limit((limit()*4)/4); return res; }
-
- IntBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native long nio_get_Long(IntBufferImpl b, int index, int limit);
- private static native void nio_put_Long(IntBufferImpl b, int index, int limit, long value);
- public LongBuffer asLongBuffer() { LongBufferImpl res = new LongBufferImpl(backing_buffer); res.limit((limit()*8)/4); return res; }
-
- IntBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native float nio_get_Float(IntBufferImpl b, int index, int limit);
- private static native void nio_put_Float(IntBufferImpl b, int index, int limit, float value);
- public FloatBuffer asFloatBuffer() { FloatBufferImpl res = new FloatBufferImpl(backing_buffer); res.limit((limit()*4)/4); return res; }
+ private static native byte nio_get_Byte (IntBufferImpl b, int index, int limit);
- IntBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native double nio_get_Double(IntBufferImpl b, int index, int limit);
- private static native void nio_put_Double(IntBufferImpl b, int index, int limit, double value);
- public DoubleBuffer asDoubleBuffer() { DoubleBufferImpl res = new DoubleBufferImpl(backing_buffer); res.limit((limit()*8)/4); return res; }
+ private static native void nio_put_Byte (IntBufferImpl b, int index, int limit, byte value);
- private static native int[] nio_cast(byte[]copy);
- private static native int[] nio_cast(char[]copy);
- private static native int[] nio_cast(short[]copy);
- private static native int[] nio_cast(long[]copy);
- private static native int[] nio_cast(int[]copy);
- private static native int[] nio_cast(float[]copy);
- private static native int[] nio_cast(double[]copy);
+ public ByteBuffer asByteBuffer ()
+ {
+ ByteBufferImpl res = new ByteBufferImpl (backing_buffer);
+ res.limit ((limit () * 1) / 4);
+ return res;
+ }
public boolean isReadOnly()
{
- return ro;
+ return readOnly;
}
public IntBuffer slice()
{
- IntBufferImpl A = new IntBufferImpl(this);
- A.array_offset = position();
- return A;
+ return new IntBufferImpl (this);
}
public IntBuffer duplicate()
@@ -141,9 +107,9 @@ public final class IntBufferImpl extends IntBuffer
public IntBuffer asReadOnlyBuffer()
{
- IntBufferImpl a = new IntBufferImpl(this);
- a.ro = true;
- return a;
+ IntBufferImpl result = new IntBufferImpl (this);
+ result.readOnly = true;
+ return result;
}
public IntBuffer compact()
@@ -153,7 +119,7 @@ public final class IntBufferImpl extends IntBuffer
public boolean isDirect()
{
- return backing_buffer != null;
+ return false;
}
final public int get()
@@ -165,6 +131,9 @@ public final class IntBufferImpl extends IntBuffer
final public IntBuffer put(int b)
{
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
backing_buffer[position()] = b;
position(position()+1);
return this;
@@ -177,14 +146,15 @@ public final class IntBufferImpl extends IntBuffer
final public IntBuffer put(int index, int b)
{
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
backing_buffer[index] = b;
return this;
}
-
- final public char getChar() { char a = nio_get_Char(this, position(), limit()); inc_pos(2); return a; } final public IntBuffer putChar(char value) { nio_put_Char(this, position(), limit(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index, limit()); return a; } final public IntBuffer putChar(int index, char value) { nio_put_Char(this, index, limit(), value); return this; };
- final public short getShort() { short a = nio_get_Short(this, position(), limit()); inc_pos(2); return a; } final public IntBuffer putShort(short value) { nio_put_Short(this, position(), limit(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index, limit()); return a; } final public IntBuffer putShort(int index, short value) { nio_put_Short(this, index, limit(), value); return this; };
- final public int getInt() { return get(); } final public IntBuffer putInt(int value) { return put(value); } final public int getInt(int index) { return get(index); } final public IntBuffer putInt(int index, int value) { return put(index, value); };
- final public long getLong() { long a = nio_get_Long(this, position(), limit()); inc_pos(8); return a; } final public IntBuffer putLong(long value) { nio_put_Long(this, position(), limit(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index, limit()); return a; } final public IntBuffer putLong(int index, long value) { nio_put_Long(this, index, limit(), value); return this; };
- final public float getFloat() { float a = nio_get_Float(this, position(), limit()); inc_pos(4); return a; } final public IntBuffer putFloat(float value) { nio_put_Float(this, position(), limit(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index, limit()); return a; } final public IntBuffer putFloat(int index, float value) { nio_put_Float(this, index, limit(), value); return this; };
- final public double getDouble() { double a = nio_get_Double(this, position(), limit()); inc_pos(8); return a; } final public IntBuffer putDouble(double value) { nio_put_Double(this, position(), limit(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index, limit()); return a; } final public IntBuffer putDouble(int index, double value) { nio_put_Double(this, index, limit(), value); return this; };
+
+ final public ByteOrder order ()
+ {
+ return ByteOrder.BIG_ENDIAN;
+ }
}
diff --git a/libjava/gnu/java/nio/LongBufferImpl.java b/libjava/gnu/java/nio/LongBufferImpl.java
index 8f29b06..5dc4992 100644
--- a/libjava/gnu/java/nio/LongBufferImpl.java
+++ b/libjava/gnu/java/nio/LongBufferImpl.java
@@ -38,100 +38,66 @@ exception statement from your version. */
package gnu.java.nio;
import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.DoubleBuffer;
-import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
+import java.nio.ByteOrder;
import java.nio.LongBuffer;
-import java.nio.ShortBuffer;
+import java.nio.ReadOnlyBufferException;
+/**
+ * This is a Heap memory implementation
+ */
public final class LongBufferImpl extends LongBuffer
{
- private int array_offset;
- private boolean ro;
+ private boolean readOnly;
public LongBufferImpl(int cap, int off, int lim)
{
+ super (cap, lim, off, 0);
this.backing_buffer = new long[cap];
- this.cap = cap ;
- this.limit(lim);
- this.position(off);
+ readOnly = false;
}
public LongBufferImpl(long[] array, int off, int lim)
{
+ super (array.length, lim, off, 0);
this.backing_buffer = array;
- this.cap = array.length;
- this.limit(lim);
- this.position(off);
+ readOnly = false;
}
public LongBufferImpl(LongBufferImpl copy)
{
+ super (copy.capacity (), copy.limit (), copy.position (), 0);
backing_buffer = copy.backing_buffer;
- ro = copy.ro;
- limit(copy.limit());
- position(copy.position());
+ readOnly = copy.isReadOnly ();
}
- void inc_pos(int a)
+ private static native long[] nio_cast (byte[] copy);
+
+ LongBufferImpl (byte[] copy)
{
- position(position() + a);
+ super (copy.length, copy.length, 0, 0);
+ this.backing_buffer = copy != null ? nio_cast (copy) : null;
+ readOnly = false;
}
- LongBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native byte nio_get_Byte(LongBufferImpl b, int index, int limit);
- private static native void nio_put_Byte(LongBufferImpl b, int index, int limit, byte value);
- public ByteBuffer asByteBuffer() { ByteBufferImpl res = new ByteBufferImpl(backing_buffer); res.limit((limit()*1)/8); return res; }
-
- LongBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native char nio_get_Char(LongBufferImpl b, int index, int limit);
- private static native void nio_put_Char(LongBufferImpl b, int index, int limit, char value);
- public CharBuffer asCharBuffer() { CharBufferImpl res = new CharBufferImpl(backing_buffer); res.limit((limit()*2)/8); return res; }
-
- LongBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native short nio_get_Short(LongBufferImpl b, int index, int limit);
- private static native void nio_put_Short(LongBufferImpl b, int index, int limit, short value);
- public ShortBuffer asShortBuffer() { ShortBufferImpl res = new ShortBufferImpl(backing_buffer); res.limit((limit()*2)/8); return res; }
-
- LongBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native int nio_get_Int(LongBufferImpl b, int index, int limit);
- private static native void nio_put_Int(LongBufferImpl b, int index, int limit, int value);
- public IntBuffer asIntBuffer() { IntBufferImpl res = new IntBufferImpl(backing_buffer); res.limit((limit()*4)/8); return res; }
-
- LongBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native long nio_get_Long(LongBufferImpl b, int index, int limit);
- private static native void nio_put_Long(LongBufferImpl b, int index, int limit, long value);
- public LongBuffer asLongBuffer() { LongBufferImpl res = new LongBufferImpl(backing_buffer); res.limit((limit()*8)/8); return res; }
+ private static native byte nio_get_Byte (LongBufferImpl b, int index, int limit);
- LongBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native float nio_get_Float(LongBufferImpl b, int index, int limit);
- private static native void nio_put_Float(LongBufferImpl b, int index, int limit, float value);
- public FloatBuffer asFloatBuffer() { FloatBufferImpl res = new FloatBufferImpl(backing_buffer); res.limit((limit()*4)/8); return res; }
+ private static native void nio_put_Byte (LongBufferImpl b, int index, int limit, byte value);
- LongBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native double nio_get_Double(LongBufferImpl b, int index, int limit);
- private static native void nio_put_Double(LongBufferImpl b, int index, int limit, double value);
- public DoubleBuffer asDoubleBuffer() { DoubleBufferImpl res = new DoubleBufferImpl(backing_buffer); res.limit((limit()*8)/8); return res; }
-
- private static native long[] nio_cast(byte[]copy);
- private static native long[] nio_cast(char[]copy);
- private static native long[] nio_cast(short[]copy);
- private static native long[] nio_cast(long[]copy);
- private static native long[] nio_cast(int[]copy);
- private static native long[] nio_cast(float[]copy);
- private static native long[] nio_cast(double[]copy);
+ public ByteBuffer asByteBuffer ()
+ {
+ ByteBufferImpl res = new ByteBufferImpl (backing_buffer);
+ res.limit ((limit () * 1) / 8);
+ return res;
+ }
public boolean isReadOnly()
{
- return ro;
+ return readOnly;
}
public LongBuffer slice()
{
- LongBufferImpl A = new LongBufferImpl(this);
- A.array_offset = position();
- return A;
+ return new LongBufferImpl (this);
}
public LongBuffer duplicate()
@@ -141,9 +107,9 @@ public final class LongBufferImpl extends LongBuffer
public LongBuffer asReadOnlyBuffer()
{
- LongBufferImpl a = new LongBufferImpl(this);
- a.ro = true;
- return a;
+ LongBufferImpl result = new LongBufferImpl (this);
+ result.readOnly = true;
+ return result;
}
public LongBuffer compact()
@@ -153,7 +119,7 @@ public final class LongBufferImpl extends LongBuffer
public boolean isDirect()
{
- return backing_buffer != null;
+ return false;
}
final public long get()
@@ -165,6 +131,9 @@ public final class LongBufferImpl extends LongBuffer
final public LongBuffer put(long b)
{
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
backing_buffer[position()] = b;
position(position()+1);
return this;
@@ -177,14 +146,15 @@ public final class LongBufferImpl extends LongBuffer
final public LongBuffer put(int index, long b)
{
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
backing_buffer[index] = b;
return this;
}
- final public char getChar() { char a = nio_get_Char(this, position(), limit()); inc_pos(2); return a; } final public LongBuffer putChar(char value) { nio_put_Char(this, position(), limit(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index, limit()); return a; } final public LongBuffer putChar(int index, char value) { nio_put_Char(this, index, limit(), value); return this; };
- final public short getShort() { short a = nio_get_Short(this, position(), limit()); inc_pos(2); return a; } final public LongBuffer putShort(short value) { nio_put_Short(this, position(), limit(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index, limit()); return a; } final public LongBuffer putShort(int index, short value) { nio_put_Short(this, index, limit(), value); return this; };
- final public int getInt() { int a = nio_get_Int(this, position(), limit()); inc_pos(4); return a; } final public LongBuffer putInt(int value) { nio_put_Int(this, position(), limit(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index, limit()); return a; } final public LongBuffer putInt(int index, int value) { nio_put_Int(this, index, limit(), value); return this; };
- final public long getLong() { return get(); } final public LongBuffer putLong(long value) { return put(value); } final public long getLong(int index) { return get(index); } final public LongBuffer putLong(int index, long value) { return put(index, value); };
- final public float getFloat() { float a = nio_get_Float(this, position(), limit()); inc_pos(4); return a; } final public LongBuffer putFloat(float value) { nio_put_Float(this, position(), limit(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index, limit()); return a; } final public LongBuffer putFloat(int index, float value) { nio_put_Float(this, index, limit(), value); return this; };
- final public double getDouble() { double a = nio_get_Double(this, position(), limit()); inc_pos(8); return a; } final public LongBuffer putDouble(double value) { nio_put_Double(this, position(), limit(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index, limit()); return a; } final public LongBuffer putDouble(int index, double value) { nio_put_Double(this, index, limit(), value); return this; };
+ final public ByteOrder order ()
+ {
+ return ByteOrder.BIG_ENDIAN;
+ }
}
diff --git a/libjava/gnu/java/nio/ShortBufferImpl.java b/libjava/gnu/java/nio/ShortBufferImpl.java
index bccb2d0..c55f098 100644
--- a/libjava/gnu/java/nio/ShortBufferImpl.java
+++ b/libjava/gnu/java/nio/ShortBufferImpl.java
@@ -38,100 +38,66 @@ exception statement from your version. */
package gnu.java.nio;
import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.DoubleBuffer;
-import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
-import java.nio.LongBuffer;
+import java.nio.ByteOrder;
import java.nio.ShortBuffer;
+import java.nio.ReadOnlyBufferException;
+/**
+ * This is a Heap memory implementation
+ */
public final class ShortBufferImpl extends ShortBuffer
{
- private int array_offset;
- private boolean ro;
+ private boolean readOnly;
public ShortBufferImpl(int cap, int off, int lim)
{
- this.backing_buffer = new short[cap];
- this.cap = cap ;
- this.limit(lim);
- this.position(off);
+ super (cap, lim, off, 0);
+ this.backing_buffer = new short [cap];
+ readOnly = false;
}
public ShortBufferImpl(short[] array, int off, int lim)
{
+ super (array.length, lim, off, 0);
this.backing_buffer = array;
- this.cap = array.length;
- this.limit(lim);
- this.position(off);
+ readOnly = false;
}
public ShortBufferImpl(ShortBufferImpl copy)
{
+ super (copy.capacity (), copy.limit (), copy.position (), 0);
backing_buffer = copy.backing_buffer;
- ro = copy.ro;
- limit(copy.limit());
- position(copy.position());
+ readOnly = copy.isReadOnly ();
}
- void inc_pos(int a)
+ private static native short[] nio_cast (byte[] copy);
+
+ ShortBufferImpl (byte[] copy)
{
- position(position() + a);
+ super (copy.length, copy.length, 0, 0);
+ this.backing_buffer = copy != null ? nio_cast (copy) : null;
+ readOnly = false;
+ }
+
+ private static native byte nio_get_Byte (ShortBufferImpl b, int index, int limit);
+
+ private static native void nio_put_Byte (ShortBufferImpl b, int index, int limit, byte value);
+
+ public ByteBuffer asByteBuffer ()
+ {
+ ByteBufferImpl res = new ByteBufferImpl (backing_buffer);
+ res.limit ((limit () * 1) / 2);
+ return res;
}
-
- ShortBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native byte nio_get_Byte(ShortBufferImpl b, int index, int limit);
- private static native void nio_put_Byte(ShortBufferImpl b, int index, int limit, byte value);
- public ByteBuffer asByteBuffer() { ByteBufferImpl res = new ByteBufferImpl(backing_buffer); res.limit((limit()*1)/2); return res; }
-
- ShortBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native char nio_get_Char(ShortBufferImpl b, int index, int limit);
- private static native void nio_put_Char(ShortBufferImpl b, int index, int limit, char value);
- public CharBuffer asCharBuffer() { CharBufferImpl res = new CharBufferImpl(backing_buffer); res.limit((limit()*2)/2); return res; }
-
- ShortBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native short nio_get_Short(ShortBufferImpl b, int index, int limit);
- private static native void nio_put_Short(ShortBufferImpl b, int index, int limit, short value);
- public ShortBuffer asShortBuffer() { ShortBufferImpl res = new ShortBufferImpl(backing_buffer); res.limit((limit()*2)/2); return res; }
-
- ShortBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native int nio_get_Int(ShortBufferImpl b, int index, int limit);
- private static native void nio_put_Int(ShortBufferImpl b, int index, int limit, int value);
- public IntBuffer asIntBuffer() { IntBufferImpl res = new IntBufferImpl(backing_buffer); res.limit((limit()*4)/2); return res; }
-
- ShortBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native long nio_get_Long(ShortBufferImpl b, int index, int limit);
- private static native void nio_put_Long(ShortBufferImpl b, int index, int limit, long value);
- public LongBuffer asLongBuffer() { LongBufferImpl res = new LongBufferImpl(backing_buffer); res.limit((limit()*8)/2); return res; }
-
- ShortBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native float nio_get_Float(ShortBufferImpl b, int index, int limit);
- private static native void nio_put_Float(ShortBufferImpl b, int index, int limit, float value);
- public FloatBuffer asFloatBuffer() { FloatBufferImpl res = new FloatBufferImpl(backing_buffer); res.limit((limit()*4)/2); return res; }
-
- ShortBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; }
- private static native double nio_get_Double(ShortBufferImpl b, int index, int limit);
- private static native void nio_put_Double(ShortBufferImpl b, int index, int limit, double value);
- public DoubleBuffer asDoubleBuffer() { DoubleBufferImpl res = new DoubleBufferImpl(backing_buffer); res.limit((limit()*8)/2); return res; }
-
- private static native short[] nio_cast(byte[]copy);
- private static native short[] nio_cast(char[]copy);
- private static native short[] nio_cast(short[]copy);
- private static native short[] nio_cast(long[]copy);
- private static native short[] nio_cast(int[]copy);
- private static native short[] nio_cast(float[]copy);
- private static native short[] nio_cast(double[]copy);
public boolean isReadOnly()
{
- return ro;
+ return readOnly;
}
public ShortBuffer slice()
{
- ShortBufferImpl a = new ShortBufferImpl(this);
- a.array_offset = position();
- return a;
+ return new ShortBufferImpl (this);
}
public ShortBuffer duplicate()
@@ -141,9 +107,9 @@ public final class ShortBufferImpl extends ShortBuffer
public ShortBuffer asReadOnlyBuffer()
{
- ShortBufferImpl a = new ShortBufferImpl(this);
- a.ro = true;
- return a;
+ ShortBufferImpl result = new ShortBufferImpl (this);
+ result.readOnly = true;
+ return result;
}
public ShortBuffer compact()
@@ -153,7 +119,7 @@ public final class ShortBufferImpl extends ShortBuffer
public boolean isDirect()
{
- return backing_buffer != null;
+ return false;
}
final public short get()
@@ -165,6 +131,9 @@ public final class ShortBufferImpl extends ShortBuffer
final public ShortBuffer put(short b)
{
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
backing_buffer[position()] = b;
position(position()+1);
return this;
@@ -177,14 +146,15 @@ public final class ShortBufferImpl extends ShortBuffer
final public ShortBuffer put(int index, short b)
{
+ if (readOnly)
+ throw new ReadOnlyBufferException ();
+
backing_buffer[index] = b;
return this;
}
-
- final public char getChar() { char a = nio_get_Char(this, position(), limit()); inc_pos(2); return a; } final public ShortBuffer putChar(char value) { nio_put_Char(this, position(), limit(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index, limit()); return a; } final public ShortBuffer putChar(int index, char value) { nio_put_Char(this, index, limit(), value); return this; };
- final public short getShort() { return get(); } final public ShortBuffer putShort(short value) { return put(value); } final public short getShort(int index) { return get(index); } final public ShortBuffer putShort(int index, short value) { return put(index, value); };
- final public int getInt() { int a = nio_get_Int(this, position(), limit()); inc_pos(4); return a; } final public ShortBuffer putInt(int value) { nio_put_Int(this, position(), limit(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index, limit()); return a; } final public ShortBuffer putInt(int index, int value) { nio_put_Int(this, index, limit(), value); return this; };
- final public long getLong() { long a = nio_get_Long(this, position(), limit()); inc_pos(8); return a; } final public ShortBuffer putLong(long value) { nio_put_Long(this, position(), limit(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index, limit()); return a; } final public ShortBuffer putLong(int index, long value) { nio_put_Long(this, index, limit(), value); return this; };
- final public float getFloat() { float a = nio_get_Float(this, position(), limit()); inc_pos(4); return a; } final public ShortBuffer putFloat(float value) { nio_put_Float(this, position(), limit(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index, limit()); return a; } final public ShortBuffer putFloat(int index, float value) { nio_put_Float(this, index, limit(), value); return this; };
- final public double getDouble() { double a = nio_get_Double(this, position(), limit()); inc_pos(8); return a; } final public ShortBuffer putDouble(double value) { nio_put_Double(this, position(), limit(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index, limit()); return a; } final public ShortBuffer putDouble(int index, double value) { nio_put_Double(this, index, limit(), value); return this; };
+
+ final public ByteOrder order ()
+ {
+ return ByteOrder.BIG_ENDIAN;
+ }
}