diff options
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/java/Makefile.am | 2 | ||||
-rw-r--r-- | gnu/java/nio/ByteBufferImpl.java | 102 | ||||
-rw-r--r-- | gnu/java/nio/CharBufferImpl.java | 110 | ||||
-rw-r--r-- | gnu/java/nio/DoubleBufferImpl.java | 102 | ||||
-rw-r--r-- | gnu/java/nio/FloatBufferImpl.java | 102 | ||||
-rw-r--r-- | gnu/java/nio/IntBufferImpl.java | 102 | ||||
-rw-r--r-- | gnu/java/nio/LongBufferImpl.java | 102 | ||||
-rw-r--r-- | gnu/java/nio/MappedByteFileBuffer.java | 84 | ||||
-rw-r--r-- | gnu/java/nio/MappedCharFileBuffer.java | 77 | ||||
-rw-r--r-- | gnu/java/nio/MappedDoubleFileBuffer.java | 77 | ||||
-rw-r--r-- | gnu/java/nio/MappedFloatFileBuffer.java | 77 | ||||
-rw-r--r-- | gnu/java/nio/MappedIntFileBuffer.java | 77 | ||||
-rw-r--r-- | gnu/java/nio/MappedLongFileBuffer.java | 77 | ||||
-rw-r--r-- | gnu/java/nio/MappedShortFileBuffer.java | 77 | ||||
-rw-r--r-- | gnu/java/nio/ShortBufferImpl.java | 102 |
15 files changed, 1269 insertions, 1 deletions
diff --git a/gnu/java/Makefile.am b/gnu/java/Makefile.am index 8de4d29f7..8bd7f11dc 100644 --- a/gnu/java/Makefile.am +++ b/gnu/java/Makefile.am @@ -1,3 +1,3 @@ ## Input file for automake to generate the Makefile.in used by configure -SUBDIRS = awt beans io lang locale math net rmi security text util +SUBDIRS = awt beans io lang locale math net nio rmi security text util diff --git a/gnu/java/nio/ByteBufferImpl.java b/gnu/java/nio/ByteBufferImpl.java new file mode 100644 index 000000000..00a8d2bc0 --- /dev/null +++ b/gnu/java/nio/ByteBufferImpl.java @@ -0,0 +1,102 @@ +package gnu.java.nio; +import java.nio.*; +public final class ByteBufferImpl extends java.nio. ByteBuffer +{ + private int array_offset; + byte [] backing_buffer; + private boolean ro; + public ByteBufferImpl(int cap, int off, int lim) + { + this.backing_buffer = new byte[cap]; + this.capacity(cap); + this.position(off); + this.limit(lim); + } + public ByteBufferImpl(byte[] array, int off, int lim) + { + this.backing_buffer = array; + this.capacity(array.length); + this.position(off); + this.limit(lim); + } + public ByteBufferImpl(ByteBufferImpl copy) + { + backing_buffer = copy.backing_buffer; + ro = copy.ro; + position(copy.position()); + limit(copy.limit()); + } + void inc_pos(int a) + { + position(position() + a); + } + private static native byte[] nio_cast(byte[]copy); + private static native byte[] nio_cast(char[]copy); + private static native byte[] nio_cast(short[]copy); + private static native byte[] nio_cast(long[]copy); + private static native byte[] nio_cast(int[]copy); + private static native byte[] nio_cast(float[]copy); + private static native byte[] nio_cast(double[]copy); + ByteBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native byte nio_get_Byte(ByteBufferImpl b, int index); private static native void nio_put_Byte(ByteBufferImpl b, int index, byte value); public java.nio. ByteBuffer asByteBuffer() { return new gnu.java.nio. ByteBufferImpl(backing_buffer); } + ByteBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native char nio_get_Char(ByteBufferImpl b, int index); private static native void nio_put_Char(ByteBufferImpl b, int index, char value); public java.nio. CharBuffer asCharBuffer() { return new gnu.java.nio. CharBufferImpl(backing_buffer); } + ByteBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native short nio_get_Short(ByteBufferImpl b, int index); private static native void nio_put_Short(ByteBufferImpl b, int index, short value); public java.nio. ShortBuffer asShortBuffer() { return new gnu.java.nio. ShortBufferImpl(backing_buffer); } + ByteBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native int nio_get_Int(ByteBufferImpl b, int index); private static native void nio_put_Int(ByteBufferImpl b, int index, int value); public java.nio. IntBuffer asIntBuffer() { return new gnu.java.nio. IntBufferImpl(backing_buffer); } + ByteBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native long nio_get_Long(ByteBufferImpl b, int index); private static native void nio_put_Long(ByteBufferImpl b, int index, long value); public java.nio. LongBuffer asLongBuffer() { return new gnu.java.nio. LongBufferImpl(backing_buffer); } + ByteBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native float nio_get_Float(ByteBufferImpl b, int index); private static native void nio_put_Float(ByteBufferImpl b, int index, float value); public java.nio. FloatBuffer asFloatBuffer() { return new gnu.java.nio. FloatBufferImpl(backing_buffer); } + ByteBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native double nio_get_Double(ByteBufferImpl b, int index); private static native void nio_put_Double(ByteBufferImpl b, int index, double value); public java.nio. DoubleBuffer asDoubleBuffer() { return new gnu.java.nio. DoubleBufferImpl(backing_buffer); } + public boolean isReadOnly() + { + return ro; + } + public java.nio. ByteBuffer slice() + { + ByteBufferImpl A = new ByteBufferImpl(this); + A.array_offset = position(); + return A; + } + public java.nio. ByteBuffer duplicate() + { + return new ByteBufferImpl(this); + } + public java.nio. ByteBuffer asReadOnlyBuffer() + { + ByteBufferImpl a = new ByteBufferImpl(this); + a.ro = true; + return a; + } + public java.nio. ByteBuffer compact() + { + return this; + } + public boolean isDirect() + { + return backing_buffer != null; + } + final public byte get() + { + byte e = backing_buffer[position()]; + position(position()+1); + return e; + } + final public java.nio. ByteBuffer put(byte b) + { + backing_buffer[position()] = b; + position(position()+1); + return this; + } + final public byte get(int index) + { + return backing_buffer[index]; + } + final public java.nio. ByteBuffer put(int index, byte b) + { + backing_buffer[index] = b; + return this; + } + final public char getChar() { char a = nio_get_Char(this, position()); inc_pos(2); return a; } final public java.nio. ByteBuffer putChar(char value) { nio_put_Char(this, position(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index); return a; } final public java.nio. ByteBuffer putChar(int index, char value) { nio_put_Char(this, index, value); return this; }; + final public short getShort() { short a = nio_get_Short(this, position()); inc_pos(2); return a; } final public java.nio. ByteBuffer putShort(short value) { nio_put_Short(this, position(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index); return a; } final public java.nio. ByteBuffer putShort(int index, short value) { nio_put_Short(this, index, value); return this; }; + final public int getInt() { int a = nio_get_Int(this, position()); inc_pos(4); return a; } final public java.nio. ByteBuffer putInt(int value) { nio_put_Int(this, position(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index); return a; } final public java.nio. ByteBuffer putInt(int index, int value) { nio_put_Int(this, index, value); return this; }; + final public long getLong() { long a = nio_get_Long(this, position()); inc_pos(8); return a; } final public java.nio. ByteBuffer putLong(long value) { nio_put_Long(this, position(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index); return a; } final public java.nio. ByteBuffer putLong(int index, long value) { nio_put_Long(this, index, value); return this; }; + final public float getFloat() { float a = nio_get_Float(this, position()); inc_pos(4); return a; } final public java.nio. ByteBuffer putFloat(float value) { nio_put_Float(this, position(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index); return a; } final public java.nio. ByteBuffer putFloat(int index, float value) { nio_put_Float(this, index, value); return this; }; + final public double getDouble() { double a = nio_get_Double(this, position()); inc_pos(8); return a; } final public java.nio. ByteBuffer putDouble(double value) { nio_put_Double(this, position(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index); return a; } final public java.nio. ByteBuffer putDouble(int index, double value) { nio_put_Double(this, index, value); return this; }; +} diff --git a/gnu/java/nio/CharBufferImpl.java b/gnu/java/nio/CharBufferImpl.java new file mode 100644 index 000000000..62060467a --- /dev/null +++ b/gnu/java/nio/CharBufferImpl.java @@ -0,0 +1,110 @@ +package gnu.java.nio; +import java.nio.*; +public final class CharBufferImpl extends java.nio. CharBuffer +{ + private int array_offset; + char [] backing_buffer; + private boolean ro; + public CharBufferImpl(int cap, int off, int lim) + { + this.backing_buffer = new char[cap]; + this.capacity(cap); + this.position(off); + this.limit(lim); + } + public CharBufferImpl(char[] array, int off, int lim) + { + this.backing_buffer = array; + this.capacity(array.length); + this.position(off); + this.limit(lim); + } + public CharBufferImpl(CharBufferImpl copy) + { + backing_buffer = copy.backing_buffer; + ro = copy.ro; + position(copy.position()); + limit(copy.limit()); + } + void inc_pos(int a) + { + position(position() + a); + } + 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); + CharBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native byte nio_get_Byte(CharBufferImpl b, int index); private static native void nio_put_Byte(CharBufferImpl b, int index, byte value); public java.nio. ByteBuffer asByteBuffer() { return new gnu.java.nio. ByteBufferImpl(backing_buffer); } + CharBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native char nio_get_Char(CharBufferImpl b, int index); private static native void nio_put_Char(CharBufferImpl b, int index, char value); public java.nio. CharBuffer asCharBuffer() { return new gnu.java.nio. CharBufferImpl(backing_buffer); } + CharBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native short nio_get_Short(CharBufferImpl b, int index); private static native void nio_put_Short(CharBufferImpl b, int index, short value); public java.nio. ShortBuffer asShortBuffer() { return new gnu.java.nio. ShortBufferImpl(backing_buffer); } + CharBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native int nio_get_Int(CharBufferImpl b, int index); private static native void nio_put_Int(CharBufferImpl b, int index, int value); public java.nio. IntBuffer asIntBuffer() { return new gnu.java.nio. IntBufferImpl(backing_buffer); } + CharBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native long nio_get_Long(CharBufferImpl b, int index); private static native void nio_put_Long(CharBufferImpl b, int index, long value); public java.nio. LongBuffer asLongBuffer() { return new gnu.java.nio. LongBufferImpl(backing_buffer); } + CharBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native float nio_get_Float(CharBufferImpl b, int index); private static native void nio_put_Float(CharBufferImpl b, int index, float value); public java.nio. FloatBuffer asFloatBuffer() { return new gnu.java.nio. FloatBufferImpl(backing_buffer); } + CharBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native double nio_get_Double(CharBufferImpl b, int index); private static native void nio_put_Double(CharBufferImpl b, int index, double value); public java.nio. DoubleBuffer asDoubleBuffer() { return new gnu.java.nio. DoubleBufferImpl(backing_buffer); } + public boolean isReadOnly() + { + return ro; + } + public java.nio. CharBuffer slice() + { + CharBufferImpl A = new CharBufferImpl(this); + A.array_offset = position(); + return A; + } + public java.nio. CharBuffer duplicate() + { + return new CharBufferImpl(this); + } + public java.nio. CharBuffer asReadOnlyBuffer() + { + CharBufferImpl a = new CharBufferImpl(this); + a.ro = true; + return a; + } + public java.nio. CharBuffer compact() + { + return this; + } + public boolean isDirect() + { + return backing_buffer != null; + } + final public char get() + { + char e = backing_buffer[position()]; + position(position()+1); + return e; + } + final public java.nio. CharBuffer put(char b) + { + backing_buffer[position()] = b; + position(position()+1); + return this; + } + final public char get(int index) + { + return backing_buffer[index]; + } + final public java.nio. CharBuffer put(int index, char b) + { + backing_buffer[index] = b; + return this; + } + final public char getChar() { return get(); } final public java.nio. CharBuffer putChar(char value) { return put(value); } final public char getChar(int index) { return get(index); } final public java.nio. CharBuffer putChar(int index, char value) { return put(index, value); }; + final public short getShort() { short a = nio_get_Short(this, position()); inc_pos(2); return a; } final public java.nio. CharBuffer putShort(short value) { nio_put_Short(this, position(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index); return a; } final public java.nio. CharBuffer putShort(int index, short value) { nio_put_Short(this, index, value); return this; }; + final public int getInt() { int a = nio_get_Int(this, position()); inc_pos(4); return a; } final public java.nio. CharBuffer putInt(int value) { nio_put_Int(this, position(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index); return a; } final public java.nio. CharBuffer putInt(int index, int value) { nio_put_Int(this, index, value); return this; }; + final public long getLong() { long a = nio_get_Long(this, position()); inc_pos(8); return a; } final public java.nio. CharBuffer putLong(long value) { nio_put_Long(this, position(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index); return a; } final public java.nio. CharBuffer putLong(int index, long value) { nio_put_Long(this, index, value); return this; }; + final public float getFloat() { float a = nio_get_Float(this, position()); inc_pos(4); return a; } final public java.nio. CharBuffer putFloat(float value) { nio_put_Float(this, position(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index); return a; } final public java.nio. CharBuffer putFloat(int index, float value) { nio_put_Float(this, index, value); return this; }; + final public double getDouble() { double a = nio_get_Double(this, position()); inc_pos(8); return a; } final public java.nio. CharBuffer putDouble(double value) { nio_put_Double(this, position(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index); return a; } final public java.nio. CharBuffer putDouble(int index, double value) { nio_put_Double(this, index, value); return this; }; + public String toString() + { + if (backing_buffer != null) + { + return new String(backing_buffer, position(), limit()); + } + return super.toString(); + } +} diff --git a/gnu/java/nio/DoubleBufferImpl.java b/gnu/java/nio/DoubleBufferImpl.java new file mode 100644 index 000000000..4aabd4cb3 --- /dev/null +++ b/gnu/java/nio/DoubleBufferImpl.java @@ -0,0 +1,102 @@ +package gnu.java.nio; +import java.nio.*; +public final class DoubleBufferImpl extends java.nio. DoubleBuffer +{ + private int array_offset; + double [] backing_buffer; + private boolean ro; + public DoubleBufferImpl(int cap, int off, int lim) + { + this.backing_buffer = new double[cap]; + this.capacity(cap); + this.position(off); + this.limit(lim); + } + public DoubleBufferImpl(double[] array, int off, int lim) + { + this.backing_buffer = array; + this.capacity(array.length); + this.position(off); + this.limit(lim); + } + public DoubleBufferImpl(DoubleBufferImpl copy) + { + backing_buffer = copy.backing_buffer; + ro = copy.ro; + position(copy.position()); + limit(copy.limit()); + } + void inc_pos(int a) + { + position(position() + a); + } + 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); + DoubleBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native byte nio_get_Byte(DoubleBufferImpl b, int index); private static native void nio_put_Byte(DoubleBufferImpl b, int index, byte value); public java.nio. ByteBuffer asByteBuffer() { return new gnu.java.nio. ByteBufferImpl(backing_buffer); } + DoubleBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native char nio_get_Char(DoubleBufferImpl b, int index); private static native void nio_put_Char(DoubleBufferImpl b, int index, char value); public java.nio. CharBuffer asCharBuffer() { return new gnu.java.nio. CharBufferImpl(backing_buffer); } + DoubleBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native short nio_get_Short(DoubleBufferImpl b, int index); private static native void nio_put_Short(DoubleBufferImpl b, int index, short value); public java.nio. ShortBuffer asShortBuffer() { return new gnu.java.nio. ShortBufferImpl(backing_buffer); } + DoubleBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native int nio_get_Int(DoubleBufferImpl b, int index); private static native void nio_put_Int(DoubleBufferImpl b, int index, int value); public java.nio. IntBuffer asIntBuffer() { return new gnu.java.nio. IntBufferImpl(backing_buffer); } + DoubleBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native long nio_get_Long(DoubleBufferImpl b, int index); private static native void nio_put_Long(DoubleBufferImpl b, int index, long value); public java.nio. LongBuffer asLongBuffer() { return new gnu.java.nio. LongBufferImpl(backing_buffer); } + DoubleBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native float nio_get_Float(DoubleBufferImpl b, int index); private static native void nio_put_Float(DoubleBufferImpl b, int index, float value); public java.nio. FloatBuffer asFloatBuffer() { return new gnu.java.nio. FloatBufferImpl(backing_buffer); } + DoubleBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native double nio_get_Double(DoubleBufferImpl b, int index); private static native void nio_put_Double(DoubleBufferImpl b, int index, double value); public java.nio. DoubleBuffer asDoubleBuffer() { return new gnu.java.nio. DoubleBufferImpl(backing_buffer); } + public boolean isReadOnly() + { + return ro; + } + public java.nio. DoubleBuffer slice() + { + DoubleBufferImpl A = new DoubleBufferImpl(this); + A.array_offset = position(); + return A; + } + public java.nio. DoubleBuffer duplicate() + { + return new DoubleBufferImpl(this); + } + public java.nio. DoubleBuffer asReadOnlyBuffer() + { + DoubleBufferImpl a = new DoubleBufferImpl(this); + a.ro = true; + return a; + } + public java.nio. DoubleBuffer compact() + { + return this; + } + public boolean isDirect() + { + return backing_buffer != null; + } + final public double get() + { + double e = backing_buffer[position()]; + position(position()+1); + return e; + } + final public java.nio. DoubleBuffer put(double b) + { + backing_buffer[position()] = b; + position(position()+1); + return this; + } + final public double get(int index) + { + return backing_buffer[index]; + } + final public java.nio. DoubleBuffer put(int index, double b) + { + backing_buffer[index] = b; + return this; + } + final public char getChar() { char a = nio_get_Char(this, position()); inc_pos(2); return a; } final public java.nio. DoubleBuffer putChar(char value) { nio_put_Char(this, position(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index); return a; } final public java.nio. DoubleBuffer putChar(int index, char value) { nio_put_Char(this, index, value); return this; }; + final public short getShort() { short a = nio_get_Short(this, position()); inc_pos(2); return a; } final public java.nio. DoubleBuffer putShort(short value) { nio_put_Short(this, position(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index); return a; } final public java.nio. DoubleBuffer putShort(int index, short value) { nio_put_Short(this, index, value); return this; }; + final public int getInt() { int a = nio_get_Int(this, position()); inc_pos(4); return a; } final public java.nio. DoubleBuffer putInt(int value) { nio_put_Int(this, position(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index); return a; } final public java.nio. DoubleBuffer putInt(int index, int value) { nio_put_Int(this, index, value); return this; }; + final public long getLong() { long a = nio_get_Long(this, position()); inc_pos(8); return a; } final public java.nio. DoubleBuffer putLong(long value) { nio_put_Long(this, position(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index); return a; } final public java.nio. DoubleBuffer putLong(int index, long value) { nio_put_Long(this, index, value); return this; }; + final public float getFloat() { float a = nio_get_Float(this, position()); inc_pos(4); return a; } final public java.nio. DoubleBuffer putFloat(float value) { nio_put_Float(this, position(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index); return a; } final public java.nio. DoubleBuffer putFloat(int index, float value) { nio_put_Float(this, index, value); return this; }; + final public double getDouble() { return get(); } final public java.nio. DoubleBuffer putDouble(double value) { return put(value); } final public double getDouble(int index) { return get(index); } final public java.nio. DoubleBuffer putDouble(int index, double value) { return put(index, value); }; +} diff --git a/gnu/java/nio/FloatBufferImpl.java b/gnu/java/nio/FloatBufferImpl.java new file mode 100644 index 000000000..2b1a155ab --- /dev/null +++ b/gnu/java/nio/FloatBufferImpl.java @@ -0,0 +1,102 @@ +package gnu.java.nio; +import java.nio.*; +public final class FloatBufferImpl extends java.nio. FloatBuffer +{ + private int array_offset; + float [] backing_buffer; + private boolean ro; + public FloatBufferImpl(int cap, int off, int lim) + { + this.backing_buffer = new float[cap]; + this.capacity(cap); + this.position(off); + this.limit(lim); + } + public FloatBufferImpl(float[] array, int off, int lim) + { + this.backing_buffer = array; + this.capacity(array.length); + this.position(off); + this.limit(lim); + } + public FloatBufferImpl(FloatBufferImpl copy) + { + backing_buffer = copy.backing_buffer; + ro = copy.ro; + position(copy.position()); + limit(copy.limit()); + } + void inc_pos(int a) + { + position(position() + a); + } + 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); + FloatBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native byte nio_get_Byte(FloatBufferImpl b, int index); private static native void nio_put_Byte(FloatBufferImpl b, int index, byte value); public java.nio. ByteBuffer asByteBuffer() { return new gnu.java.nio. ByteBufferImpl(backing_buffer); } + FloatBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native char nio_get_Char(FloatBufferImpl b, int index); private static native void nio_put_Char(FloatBufferImpl b, int index, char value); public java.nio. CharBuffer asCharBuffer() { return new gnu.java.nio. CharBufferImpl(backing_buffer); } + FloatBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native short nio_get_Short(FloatBufferImpl b, int index); private static native void nio_put_Short(FloatBufferImpl b, int index, short value); public java.nio. ShortBuffer asShortBuffer() { return new gnu.java.nio. ShortBufferImpl(backing_buffer); } + FloatBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native int nio_get_Int(FloatBufferImpl b, int index); private static native void nio_put_Int(FloatBufferImpl b, int index, int value); public java.nio. IntBuffer asIntBuffer() { return new gnu.java.nio. IntBufferImpl(backing_buffer); } + FloatBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native long nio_get_Long(FloatBufferImpl b, int index); private static native void nio_put_Long(FloatBufferImpl b, int index, long value); public java.nio. LongBuffer asLongBuffer() { return new gnu.java.nio. LongBufferImpl(backing_buffer); } + FloatBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native float nio_get_Float(FloatBufferImpl b, int index); private static native void nio_put_Float(FloatBufferImpl b, int index, float value); public java.nio. FloatBuffer asFloatBuffer() { return new gnu.java.nio. FloatBufferImpl(backing_buffer); } + FloatBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native double nio_get_Double(FloatBufferImpl b, int index); private static native void nio_put_Double(FloatBufferImpl b, int index, double value); public java.nio. DoubleBuffer asDoubleBuffer() { return new gnu.java.nio. DoubleBufferImpl(backing_buffer); } + public boolean isReadOnly() + { + return ro; + } + public java.nio. FloatBuffer slice() + { + FloatBufferImpl A = new FloatBufferImpl(this); + A.array_offset = position(); + return A; + } + public java.nio. FloatBuffer duplicate() + { + return new FloatBufferImpl(this); + } + public java.nio. FloatBuffer asReadOnlyBuffer() + { + FloatBufferImpl a = new FloatBufferImpl(this); + a.ro = true; + return a; + } + public java.nio. FloatBuffer compact() + { + return this; + } + public boolean isDirect() + { + return backing_buffer != null; + } + final public float get() + { + float e = backing_buffer[position()]; + position(position()+1); + return e; + } + final public java.nio. FloatBuffer put(float b) + { + backing_buffer[position()] = b; + position(position()+1); + return this; + } + final public float get(int index) + { + return backing_buffer[index]; + } + final public java.nio. FloatBuffer put(int index, float b) + { + backing_buffer[index] = b; + return this; + } + final public char getChar() { char a = nio_get_Char(this, position()); inc_pos(2); return a; } final public java.nio. FloatBuffer putChar(char value) { nio_put_Char(this, position(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index); return a; } final public java.nio. FloatBuffer putChar(int index, char value) { nio_put_Char(this, index, value); return this; }; + final public short getShort() { short a = nio_get_Short(this, position()); inc_pos(2); return a; } final public java.nio. FloatBuffer putShort(short value) { nio_put_Short(this, position(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index); return a; } final public java.nio. FloatBuffer putShort(int index, short value) { nio_put_Short(this, index, value); return this; }; + final public int getInt() { int a = nio_get_Int(this, position()); inc_pos(4); return a; } final public java.nio. FloatBuffer putInt(int value) { nio_put_Int(this, position(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index); return a; } final public java.nio. FloatBuffer putInt(int index, int value) { nio_put_Int(this, index, value); return this; }; + final public long getLong() { long a = nio_get_Long(this, position()); inc_pos(8); return a; } final public java.nio. FloatBuffer putLong(long value) { nio_put_Long(this, position(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index); return a; } final public java.nio. FloatBuffer putLong(int index, long value) { nio_put_Long(this, index, value); return this; }; + final public float getFloat() { return get(); } final public java.nio. FloatBuffer putFloat(float value) { return put(value); } final public float getFloat(int index) { return get(index); } final public java.nio. FloatBuffer putFloat(int index, float value) { return put(index, value); }; + final public double getDouble() { double a = nio_get_Double(this, position()); inc_pos(8); return a; } final public java.nio. FloatBuffer putDouble(double value) { nio_put_Double(this, position(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index); return a; } final public java.nio. FloatBuffer putDouble(int index, double value) { nio_put_Double(this, index, value); return this; }; +} diff --git a/gnu/java/nio/IntBufferImpl.java b/gnu/java/nio/IntBufferImpl.java new file mode 100644 index 000000000..5453f8d01 --- /dev/null +++ b/gnu/java/nio/IntBufferImpl.java @@ -0,0 +1,102 @@ +package gnu.java.nio; +import java.nio.*; +public final class IntBufferImpl extends java.nio. IntBuffer +{ + private int array_offset; + int [] backing_buffer; + private boolean ro; + public IntBufferImpl(int cap, int off, int lim) + { + this.backing_buffer = new int[cap]; + this.capacity(cap); + this.position(off); + this.limit(lim); + } + public IntBufferImpl(int[] array, int off, int lim) + { + this.backing_buffer = array; + this.capacity(array.length); + this.position(off); + this.limit(lim); + } + public IntBufferImpl(IntBufferImpl copy) + { + backing_buffer = copy.backing_buffer; + ro = copy.ro; + position(copy.position()); + limit(copy.limit()); + } + void inc_pos(int a) + { + position(position() + a); + } + 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); + IntBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native byte nio_get_Byte(IntBufferImpl b, int index); private static native void nio_put_Byte(IntBufferImpl b, int index, byte value); public java.nio. ByteBuffer asByteBuffer() { return new gnu.java.nio. ByteBufferImpl(backing_buffer); } + IntBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native char nio_get_Char(IntBufferImpl b, int index); private static native void nio_put_Char(IntBufferImpl b, int index, char value); public java.nio. CharBuffer asCharBuffer() { return new gnu.java.nio. CharBufferImpl(backing_buffer); } + IntBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native short nio_get_Short(IntBufferImpl b, int index); private static native void nio_put_Short(IntBufferImpl b, int index, short value); public java.nio. ShortBuffer asShortBuffer() { return new gnu.java.nio. ShortBufferImpl(backing_buffer); } + IntBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native int nio_get_Int(IntBufferImpl b, int index); private static native void nio_put_Int(IntBufferImpl b, int index, int value); public java.nio. IntBuffer asIntBuffer() { return new gnu.java.nio. IntBufferImpl(backing_buffer); } + IntBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native long nio_get_Long(IntBufferImpl b, int index); private static native void nio_put_Long(IntBufferImpl b, int index, long value); public java.nio. LongBuffer asLongBuffer() { return new gnu.java.nio. LongBufferImpl(backing_buffer); } + IntBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native float nio_get_Float(IntBufferImpl b, int index); private static native void nio_put_Float(IntBufferImpl b, int index, float value); public java.nio. FloatBuffer asFloatBuffer() { return new gnu.java.nio. FloatBufferImpl(backing_buffer); } + IntBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native double nio_get_Double(IntBufferImpl b, int index); private static native void nio_put_Double(IntBufferImpl b, int index, double value); public java.nio. DoubleBuffer asDoubleBuffer() { return new gnu.java.nio. DoubleBufferImpl(backing_buffer); } + public boolean isReadOnly() + { + return ro; + } + public java.nio. IntBuffer slice() + { + IntBufferImpl A = new IntBufferImpl(this); + A.array_offset = position(); + return A; + } + public java.nio. IntBuffer duplicate() + { + return new IntBufferImpl(this); + } + public java.nio. IntBuffer asReadOnlyBuffer() + { + IntBufferImpl a = new IntBufferImpl(this); + a.ro = true; + return a; + } + public java.nio. IntBuffer compact() + { + return this; + } + public boolean isDirect() + { + return backing_buffer != null; + } + final public int get() + { + int e = backing_buffer[position()]; + position(position()+1); + return e; + } + final public java.nio. IntBuffer put(int b) + { + backing_buffer[position()] = b; + position(position()+1); + return this; + } + final public int get(int index) + { + return backing_buffer[index]; + } + final public java.nio. IntBuffer put(int index, int b) + { + backing_buffer[index] = b; + return this; + } + final public char getChar() { char a = nio_get_Char(this, position()); inc_pos(2); return a; } final public java.nio. IntBuffer putChar(char value) { nio_put_Char(this, position(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index); return a; } final public java.nio. IntBuffer putChar(int index, char value) { nio_put_Char(this, index, value); return this; }; + final public short getShort() { short a = nio_get_Short(this, position()); inc_pos(2); return a; } final public java.nio. IntBuffer putShort(short value) { nio_put_Short(this, position(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index); return a; } final public java.nio. IntBuffer putShort(int index, short value) { nio_put_Short(this, index, value); return this; }; + final public int getInt() { return get(); } final public java.nio. IntBuffer putInt(int value) { return put(value); } final public int getInt(int index) { return get(index); } final public java.nio. IntBuffer putInt(int index, int value) { return put(index, value); }; + final public long getLong() { long a = nio_get_Long(this, position()); inc_pos(8); return a; } final public java.nio. IntBuffer putLong(long value) { nio_put_Long(this, position(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index); return a; } final public java.nio. IntBuffer putLong(int index, long value) { nio_put_Long(this, index, value); return this; }; + final public float getFloat() { float a = nio_get_Float(this, position()); inc_pos(4); return a; } final public java.nio. IntBuffer putFloat(float value) { nio_put_Float(this, position(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index); return a; } final public java.nio. IntBuffer putFloat(int index, float value) { nio_put_Float(this, index, value); return this; }; + final public double getDouble() { double a = nio_get_Double(this, position()); inc_pos(8); return a; } final public java.nio. IntBuffer putDouble(double value) { nio_put_Double(this, position(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index); return a; } final public java.nio. IntBuffer putDouble(int index, double value) { nio_put_Double(this, index, value); return this; }; +} diff --git a/gnu/java/nio/LongBufferImpl.java b/gnu/java/nio/LongBufferImpl.java new file mode 100644 index 000000000..67a15f702 --- /dev/null +++ b/gnu/java/nio/LongBufferImpl.java @@ -0,0 +1,102 @@ +package gnu.java.nio; +import java.nio.*; +public final class LongBufferImpl extends java.nio. LongBuffer +{ + private int array_offset; + long [] backing_buffer; + private boolean ro; + public LongBufferImpl(int cap, int off, int lim) + { + this.backing_buffer = new long[cap]; + this.capacity(cap); + this.position(off); + this.limit(lim); + } + public LongBufferImpl(long[] array, int off, int lim) + { + this.backing_buffer = array; + this.capacity(array.length); + this.position(off); + this.limit(lim); + } + public LongBufferImpl(LongBufferImpl copy) + { + backing_buffer = copy.backing_buffer; + ro = copy.ro; + position(copy.position()); + limit(copy.limit()); + } + void inc_pos(int a) + { + position(position() + a); + } + 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); + LongBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native byte nio_get_Byte(LongBufferImpl b, int index); private static native void nio_put_Byte(LongBufferImpl b, int index, byte value); public java.nio. ByteBuffer asByteBuffer() { return new gnu.java.nio. ByteBufferImpl(backing_buffer); } + LongBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native char nio_get_Char(LongBufferImpl b, int index); private static native void nio_put_Char(LongBufferImpl b, int index, char value); public java.nio. CharBuffer asCharBuffer() { return new gnu.java.nio. CharBufferImpl(backing_buffer); } + LongBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native short nio_get_Short(LongBufferImpl b, int index); private static native void nio_put_Short(LongBufferImpl b, int index, short value); public java.nio. ShortBuffer asShortBuffer() { return new gnu.java.nio. ShortBufferImpl(backing_buffer); } + LongBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native int nio_get_Int(LongBufferImpl b, int index); private static native void nio_put_Int(LongBufferImpl b, int index, int value); public java.nio. IntBuffer asIntBuffer() { return new gnu.java.nio. IntBufferImpl(backing_buffer); } + LongBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native long nio_get_Long(LongBufferImpl b, int index); private static native void nio_put_Long(LongBufferImpl b, int index, long value); public java.nio. LongBuffer asLongBuffer() { return new gnu.java.nio. LongBufferImpl(backing_buffer); } + LongBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native float nio_get_Float(LongBufferImpl b, int index); private static native void nio_put_Float(LongBufferImpl b, int index, float value); public java.nio. FloatBuffer asFloatBuffer() { return new gnu.java.nio. FloatBufferImpl(backing_buffer); } + LongBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native double nio_get_Double(LongBufferImpl b, int index); private static native void nio_put_Double(LongBufferImpl b, int index, double value); public java.nio. DoubleBuffer asDoubleBuffer() { return new gnu.java.nio. DoubleBufferImpl(backing_buffer); } + public boolean isReadOnly() + { + return ro; + } + public java.nio. LongBuffer slice() + { + LongBufferImpl A = new LongBufferImpl(this); + A.array_offset = position(); + return A; + } + public java.nio. LongBuffer duplicate() + { + return new LongBufferImpl(this); + } + public java.nio. LongBuffer asReadOnlyBuffer() + { + LongBufferImpl a = new LongBufferImpl(this); + a.ro = true; + return a; + } + public java.nio. LongBuffer compact() + { + return this; + } + public boolean isDirect() + { + return backing_buffer != null; + } + final public long get() + { + long e = backing_buffer[position()]; + position(position()+1); + return e; + } + final public java.nio. LongBuffer put(long b) + { + backing_buffer[position()] = b; + position(position()+1); + return this; + } + final public long get(int index) + { + return backing_buffer[index]; + } + final public java.nio. LongBuffer put(int index, long b) + { + backing_buffer[index] = b; + return this; + } + final public char getChar() { char a = nio_get_Char(this, position()); inc_pos(2); return a; } final public java.nio. LongBuffer putChar(char value) { nio_put_Char(this, position(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index); return a; } final public java.nio. LongBuffer putChar(int index, char value) { nio_put_Char(this, index, value); return this; }; + final public short getShort() { short a = nio_get_Short(this, position()); inc_pos(2); return a; } final public java.nio. LongBuffer putShort(short value) { nio_put_Short(this, position(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index); return a; } final public java.nio. LongBuffer putShort(int index, short value) { nio_put_Short(this, index, value); return this; }; + final public int getInt() { int a = nio_get_Int(this, position()); inc_pos(4); return a; } final public java.nio. LongBuffer putInt(int value) { nio_put_Int(this, position(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index); return a; } final public java.nio. LongBuffer putInt(int index, int value) { nio_put_Int(this, index, value); return this; }; + final public long getLong() { return get(); } final public java.nio. LongBuffer putLong(long value) { return put(value); } final public long getLong(int index) { return get(index); } final public java.nio. LongBuffer putLong(int index, long value) { return put(index, value); }; + final public float getFloat() { float a = nio_get_Float(this, position()); inc_pos(4); return a; } final public java.nio. LongBuffer putFloat(float value) { nio_put_Float(this, position(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index); return a; } final public java.nio. LongBuffer putFloat(int index, float value) { nio_put_Float(this, index, value); return this; }; + final public double getDouble() { double a = nio_get_Double(this, position()); inc_pos(8); return a; } final public java.nio. LongBuffer putDouble(double value) { nio_put_Double(this, position(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index); return a; } final public java.nio. LongBuffer putDouble(int index, double value) { nio_put_Double(this, index, value); return this; }; +} diff --git a/gnu/java/nio/MappedByteFileBuffer.java b/gnu/java/nio/MappedByteFileBuffer.java new file mode 100644 index 000000000..0988fffb1 --- /dev/null +++ b/gnu/java/nio/MappedByteFileBuffer.java @@ -0,0 +1,84 @@ +package gnu.java.nio; +import java.nio.*; +final public class MappedByteFileBuffer + extends MappedByteBuffer +{ + public long address; + boolean ro; + boolean direct; + public FileChannelImpl ch; + public MappedByteFileBuffer(FileChannelImpl ch) + { + this.ch = ch; + address = ch.address; + } + public MappedByteFileBuffer(MappedByteFileBuffer b) + { + this.ro = b.ro; + this.ch = b.ch; + address = b.address; + } + public boolean isReadOnly() + { + return ro; + } + public static native byte nio_read_Byte_file_channel(FileChannelImpl ch, int index); public static native void nio_write_Byte_file_channel(FileChannelImpl ch, int index, byte value); + public static native short nio_read_Short_file_channel(FileChannelImpl ch, int index); public static native void nio_write_Short_file_channel(FileChannelImpl ch, int index, short value); + public static native char nio_read_Char_file_channel(FileChannelImpl ch, int index); public static native void nio_write_Char_file_channel(FileChannelImpl ch, int index, char value); + public static native int nio_read_Int_file_channel(FileChannelImpl ch, int index); public static native void nio_write_Int_file_channel(FileChannelImpl ch, int index, int value); + public static native long nio_read_Long_file_channel(FileChannelImpl ch, int index); public static native void nio_write_Long_file_channel(FileChannelImpl ch, int index, long value); + public static native float nio_read_Float_file_channel(FileChannelImpl ch, int index); public static native void nio_write_Float_file_channel(FileChannelImpl ch, int index, float value); + public static native double nio_read_Double_file_channel(FileChannelImpl ch, int index); public static native void nio_write_Double_file_channel(FileChannelImpl ch, int index, double value); +final public byte get() + { + byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position()); + position(position() + 1); + return a; + } +final public ByteBuffer put(byte b) + { + MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), b); + position(position() + 1); + return this; + } +final public byte get(int index) + { + byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index); + return a; + } +final public ByteBuffer put(int index, byte b) + { + MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, b); + return this; + } +final public ByteBuffer compact() + { + return this; + } +final public boolean isDirect() + { + return direct; + } +final public ByteBuffer slice() + { + MappedByteFileBuffer A = new MappedByteFileBuffer(this); + return A; + } +public ByteBuffer duplicate() + { + return new MappedByteFileBuffer(this); + } +public ByteBuffer asReadOnlyBuffer() + { + MappedByteFileBuffer b = new MappedByteFileBuffer(this); + b.ro = true; + return b; + } + final public ByteBuffer asByteBuffer() { return new MappedByteFileBuffer(ch); } final public byte getByte() { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position()); position(position() + 1); return a; } final public ByteBuffer putByte(byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), value); position(position() + 1); return this; } final public byte getByte(int index) { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index); return a; } final public ByteBuffer putByte(int index, byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, value); return this; }; + final public CharBuffer asCharBuffer() { return new MappedCharFileBuffer(ch); } final public char getChar() { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, position()); position(position() + 1); return a; } final public ByteBuffer putChar(char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, position(), value); position(position() + 1); return this; } final public char getChar(int index) { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, index); return a; } final public ByteBuffer putChar(int index, char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, index, value); return this; }; + final public ShortBuffer asShortBuffer() { return new MappedShortFileBuffer(ch); } final public short getShort() { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, position()); position(position() + 1); return a; } final public ByteBuffer putShort(short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, position(), value); position(position() + 1); return this; } final public short getShort(int index) { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, index); return a; } final public ByteBuffer putShort(int index, short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, index, value); return this; }; + final public IntBuffer asIntBuffer() { return new MappedIntFileBuffer(ch); } final public int getInt() { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, position()); position(position() + 1); return a; } final public ByteBuffer putInt(int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, position(), value); position(position() + 1); return this; } final public int getInt(int index) { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, index); return a; } final public ByteBuffer putInt(int index, int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, index, value); return this; }; + final public LongBuffer asLongBuffer() { return new MappedLongFileBuffer(ch); } final public long getLong() { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, position()); position(position() + 1); return a; } final public ByteBuffer putLong(long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, position(), value); position(position() + 1); return this; } final public long getLong(int index) { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, index); return a; } final public ByteBuffer putLong(int index, long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, index, value); return this; }; + final public FloatBuffer asFloatBuffer() { return new MappedFloatFileBuffer(ch); } final public float getFloat() { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, position()); position(position() + 1); return a; } final public ByteBuffer putFloat(float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, position(), value); position(position() + 1); return this; } final public float getFloat(int index) { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, index); return a; } final public ByteBuffer putFloat(int index, float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, index, value); return this; }; + final public DoubleBuffer asDoubleBuffer() { return new MappedDoubleFileBuffer(ch); } final public double getDouble() { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, position()); position(position() + 1); return a; } final public ByteBuffer putDouble(double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, position(), value); position(position() + 1); return this; } final public double getDouble(int index) { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, index); return a; } final public ByteBuffer putDouble(int index, double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, index, value); return this; }; +} diff --git a/gnu/java/nio/MappedCharFileBuffer.java b/gnu/java/nio/MappedCharFileBuffer.java new file mode 100644 index 000000000..6b46c077a --- /dev/null +++ b/gnu/java/nio/MappedCharFileBuffer.java @@ -0,0 +1,77 @@ +package gnu.java.nio; +import java.nio.*; +final public class MappedCharFileBuffer + extends CharBuffer +{ + public long address; + boolean ro; + boolean direct; + public FileChannelImpl ch; + public MappedCharFileBuffer(FileChannelImpl ch) + { + this.ch = ch; + address = ch.address; + } + public MappedCharFileBuffer(MappedCharFileBuffer b) + { + this.ro = b.ro; + this.ch = b.ch; + address = b.address; + } + public boolean isReadOnly() + { + return ro; + } +final public char get() + { + char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, position()); + position(position() + 2); + return a; + } +final public CharBuffer put(char b) + { + MappedByteFileBuffer.nio_write_Char_file_channel(ch, position(), b); + position(position() + 2); + return this; + } +final public char get(int index) + { + char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, index); + return a; + } +final public CharBuffer put(int index, char b) + { + MappedByteFileBuffer.nio_write_Char_file_channel(ch, index, b); + return this; + } +final public CharBuffer compact() + { + return this; + } +final public boolean isDirect() + { + return direct; + } +final public CharBuffer slice() + { + MappedCharFileBuffer A = new MappedCharFileBuffer(this); + return A; + } +public CharBuffer duplicate() + { + return new MappedCharFileBuffer(this); + } +public CharBuffer asReadOnlyBuffer() + { + MappedCharFileBuffer b = new MappedCharFileBuffer(this); + b.ro = true; + return b; + } + final public ByteBuffer asByteBuffer() { return new MappedByteFileBuffer(ch); } final public byte getByte() { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position()); position(position() + 2); return a; } final public CharBuffer putByte(byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), value); position(position() + 2); return this; } final public byte getByte(int index) { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index); return a; } final public CharBuffer putByte(int index, byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, value); return this; }; + final public CharBuffer asCharBuffer() { return new MappedCharFileBuffer(ch); } final public char getChar() { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, position()); position(position() + 2); return a; } final public CharBuffer putChar(char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, position(), value); position(position() + 2); return this; } final public char getChar(int index) { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, index); return a; } final public CharBuffer putChar(int index, char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, index, value); return this; }; + final public ShortBuffer asShortBuffer() { return new MappedShortFileBuffer(ch); } final public short getShort() { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, position()); position(position() + 2); return a; } final public CharBuffer putShort(short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, position(), value); position(position() + 2); return this; } final public short getShort(int index) { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, index); return a; } final public CharBuffer putShort(int index, short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, index, value); return this; }; + final public IntBuffer asIntBuffer() { return new MappedIntFileBuffer(ch); } final public int getInt() { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, position()); position(position() + 2); return a; } final public CharBuffer putInt(int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, position(), value); position(position() + 2); return this; } final public int getInt(int index) { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, index); return a; } final public CharBuffer putInt(int index, int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, index, value); return this; }; + final public LongBuffer asLongBuffer() { return new MappedLongFileBuffer(ch); } final public long getLong() { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, position()); position(position() + 2); return a; } final public CharBuffer putLong(long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, position(), value); position(position() + 2); return this; } final public long getLong(int index) { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, index); return a; } final public CharBuffer putLong(int index, long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, index, value); return this; }; + final public FloatBuffer asFloatBuffer() { return new MappedFloatFileBuffer(ch); } final public float getFloat() { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, position()); position(position() + 2); return a; } final public CharBuffer putFloat(float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, position(), value); position(position() + 2); return this; } final public float getFloat(int index) { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, index); return a; } final public CharBuffer putFloat(int index, float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, index, value); return this; }; + final public DoubleBuffer asDoubleBuffer() { return new MappedDoubleFileBuffer(ch); } final public double getDouble() { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, position()); position(position() + 2); return a; } final public CharBuffer putDouble(double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, position(), value); position(position() + 2); return this; } final public double getDouble(int index) { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, index); return a; } final public CharBuffer putDouble(int index, double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, index, value); return this; }; +} diff --git a/gnu/java/nio/MappedDoubleFileBuffer.java b/gnu/java/nio/MappedDoubleFileBuffer.java new file mode 100644 index 000000000..4a8cd8b00 --- /dev/null +++ b/gnu/java/nio/MappedDoubleFileBuffer.java @@ -0,0 +1,77 @@ +package gnu.java.nio; +import java.nio.*; +final public class MappedDoubleFileBuffer + extends DoubleBuffer +{ + public long address; + boolean ro; + boolean direct; + public FileChannelImpl ch; + public MappedDoubleFileBuffer(FileChannelImpl ch) + { + this.ch = ch; + address = ch.address; + } + public MappedDoubleFileBuffer(MappedDoubleFileBuffer b) + { + this.ro = b.ro; + this.ch = b.ch; + address = b.address; + } + public boolean isReadOnly() + { + return ro; + } +final public double get() + { + double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, position()); + position(position() + 8); + return a; + } +final public DoubleBuffer put(double b) + { + MappedByteFileBuffer.nio_write_Double_file_channel(ch, position(), b); + position(position() + 8); + return this; + } +final public double get(int index) + { + double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, index); + return a; + } +final public DoubleBuffer put(int index, double b) + { + MappedByteFileBuffer.nio_write_Double_file_channel(ch, index, b); + return this; + } +final public DoubleBuffer compact() + { + return this; + } +final public boolean isDirect() + { + return direct; + } +final public DoubleBuffer slice() + { + MappedDoubleFileBuffer A = new MappedDoubleFileBuffer(this); + return A; + } +public DoubleBuffer duplicate() + { + return new MappedDoubleFileBuffer(this); + } +public DoubleBuffer asReadOnlyBuffer() + { + MappedDoubleFileBuffer b = new MappedDoubleFileBuffer(this); + b.ro = true; + return b; + } + final public ByteBuffer asByteBuffer() { return new MappedByteFileBuffer(ch); } final public byte getByte() { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position()); position(position() + 8); return a; } final public DoubleBuffer putByte(byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), value); position(position() + 8); return this; } final public byte getByte(int index) { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index); return a; } final public DoubleBuffer putByte(int index, byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, value); return this; }; + final public CharBuffer asCharBuffer() { return new MappedCharFileBuffer(ch); } final public char getChar() { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, position()); position(position() + 8); return a; } final public DoubleBuffer putChar(char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, position(), value); position(position() + 8); return this; } final public char getChar(int index) { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, index); return a; } final public DoubleBuffer putChar(int index, char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, index, value); return this; }; + final public ShortBuffer asShortBuffer() { return new MappedShortFileBuffer(ch); } final public short getShort() { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, position()); position(position() + 8); return a; } final public DoubleBuffer putShort(short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, position(), value); position(position() + 8); return this; } final public short getShort(int index) { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, index); return a; } final public DoubleBuffer putShort(int index, short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, index, value); return this; }; + final public IntBuffer asIntBuffer() { return new MappedIntFileBuffer(ch); } final public int getInt() { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, position()); position(position() + 8); return a; } final public DoubleBuffer putInt(int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, position(), value); position(position() + 8); return this; } final public int getInt(int index) { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, index); return a; } final public DoubleBuffer putInt(int index, int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, index, value); return this; }; + final public LongBuffer asLongBuffer() { return new MappedLongFileBuffer(ch); } final public long getLong() { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, position()); position(position() + 8); return a; } final public DoubleBuffer putLong(long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, position(), value); position(position() + 8); return this; } final public long getLong(int index) { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, index); return a; } final public DoubleBuffer putLong(int index, long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, index, value); return this; }; + final public FloatBuffer asFloatBuffer() { return new MappedFloatFileBuffer(ch); } final public float getFloat() { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, position()); position(position() + 8); return a; } final public DoubleBuffer putFloat(float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, position(), value); position(position() + 8); return this; } final public float getFloat(int index) { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, index); return a; } final public DoubleBuffer putFloat(int index, float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, index, value); return this; }; + final public DoubleBuffer asDoubleBuffer() { return new MappedDoubleFileBuffer(ch); } final public double getDouble() { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, position()); position(position() + 8); return a; } final public DoubleBuffer putDouble(double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, position(), value); position(position() + 8); return this; } final public double getDouble(int index) { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, index); return a; } final public DoubleBuffer putDouble(int index, double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, index, value); return this; }; +} diff --git a/gnu/java/nio/MappedFloatFileBuffer.java b/gnu/java/nio/MappedFloatFileBuffer.java new file mode 100644 index 000000000..35cf872ee --- /dev/null +++ b/gnu/java/nio/MappedFloatFileBuffer.java @@ -0,0 +1,77 @@ +package gnu.java.nio; +import java.nio.*; +final public class MappedFloatFileBuffer + extends FloatBuffer +{ + public long address; + boolean ro; + boolean direct; + public FileChannelImpl ch; + public MappedFloatFileBuffer(FileChannelImpl ch) + { + this.ch = ch; + address = ch.address; + } + public MappedFloatFileBuffer(MappedFloatFileBuffer b) + { + this.ro = b.ro; + this.ch = b.ch; + address = b.address; + } + public boolean isReadOnly() + { + return ro; + } +final public float get() + { + float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, position()); + position(position() + 4); + return a; + } +final public FloatBuffer put(float b) + { + MappedByteFileBuffer.nio_write_Float_file_channel(ch, position(), b); + position(position() + 4); + return this; + } +final public float get(int index) + { + float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, index); + return a; + } +final public FloatBuffer put(int index, float b) + { + MappedByteFileBuffer.nio_write_Float_file_channel(ch, index, b); + return this; + } +final public FloatBuffer compact() + { + return this; + } +final public boolean isDirect() + { + return direct; + } +final public FloatBuffer slice() + { + MappedFloatFileBuffer A = new MappedFloatFileBuffer(this); + return A; + } +public FloatBuffer duplicate() + { + return new MappedFloatFileBuffer(this); + } +public FloatBuffer asReadOnlyBuffer() + { + MappedFloatFileBuffer b = new MappedFloatFileBuffer(this); + b.ro = true; + return b; + } + final public ByteBuffer asByteBuffer() { return new MappedByteFileBuffer(ch); } final public byte getByte() { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position()); position(position() + 4); return a; } final public FloatBuffer putByte(byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), value); position(position() + 4); return this; } final public byte getByte(int index) { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index); return a; } final public FloatBuffer putByte(int index, byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, value); return this; }; + final public CharBuffer asCharBuffer() { return new MappedCharFileBuffer(ch); } final public char getChar() { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, position()); position(position() + 4); return a; } final public FloatBuffer putChar(char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, position(), value); position(position() + 4); return this; } final public char getChar(int index) { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, index); return a; } final public FloatBuffer putChar(int index, char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, index, value); return this; }; + final public ShortBuffer asShortBuffer() { return new MappedShortFileBuffer(ch); } final public short getShort() { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, position()); position(position() + 4); return a; } final public FloatBuffer putShort(short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, position(), value); position(position() + 4); return this; } final public short getShort(int index) { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, index); return a; } final public FloatBuffer putShort(int index, short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, index, value); return this; }; + final public IntBuffer asIntBuffer() { return new MappedIntFileBuffer(ch); } final public int getInt() { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, position()); position(position() + 4); return a; } final public FloatBuffer putInt(int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, position(), value); position(position() + 4); return this; } final public int getInt(int index) { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, index); return a; } final public FloatBuffer putInt(int index, int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, index, value); return this; }; + final public LongBuffer asLongBuffer() { return new MappedLongFileBuffer(ch); } final public long getLong() { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, position()); position(position() + 4); return a; } final public FloatBuffer putLong(long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, position(), value); position(position() + 4); return this; } final public long getLong(int index) { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, index); return a; } final public FloatBuffer putLong(int index, long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, index, value); return this; }; + final public FloatBuffer asFloatBuffer() { return new MappedFloatFileBuffer(ch); } final public float getFloat() { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, position()); position(position() + 4); return a; } final public FloatBuffer putFloat(float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, position(), value); position(position() + 4); return this; } final public float getFloat(int index) { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, index); return a; } final public FloatBuffer putFloat(int index, float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, index, value); return this; }; + final public DoubleBuffer asDoubleBuffer() { return new MappedDoubleFileBuffer(ch); } final public double getDouble() { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, position()); position(position() + 4); return a; } final public FloatBuffer putDouble(double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, position(), value); position(position() + 4); return this; } final public double getDouble(int index) { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, index); return a; } final public FloatBuffer putDouble(int index, double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, index, value); return this; }; +} diff --git a/gnu/java/nio/MappedIntFileBuffer.java b/gnu/java/nio/MappedIntFileBuffer.java new file mode 100644 index 000000000..033f0c7c3 --- /dev/null +++ b/gnu/java/nio/MappedIntFileBuffer.java @@ -0,0 +1,77 @@ +package gnu.java.nio; +import java.nio.*; +final public class MappedIntFileBuffer + extends IntBuffer +{ + public long address; + boolean ro; + boolean direct; + public FileChannelImpl ch; + public MappedIntFileBuffer(FileChannelImpl ch) + { + this.ch = ch; + address = ch.address; + } + public MappedIntFileBuffer(MappedIntFileBuffer b) + { + this.ro = b.ro; + this.ch = b.ch; + address = b.address; + } + public boolean isReadOnly() + { + return ro; + } +final public int get() + { + int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, position()); + position(position() + 4); + return a; + } +final public IntBuffer put(int b) + { + MappedByteFileBuffer.nio_write_Int_file_channel(ch, position(), b); + position(position() + 4); + return this; + } +final public int get(int index) + { + int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, index); + return a; + } +final public IntBuffer put(int index, int b) + { + MappedByteFileBuffer.nio_write_Int_file_channel(ch, index, b); + return this; + } +final public IntBuffer compact() + { + return this; + } +final public boolean isDirect() + { + return direct; + } +final public IntBuffer slice() + { + MappedIntFileBuffer A = new MappedIntFileBuffer(this); + return A; + } +public IntBuffer duplicate() + { + return new MappedIntFileBuffer(this); + } +public IntBuffer asReadOnlyBuffer() + { + MappedIntFileBuffer b = new MappedIntFileBuffer(this); + b.ro = true; + return b; + } + final public ByteBuffer asByteBuffer() { return new MappedByteFileBuffer(ch); } final public byte getByte() { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position()); position(position() + 4); return a; } final public IntBuffer putByte(byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), value); position(position() + 4); return this; } final public byte getByte(int index) { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index); return a; } final public IntBuffer putByte(int index, byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, value); return this; }; + final public CharBuffer asCharBuffer() { return new MappedCharFileBuffer(ch); } final public char getChar() { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, position()); position(position() + 4); return a; } final public IntBuffer putChar(char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, position(), value); position(position() + 4); return this; } final public char getChar(int index) { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, index); return a; } final public IntBuffer putChar(int index, char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, index, value); return this; }; + final public ShortBuffer asShortBuffer() { return new MappedShortFileBuffer(ch); } final public short getShort() { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, position()); position(position() + 4); return a; } final public IntBuffer putShort(short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, position(), value); position(position() + 4); return this; } final public short getShort(int index) { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, index); return a; } final public IntBuffer putShort(int index, short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, index, value); return this; }; + final public IntBuffer asIntBuffer() { return new MappedIntFileBuffer(ch); } final public int getInt() { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, position()); position(position() + 4); return a; } final public IntBuffer putInt(int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, position(), value); position(position() + 4); return this; } final public int getInt(int index) { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, index); return a; } final public IntBuffer putInt(int index, int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, index, value); return this; }; + final public LongBuffer asLongBuffer() { return new MappedLongFileBuffer(ch); } final public long getLong() { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, position()); position(position() + 4); return a; } final public IntBuffer putLong(long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, position(), value); position(position() + 4); return this; } final public long getLong(int index) { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, index); return a; } final public IntBuffer putLong(int index, long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, index, value); return this; }; + final public FloatBuffer asFloatBuffer() { return new MappedFloatFileBuffer(ch); } final public float getFloat() { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, position()); position(position() + 4); return a; } final public IntBuffer putFloat(float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, position(), value); position(position() + 4); return this; } final public float getFloat(int index) { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, index); return a; } final public IntBuffer putFloat(int index, float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, index, value); return this; }; + final public DoubleBuffer asDoubleBuffer() { return new MappedDoubleFileBuffer(ch); } final public double getDouble() { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, position()); position(position() + 4); return a; } final public IntBuffer putDouble(double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, position(), value); position(position() + 4); return this; } final public double getDouble(int index) { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, index); return a; } final public IntBuffer putDouble(int index, double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, index, value); return this; }; +} diff --git a/gnu/java/nio/MappedLongFileBuffer.java b/gnu/java/nio/MappedLongFileBuffer.java new file mode 100644 index 000000000..1bddc209d --- /dev/null +++ b/gnu/java/nio/MappedLongFileBuffer.java @@ -0,0 +1,77 @@ +package gnu.java.nio; +import java.nio.*; +final public class MappedLongFileBuffer + extends LongBuffer +{ + public long address; + boolean ro; + boolean direct; + public FileChannelImpl ch; + public MappedLongFileBuffer(FileChannelImpl ch) + { + this.ch = ch; + address = ch.address; + } + public MappedLongFileBuffer(MappedLongFileBuffer b) + { + this.ro = b.ro; + this.ch = b.ch; + address = b.address; + } + public boolean isReadOnly() + { + return ro; + } +final public long get() + { + long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, position()); + position(position() + 8); + return a; + } +final public LongBuffer put(long b) + { + MappedByteFileBuffer.nio_write_Long_file_channel(ch, position(), b); + position(position() + 8); + return this; + } +final public long get(int index) + { + long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, index); + return a; + } +final public LongBuffer put(int index, long b) + { + MappedByteFileBuffer.nio_write_Long_file_channel(ch, index, b); + return this; + } +final public LongBuffer compact() + { + return this; + } +final public boolean isDirect() + { + return direct; + } +final public LongBuffer slice() + { + MappedLongFileBuffer A = new MappedLongFileBuffer(this); + return A; + } +public LongBuffer duplicate() + { + return new MappedLongFileBuffer(this); + } +public LongBuffer asReadOnlyBuffer() + { + MappedLongFileBuffer b = new MappedLongFileBuffer(this); + b.ro = true; + return b; + } + final public ByteBuffer asByteBuffer() { return new MappedByteFileBuffer(ch); } final public byte getByte() { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position()); position(position() + 8); return a; } final public LongBuffer putByte(byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), value); position(position() + 8); return this; } final public byte getByte(int index) { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index); return a; } final public LongBuffer putByte(int index, byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, value); return this; }; + final public CharBuffer asCharBuffer() { return new MappedCharFileBuffer(ch); } final public char getChar() { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, position()); position(position() + 8); return a; } final public LongBuffer putChar(char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, position(), value); position(position() + 8); return this; } final public char getChar(int index) { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, index); return a; } final public LongBuffer putChar(int index, char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, index, value); return this; }; + final public ShortBuffer asShortBuffer() { return new MappedShortFileBuffer(ch); } final public short getShort() { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, position()); position(position() + 8); return a; } final public LongBuffer putShort(short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, position(), value); position(position() + 8); return this; } final public short getShort(int index) { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, index); return a; } final public LongBuffer putShort(int index, short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, index, value); return this; }; + final public IntBuffer asIntBuffer() { return new MappedIntFileBuffer(ch); } final public int getInt() { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, position()); position(position() + 8); return a; } final public LongBuffer putInt(int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, position(), value); position(position() + 8); return this; } final public int getInt(int index) { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, index); return a; } final public LongBuffer putInt(int index, int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, index, value); return this; }; + final public LongBuffer asLongBuffer() { return new MappedLongFileBuffer(ch); } final public long getLong() { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, position()); position(position() + 8); return a; } final public LongBuffer putLong(long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, position(), value); position(position() + 8); return this; } final public long getLong(int index) { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, index); return a; } final public LongBuffer putLong(int index, long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, index, value); return this; }; + final public FloatBuffer asFloatBuffer() { return new MappedFloatFileBuffer(ch); } final public float getFloat() { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, position()); position(position() + 8); return a; } final public LongBuffer putFloat(float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, position(), value); position(position() + 8); return this; } final public float getFloat(int index) { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, index); return a; } final public LongBuffer putFloat(int index, float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, index, value); return this; }; + final public DoubleBuffer asDoubleBuffer() { return new MappedDoubleFileBuffer(ch); } final public double getDouble() { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, position()); position(position() + 8); return a; } final public LongBuffer putDouble(double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, position(), value); position(position() + 8); return this; } final public double getDouble(int index) { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, index); return a; } final public LongBuffer putDouble(int index, double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, index, value); return this; }; +} diff --git a/gnu/java/nio/MappedShortFileBuffer.java b/gnu/java/nio/MappedShortFileBuffer.java new file mode 100644 index 000000000..d1ad464d0 --- /dev/null +++ b/gnu/java/nio/MappedShortFileBuffer.java @@ -0,0 +1,77 @@ +package gnu.java.nio; +import java.nio.*; +final public class MappedShortFileBuffer + extends ShortBuffer +{ + public long address; + boolean ro; + boolean direct; + public FileChannelImpl ch; + public MappedShortFileBuffer(FileChannelImpl ch) + { + this.ch = ch; + address = ch.address; + } + public MappedShortFileBuffer(MappedShortFileBuffer b) + { + this.ro = b.ro; + this.ch = b.ch; + address = b.address; + } + public boolean isReadOnly() + { + return ro; + } +final public short get() + { + short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, position()); + position(position() + 2); + return a; + } +final public ShortBuffer put(short b) + { + MappedByteFileBuffer.nio_write_Short_file_channel(ch, position(), b); + position(position() + 2); + return this; + } +final public short get(int index) + { + short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, index); + return a; + } +final public ShortBuffer put(int index, short b) + { + MappedByteFileBuffer.nio_write_Short_file_channel(ch, index, b); + return this; + } +final public ShortBuffer compact() + { + return this; + } +final public boolean isDirect() + { + return direct; + } +final public ShortBuffer slice() + { + MappedShortFileBuffer A = new MappedShortFileBuffer(this); + return A; + } +public ShortBuffer duplicate() + { + return new MappedShortFileBuffer(this); + } +public ShortBuffer asReadOnlyBuffer() + { + MappedShortFileBuffer b = new MappedShortFileBuffer(this); + b.ro = true; + return b; + } + final public ByteBuffer asByteBuffer() { return new MappedByteFileBuffer(ch); } final public byte getByte() { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, position()); position(position() + 2); return a; } final public ShortBuffer putByte(byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, position(), value); position(position() + 2); return this; } final public byte getByte(int index) { byte a = MappedByteFileBuffer.nio_read_Byte_file_channel(ch, index); return a; } final public ShortBuffer putByte(int index, byte value) { MappedByteFileBuffer.nio_write_Byte_file_channel(ch, index, value); return this; }; + final public CharBuffer asCharBuffer() { return new MappedCharFileBuffer(ch); } final public char getChar() { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, position()); position(position() + 2); return a; } final public ShortBuffer putChar(char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, position(), value); position(position() + 2); return this; } final public char getChar(int index) { char a = MappedByteFileBuffer.nio_read_Char_file_channel(ch, index); return a; } final public ShortBuffer putChar(int index, char value) { MappedByteFileBuffer.nio_write_Char_file_channel(ch, index, value); return this; }; + final public ShortBuffer asShortBuffer() { return new MappedShortFileBuffer(ch); } final public short getShort() { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, position()); position(position() + 2); return a; } final public ShortBuffer putShort(short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, position(), value); position(position() + 2); return this; } final public short getShort(int index) { short a = MappedByteFileBuffer.nio_read_Short_file_channel(ch, index); return a; } final public ShortBuffer putShort(int index, short value) { MappedByteFileBuffer.nio_write_Short_file_channel(ch, index, value); return this; }; + final public IntBuffer asIntBuffer() { return new MappedIntFileBuffer(ch); } final public int getInt() { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, position()); position(position() + 2); return a; } final public ShortBuffer putInt(int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, position(), value); position(position() + 2); return this; } final public int getInt(int index) { int a = MappedByteFileBuffer.nio_read_Int_file_channel(ch, index); return a; } final public ShortBuffer putInt(int index, int value) { MappedByteFileBuffer.nio_write_Int_file_channel(ch, index, value); return this; }; + final public LongBuffer asLongBuffer() { return new MappedLongFileBuffer(ch); } final public long getLong() { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, position()); position(position() + 2); return a; } final public ShortBuffer putLong(long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, position(), value); position(position() + 2); return this; } final public long getLong(int index) { long a = MappedByteFileBuffer.nio_read_Long_file_channel(ch, index); return a; } final public ShortBuffer putLong(int index, long value) { MappedByteFileBuffer.nio_write_Long_file_channel(ch, index, value); return this; }; + final public FloatBuffer asFloatBuffer() { return new MappedFloatFileBuffer(ch); } final public float getFloat() { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, position()); position(position() + 2); return a; } final public ShortBuffer putFloat(float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, position(), value); position(position() + 2); return this; } final public float getFloat(int index) { float a = MappedByteFileBuffer.nio_read_Float_file_channel(ch, index); return a; } final public ShortBuffer putFloat(int index, float value) { MappedByteFileBuffer.nio_write_Float_file_channel(ch, index, value); return this; }; + final public DoubleBuffer asDoubleBuffer() { return new MappedDoubleFileBuffer(ch); } final public double getDouble() { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, position()); position(position() + 2); return a; } final public ShortBuffer putDouble(double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, position(), value); position(position() + 2); return this; } final public double getDouble(int index) { double a = MappedByteFileBuffer.nio_read_Double_file_channel(ch, index); return a; } final public ShortBuffer putDouble(int index, double value) { MappedByteFileBuffer.nio_write_Double_file_channel(ch, index, value); return this; }; +} diff --git a/gnu/java/nio/ShortBufferImpl.java b/gnu/java/nio/ShortBufferImpl.java new file mode 100644 index 000000000..1b15d4912 --- /dev/null +++ b/gnu/java/nio/ShortBufferImpl.java @@ -0,0 +1,102 @@ +package gnu.java.nio; +import java.nio.*; +public final class ShortBufferImpl extends java.nio. ShortBuffer +{ + private int array_offset; + short [] backing_buffer; + private boolean ro; + public ShortBufferImpl(int cap, int off, int lim) + { + this.backing_buffer = new short[cap]; + this.capacity(cap); + this.position(off); + this.limit(lim); + } + public ShortBufferImpl(short[] array, int off, int lim) + { + this.backing_buffer = array; + this.capacity(array.length); + this.position(off); + this.limit(lim); + } + public ShortBufferImpl(ShortBufferImpl copy) + { + backing_buffer = copy.backing_buffer; + ro = copy.ro; + position(copy.position()); + limit(copy.limit()); + } + void inc_pos(int a) + { + position(position() + a); + } + 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); + ShortBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native byte nio_get_Byte(ShortBufferImpl b, int index); private static native void nio_put_Byte(ShortBufferImpl b, int index, byte value); public java.nio. ByteBuffer asByteBuffer() { return new gnu.java.nio. ByteBufferImpl(backing_buffer); } + ShortBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native char nio_get_Char(ShortBufferImpl b, int index); private static native void nio_put_Char(ShortBufferImpl b, int index, char value); public java.nio. CharBuffer asCharBuffer() { return new gnu.java.nio. CharBufferImpl(backing_buffer); } + ShortBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native short nio_get_Short(ShortBufferImpl b, int index); private static native void nio_put_Short(ShortBufferImpl b, int index, short value); public java.nio. ShortBuffer asShortBuffer() { return new gnu.java.nio. ShortBufferImpl(backing_buffer); } + ShortBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native int nio_get_Int(ShortBufferImpl b, int index); private static native void nio_put_Int(ShortBufferImpl b, int index, int value); public java.nio. IntBuffer asIntBuffer() { return new gnu.java.nio. IntBufferImpl(backing_buffer); } + ShortBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native long nio_get_Long(ShortBufferImpl b, int index); private static native void nio_put_Long(ShortBufferImpl b, int index, long value); public java.nio. LongBuffer asLongBuffer() { return new gnu.java.nio. LongBufferImpl(backing_buffer); } + ShortBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native float nio_get_Float(ShortBufferImpl b, int index); private static native void nio_put_Float(ShortBufferImpl b, int index, float value); public java.nio. FloatBuffer asFloatBuffer() { return new gnu.java.nio. FloatBufferImpl(backing_buffer); } + ShortBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native double nio_get_Double(ShortBufferImpl b, int index); private static native void nio_put_Double(ShortBufferImpl b, int index, double value); public java.nio. DoubleBuffer asDoubleBuffer() { return new gnu.java.nio. DoubleBufferImpl(backing_buffer); } + public boolean isReadOnly() + { + return ro; + } + public java.nio. ShortBuffer slice() + { + ShortBufferImpl A = new ShortBufferImpl(this); + A.array_offset = position(); + return A; + } + public java.nio. ShortBuffer duplicate() + { + return new ShortBufferImpl(this); + } + public java.nio. ShortBuffer asReadOnlyBuffer() + { + ShortBufferImpl a = new ShortBufferImpl(this); + a.ro = true; + return a; + } + public java.nio. ShortBuffer compact() + { + return this; + } + public boolean isDirect() + { + return backing_buffer != null; + } + final public short get() + { + short e = backing_buffer[position()]; + position(position()+1); + return e; + } + final public java.nio. ShortBuffer put(short b) + { + backing_buffer[position()] = b; + position(position()+1); + return this; + } + final public short get(int index) + { + return backing_buffer[index]; + } + final public java.nio. ShortBuffer put(int index, short b) + { + backing_buffer[index] = b; + return this; + } + final public char getChar() { char a = nio_get_Char(this, position()); inc_pos(2); return a; } final public java.nio. ShortBuffer putChar(char value) { nio_put_Char(this, position(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index); return a; } final public java.nio. ShortBuffer putChar(int index, char value) { nio_put_Char(this, index, value); return this; }; + final public short getShort() { return get(); } final public java.nio. ShortBuffer putShort(short value) { return put(value); } final public short getShort(int index) { return get(index); } final public java.nio. ShortBuffer putShort(int index, short value) { return put(index, value); }; + final public int getInt() { int a = nio_get_Int(this, position()); inc_pos(4); return a; } final public java.nio. ShortBuffer putInt(int value) { nio_put_Int(this, position(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index); return a; } final public java.nio. ShortBuffer putInt(int index, int value) { nio_put_Int(this, index, value); return this; }; + final public long getLong() { long a = nio_get_Long(this, position()); inc_pos(8); return a; } final public java.nio. ShortBuffer putLong(long value) { nio_put_Long(this, position(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index); return a; } final public java.nio. ShortBuffer putLong(int index, long value) { nio_put_Long(this, index, value); return this; }; + final public float getFloat() { float a = nio_get_Float(this, position()); inc_pos(4); return a; } final public java.nio. ShortBuffer putFloat(float value) { nio_put_Float(this, position(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index); return a; } final public java.nio. ShortBuffer putFloat(int index, float value) { nio_put_Float(this, index, value); return this; }; + final public double getDouble() { double a = nio_get_Double(this, position()); inc_pos(8); return a; } final public java.nio. ShortBuffer putDouble(double value) { nio_put_Double(this, position(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index); return a; } final public java.nio. ShortBuffer putDouble(int index, double value) { nio_put_Double(this, index, value); return this; }; +} |