ByteBufferImpl.java: Reformatted.

2003-05-12  Michael Koch  <konqueror@gmx.de>

	* gnu/java/nio/ByteBufferImpl.java: Reformatted.
	(nio_get_*): Removed.
	(nio_put_*): Removed.
	(as*Buffer): Implemented.
	(compact): Implemented.
	(get): Documentation added.
	(put): Documentation added.
	(get*): Newly implemented.
	(put*): Newly implemented.
	* gnu/java/nio/CharBufferImpl.java: Reformatted.
	(CharBufferImpl): Revised.
	(slice): New implementation.
	(duplicate): New implementation.
	(compact): New implementation.
	(asReadOnlyBuffer): New implementation.
	(get): Documentation revised.
	(order): Return native byte order.
	* gnu/java/nio/DirectByteBufferImpl.java
	(allocateDirect): objects can be null not 0.
	* gnu/java/nio/DoubleBufferImpl.java: Reformatted.
	(DoubleBufferImpl): Revised.
	(slice): New implementation.
	(duplicate): New implementation.
	(compact): New implementation.
	(asReadOnlyBuffer): New implementation.
	(get): Documentation revised.
	(order): Return native byte order.
	* gnu/java/nio/FloatBufferImpl.java: Reformatted.
	(FloatBufferImpl): Revised.
	(slice): New implementation.
	(duplicate): New implementation.
	(compact): New implementation.
	(asReadOnlyBuffer): New implementation.
	(get): Documentation revised.
	(order): Return native byte order.
	* gnu/java/nio/IntBufferImpl.java: Reformatted.
	(IntBufferImpl): Revised.
	(slice): New implementation.
	(duplicate): New implementation.
	(compact): New implementation.
	(asReadOnlyBuffer): New implementation.
	(get): Documentation revised.
	(order): Return native byte order.
	* gnu/java/nio/LongBufferImpl.java: Reformatted.
	(LongBufferImpl): Revised.
	(slice): New implementation.
	(duplicate): New implementation.
	(compact): New implementation.
	(asReadOnlyBuffer): New implementation.
	(get): Documentation revised.
	(order): Return native byte order.
	* gnu/java/nio/ShortBufferImpl.java: Reformatted.
	(ShortBufferImpl): Revised.
	(slice): New implementation.
	(duplicate): New implementation.
	(compact): New implementation.
	(asReadOnlyBuffer): New implementation.
	(get): Documentation revised.
	(order): Return native byte order.
	* java/nio/CharBuffer.java: Reformatted, much documentation rewritten.
	(CharBuffer): Revised.
	(order): Removed.
	* java/nio/DoubleBuffer.java: Reformatted, much documentation rewritten.
	(DoubleBuffer): Revised.
	(allocateDirect): Removed.
	(order): Removed.
	* java/nio/FloatBuffer.java: Reformatted, much documentation rewritten.
	(FloatBuffer): Revised.
	(allocateDirect): Removed.
	(order): Removed.
	* java/nio/IntBuffer.java: Reformatted, much documentation rewritten.
	(IntBuffer): Revised.
	(allocateDirect): Removed.
	(order): Removed.
	* java/nio/LongBuffer.java: Reformatted, much documentation rewritten.
	(LongBuffer): Revised.
	(allocateDirect): Removed.
	(order): Removed.
	* java/nio/ShortBuffer.java: Reformatted, much documentation rewritten.
	(ShortBuffer): Revised.
	(allocateDirect): Removed.
	(order): Removed.
	* gnu/java/nio/natByteBufferImpl.cc: Removed.
	* gnu/java/nio/natCharBufferImpl.cc: Removed.
	* Makefile.am
	(ordinary_java_source_files): Added the following files:
	gnu/java/nio/CharViewBufferImpl.java,
	gnu/java/nio/DoubleViewBufferImpl.java,
	gnu/java/nio/FloatViewBufferImpl.java,
	gnu/java/nio/IntViewBufferImpl.java,
	gnu/java/nio/LongViewBufferImpl.java,
	gnu/java/nio/ShortViewBufferImpl.java
	(nat_source_files): Removed the following files:
	gnu/java/nio/natByteBufferImpl.cc,
	gnu/java/nio/natCharBufferImpl.cc
	* Makefile.in: Regenerated.

From-SVN: r66733
This commit is contained in:
Michael Koch 2003-05-12 20:45:20 +00:00 committed by Michael Koch
parent d3e0dffb76
commit 36d4669b73
19 changed files with 2056 additions and 976 deletions

View file

@ -1,5 +1,5 @@
/* ByteBufferImpl.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.java.nio;
import java.nio.ByteBuffer;
@ -66,7 +67,7 @@ public final class ByteBufferImpl extends ByteBuffer
this.backing_buffer = array;
readOnly = false;
}
public ByteBufferImpl (ByteBufferImpl copy)
{
super (copy.capacity (), copy.limit (), copy.position (), 0);
@ -79,311 +80,369 @@ public final class ByteBufferImpl extends ByteBuffer
position (position () + toAdd);
}
private static native char nio_get_Char (ByteBufferImpl b, int index, int limit);
private static native void nio_put_Char (ByteBufferImpl b, int index, int limit, char value);
public CharBuffer asCharBuffer ()
{
throw new Error ("Not implemented");
return new CharViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
}
private static native short nio_get_Short (ByteBufferImpl b, int index, int limit);
private static native void nio_put_Short (ByteBufferImpl b, int index, int limit, short value);
public ShortBuffer asShortBuffer ()
{
throw new Error ("Not implemented");
return new ShortViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
}
private static native int nio_get_Int (ByteBufferImpl b, int index, int limit);
private static native void nio_put_Int (ByteBufferImpl b, int index, int limit, int value);
public IntBuffer asIntBuffer ()
{
throw new Error ("Not implemented");
return new IntViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
}
private static native long nio_get_Long (ByteBufferImpl b, int index, int limit);
private static native void nio_put_Long (ByteBufferImpl b, int index, int limit, long value);
public LongBuffer asLongBuffer ()
{
throw new Error ("Not implemented");
return new LongViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
}
private static native float nio_get_Float (ByteBufferImpl b, int index, int limit);
private static native void nio_put_Float (ByteBufferImpl b, int index, int limit, float value);
public FloatBuffer asFloatBuffer ()
{
throw new Error ("Not implemented");
return new FloatViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
}
private static native double nio_get_Double (ByteBufferImpl b, int index, int limit);
private static native void nio_put_Double (ByteBufferImpl b, int index, int limit, double value);
public DoubleBuffer asDoubleBuffer ()
{
throw new Error ("Not implemented");
return new DoubleViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
}
public boolean isReadOnly()
public boolean isReadOnly ()
{
return readOnly;
}
public ByteBuffer slice()
public ByteBuffer slice ()
{
return new ByteBufferImpl(this);
return new ByteBufferImpl (this);
}
public ByteBuffer duplicate()
public ByteBuffer duplicate ()
{
return new ByteBufferImpl(this);
return new ByteBufferImpl (this);
}
public ByteBuffer asReadOnlyBuffer()
public ByteBuffer asReadOnlyBuffer ()
{
ByteBufferImpl a = new ByteBufferImpl(this);
ByteBufferImpl a = new ByteBufferImpl (this);
a.readOnly = true;
return a;
}
public ByteBuffer compact()
public ByteBuffer compact ()
{
int copied = 0;
while (remaining () > 0)
{
put (copied, get ());
copied++;
}
position (copied);
return this;
}
public boolean isDirect()
public boolean isDirect ()
{
return false;
}
final public byte get()
/**
* Relative get method. Reads the next <code>byte</code> from the buffer.
*/
final public byte get ()
{
byte e = backing_buffer[position()];
position(position()+1);
return e;
byte result = backing_buffer [position ()];
position (position () + 1);
return result;
}
final public ByteBuffer put(byte b)
/**
* Relative put method. Writes <code>value</code> to the next position
* in the buffer.
*
* @exception ReadOnlyBufferException If this buffer is read-only.
*/
final public ByteBuffer put (byte value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
backing_buffer[position()] = b;
position(position()+1);
backing_buffer [position ()] = value;
position (position () + 1);
return this;
}
final public byte get(int index)
/**
* Absolute get method. Reads the <code>byte</code> at position
* <code>index</code>.
*
* @exception IndexOutOfBoundsException If index is negative or not smaller
* than the buffer's limit.
*/
final public byte get (int index)
{
return backing_buffer[index];
return backing_buffer [index];
}
final public ByteBuffer put(int index, byte b)
/**
* Absolute put method. Writes <code>value</value> to position
* <code>index</code> in the buffer.
*
* @exception IndexOutOfBoundsException If index is negative or not smaller
* than the buffer's limit.
* @exception ReadOnlyBufferException If this buffer is read-only.
*/
final public ByteBuffer put (int index, byte value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
backing_buffer[index] = b;
backing_buffer [index] = value;
return this;
}
final public char getChar ()
{
char a = nio_get_Char (this, position (), limit ());
inc_pos (2);
return a;
// FIXME: this handles big endian only
return (char) (((get () & 0xff) << 8) + (get () & 0xff));
}
final public ByteBuffer putChar (char value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
nio_put_Char (this, position (), limit (), value);
inc_pos (2);
// FIXME: this handles big endian only
put ((byte) ((((int) value) & 0xff00) >> 8));
put ((byte) (((int) value) & 0x00ff));
return this;
}
final public char getChar (int index)
{
char a = nio_get_Char (this, index, limit ());
return a;
// FIXME: this handles big endian only
return (char) (((get (index) & 0xff) << 8) + (get (index + 1) & 0xff));
}
final public ByteBuffer putChar (int index, char value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
nio_put_Char (this, index, limit (), value);
// FIXME: this handles big endian only
put (index, (byte) ((((int) value) & 0xff00) >> 8));
put (index + 1, (byte) (((int) value) & 0x00ff));
return this;
}
final public short getShort ()
{
short a = nio_get_Short (this, position (), limit ());
inc_pos (2);
return a;
// FIXME: this handles big endian only
return (short) (((get () & 0xff) << 8) + (get () & 0xff));
}
final public ByteBuffer putShort (short value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
nio_put_Short (this, position (), limit (), value);
inc_pos (2);
// FIXME: this handles big endian only
put ((byte) ((((int) value) & 0xff00) >> 8));
put ((byte) (((int) value) & 0x00ff));
return this;
}
final public short getShort (int index)
{
short a = nio_get_Short (this, index, limit ());
return a;
// FIXME: this handles big endian only
return (short) (((get (index) & 0xff) << 8) + (get (index + 1) & 0xff));
}
final public ByteBuffer putShort (int index, short value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
nio_put_Short (this, index, limit (), value);
// FIXME: this handles big endian only
put (index, (byte) ((((int) value) & 0xff00) >> 8));
put (index + 1, (byte) (((int) value) & 0x00ff));
return this;
}
final public int getInt ()
{
int a = nio_get_Int (this, position (), limit ());
inc_pos (4);
return a;
// FIXME: this handles big endian only
return (int) (((get () & 0xff) << 24)
+ (get () & 0xff) << 16
+ (get () & 0xff) << 8
+ (get () & 0xff));
}
final public ByteBuffer putInt (int value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
nio_put_Int (this, position (), limit (), value);
inc_pos (4);
// FIXME: this handles big endian only
put ((byte) ((((int) value) & 0xff000000) >> 24));
put ((byte) ((((int) value) & 0x00ff0000) >> 16));
put ((byte) ((((int) value) & 0x0000ff00) >> 8));
put ((byte) (((int) value) & 0x000000ff));
return this;
}
final public int getInt (int index)
{
int a = nio_get_Int (this, index, limit ());
return a;
// FIXME: this handles big endian only
return (int) (((get (index) & 0xff) << 24)
+ (get (index + 1) & 0xff) << 16
+ (get (index + 2) & 0xff) << 8
+ (get (index + 3) & 0xff));
}
final public ByteBuffer putInt (int index, int value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
nio_put_Int(this, index, limit (), value);
// FIXME: this handles big endian only
put (index, (byte) ((((int) value) & 0xff000000) >> 24));
put (index + 1, (byte) ((((int) value) & 0x00ff0000) >> 16));
put (index + 2, (byte) ((((int) value) & 0x0000ff00) >> 8));
put (index + 3, (byte) (((int) value) & 0x000000ff));
return this;
}
final public long getLong ()
{
long a = nio_get_Long (this, position (), limit ());
inc_pos (8);
return a;
// FIXME: this handles big endian only
return (long) (((get () & 0xff) << 56)
+ (get () & 0xff) << 48
+ (get () & 0xff) << 40
+ (get () & 0xff) << 32
+ (get () & 0xff) << 24
+ (get () & 0xff) << 16
+ (get () & 0xff) << 8
+ (get () & 0xff));
}
final public ByteBuffer putLong (long value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
nio_put_Long (this, position (), limit (), value);
inc_pos (8);
// FIXME: this handles big endian only
put ((byte) ((((int) value) & 0xff00000000000000) >> 56));
put ((byte) ((((int) value) & 0x00ff000000000000) >> 48));
put ((byte) ((((int) value) & 0x0000ff0000000000) >> 40));
put ((byte) ((((int) value) & 0x000000ff00000000) >> 32));
put ((byte) ((((int) value) & 0x00000000ff000000) >> 24));
put ((byte) ((((int) value) & 0x0000000000ff0000) >> 16));
put ((byte) ((((int) value) & 0x000000000000ff00) >> 8));
put ((byte) (((int) value) & 0x00000000000000ff));
return this;
}
final public long getLong (int index)
{
long a = nio_get_Long (this, index, limit ());
return a;
// FIXME: this handles big endian only
return (long) (((get (index) & 0xff) << 56)
+ (get (index + 1) & 0xff) << 48
+ (get (index + 2) & 0xff) << 40
+ (get (index + 3) & 0xff) << 32
+ (get (index + 4) & 0xff) << 24
+ (get (index + 5) & 0xff) << 16
+ (get (index + 6) & 0xff) << 8
+ (get (index + 7) & 0xff));
}
final public ByteBuffer putLong (int index, long value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
nio_put_Long (this, index, limit (), value);
// FIXME: this handles big endian only
put (index, (byte) ((((int) value) & 0xff00000000000000) >> 56));
put (index + 1, (byte) ((((int) value) & 0x00ff000000000000) >> 48));
put (index + 2, (byte) ((((int) value) & 0x0000ff0000000000) >> 40));
put (index + 3, (byte) ((((int) value) & 0x000000ff00000000) >> 32));
put (index + 4, (byte) ((((int) value) & 0x00000000ff000000) >> 24));
put (index + 5, (byte) ((((int) value) & 0x0000000000ff0000) >> 16));
put (index + 6, (byte) ((((int) value) & 0x000000000000ff00) >> 8));
put (index + 7, (byte) (((int) value) & 0x00000000000000ff));
return this;
}
final public float getFloat ()
{
float a = nio_get_Float (this, position (), limit ());
inc_pos (4);
return a;
// FIXME: this handles big endian only
return (float) (((get () & 0xff) << 24)
+ (get () & 0xff) << 16
+ (get () & 0xff) << 8
+ (get () & 0xff));
}
final public ByteBuffer putFloat (float value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
nio_put_Float (this, position (), limit (), value);
inc_pos (4);
// FIXME: this handles big endian only
put ((byte) ((((int) value) & 0xff000000) >> 24));
put ((byte) ((((int) value) & 0x00ff0000) >> 16));
put ((byte) ((((int) value) & 0x0000ff00) >> 8));
put ((byte) (((int) value) & 0x000000ff));
return this;
}
final public float getFloat (int index)
{
float a = nio_get_Float (this, index, limit ());
return a;
// FIXME: this handles big endian only
return (float) (((get (index) & 0xff) << 24)
+ (get (index + 1) & 0xff) << 16
+ (get (index + 2) & 0xff) << 8
+ (get (index + 3) & 0xff));
}
final public ByteBuffer putFloat (int index, float value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
nio_put_Float (this, index, limit(), value);
// FIXME: this handles big endian only
put (index, (byte) ((((int) value) & 0xff000000) >> 24));
put (index + 1, (byte) ((((int) value) & 0x00ff0000) >> 16));
put (index + 2, (byte) ((((int) value) & 0x0000ff00) >> 8));
put (index + 3, (byte) (((int) value) & 0x000000ff));
return this;
}
final public double getDouble ()
{
double a = nio_get_Double (this, position (), limit ());
inc_pos (8);
return a;
// FIXME: this handles big endian only
return (double) (((get () & 0xff) << 56)
+ (get () & 0xff) << 48
+ (get () & 0xff) << 40
+ (get () & 0xff) << 32
+ (get () & 0xff) << 24
+ (get () & 0xff) << 16
+ (get () & 0xff) << 8
+ (get () & 0xff));
}
final public ByteBuffer putDouble (double value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
nio_put_Double (this, position(), limit (), value);
inc_pos (8);
// FIXME: this handles big endian only
put ((byte) ((((int) value) & 0xff00000000000000) >> 56));
put ((byte) ((((int) value) & 0x00ff000000000000) >> 48));
put ((byte) ((((int) value) & 0x0000ff0000000000) >> 40));
put ((byte) ((((int) value) & 0x000000ff00000000) >> 32));
put ((byte) ((((int) value) & 0x00000000ff000000) >> 24));
put ((byte) ((((int) value) & 0x0000000000ff0000) >> 16));
put ((byte) ((((int) value) & 0x000000000000ff00) >> 8));
put ((byte) (((int) value) & 0x00000000000000ff));
return this;
}
final public double getDouble (int index)
{
return nio_get_Double (this, index, limit ());
// FIXME: this handles big endian only
return (double) (((get (index) & 0xff) << 56)
+ (get (index + 1) & 0xff) << 48
+ (get (index + 2) & 0xff) << 40
+ (get (index + 3) & 0xff) << 32
+ (get (index + 4) & 0xff) << 24
+ (get (index + 5) & 0xff) << 16
+ (get (index + 6) & 0xff) << 8
+ (get (index + 7) & 0xff));
}
final public ByteBuffer putDouble (int index, double value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
nio_put_Double (this, index, limit (), value);
// FIXME: this handles big endian only
put (index, (byte) ((((int) value) & 0xff00000000000000) >> 56));
put (index + 1, (byte) ((((int) value) & 0x00ff000000000000) >> 48));
put (index + 2, (byte) ((((int) value) & 0x0000ff0000000000) >> 40));
put (index + 3, (byte) ((((int) value) & 0x000000ff00000000) >> 32));
put (index + 4, (byte) ((((int) value) & 0x00000000ff000000) >> 24));
put (index + 5, (byte) ((((int) value) & 0x0000000000ff0000) >> 16));
put (index + 6, (byte) ((((int) value) & 0x000000000000ff00) >> 8));
put (index + 7, (byte) (((int) value) & 0x00000000000000ff));
return this;
}
}

View file

@ -1,5 +1,5 @@
/* CharBufferImpl.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.java.nio;
import java.nio.ByteBuffer;
@ -49,18 +50,15 @@ public final class CharBufferImpl extends CharBuffer
{
private boolean readOnly;
public CharBufferImpl(int cap, int off, int lim)
CharBufferImpl (int capacity)
{
super (cap, lim, off, 0);
this.backing_buffer = new char [cap];
readOnly = false;
this (new char [capacity], 0, capacity, capacity, 0, -1, false);
}
public CharBufferImpl(char[] array, int offset, int length)
CharBufferImpl (char[] buffer, int offset, int capacity, int limit, int position, int mark, boolean readOnly)
{
super (array.length, length, offset, 0);
this.backing_buffer = array;
readOnly = false;
super (buffer, offset, capacity, limit, position, mark);
this.readOnly = readOnly;
}
public CharBufferImpl (CharBufferImpl copy)
@ -70,37 +68,41 @@ public final class CharBufferImpl extends CharBuffer
readOnly = copy.isReadOnly ();
}
private static native char[] nio_cast (byte[] copy);
public boolean isReadOnly()
public boolean isReadOnly ()
{
return readOnly;
}
public CharBuffer slice()
public CharBuffer slice ()
{
return new CharBufferImpl (backing_buffer, arrayOffset () + position (),
remaining ());
return new CharBufferImpl (backing_buffer, array_offset + position (), remaining (), remaining (), 0, -1, isReadOnly ());
}
public CharBuffer duplicate()
public CharBuffer duplicate ()
{
return new CharBufferImpl(this);
return new CharBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, isReadOnly ());
}
public CharBuffer asReadOnlyBuffer()
public CharBuffer asReadOnlyBuffer ()
{
CharBufferImpl result = new CharBufferImpl (this);
result.readOnly = true;
return result;
return new CharBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, true);
}
public CharBuffer compact()
public CharBuffer compact ()
{
int copied = 0;
while (remaining () > 0)
{
put (copied, get ());
copied++;
}
position (copied);
return this;
}
public boolean isDirect()
public boolean isDirect ()
{
return false;
}
@ -113,20 +115,17 @@ public final class CharBufferImpl extends CharBuffer
|| end > length ())
throw new IndexOutOfBoundsException ();
// No support for direct buffers yet.
// assert array () != null;
return new CharBufferImpl (array (), position () + start,
position () + end);
return new CharBufferImpl (backing_buffer, array_offset, capacity (), position () + end, position () + start, -1, isReadOnly ());
}
/**
* Relative get method. Reads the next character from the buffer.
* Relative get method. Reads the next <code>char</code> from the buffer.
*/
final public char get()
final public char get ()
{
char e = backing_buffer[position()];
position(position()+1);
return e;
char result = backing_buffer [position ()];
position (position () + 1);
return result;
}
/**
@ -135,29 +134,30 @@ public final class CharBufferImpl extends CharBuffer
*
* @exception ReadOnlyBufferException If this buffer is read-only.
*/
final public CharBuffer put(char b)
final public CharBuffer put (char value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
backing_buffer[position()] = b;
position(position()+1);
backing_buffer [position ()] = value;
position (position () + 1);
return this;
}
/**
* Absolute get method. Reads the character at position <code>index</code>.
* Absolute get method. Reads the <code>char</code> at position
* <code>index</code>.
*
* @exception IndexOutOfBoundsException If index is negative or not smaller
* than the buffer's limit.
*/
final public char get(int index)
final public char get (int index)
{
if (index < 0
|| index >= limit ())
throw new IndexOutOfBoundsException ();
return backing_buffer[index];
return backing_buffer [index];
}
/**
@ -168,7 +168,7 @@ public final class CharBufferImpl extends CharBuffer
* than the buffer's limit.
* @exception ReadOnlyBufferException If this buffer is read-only.
*/
final public CharBuffer put(int index, char b)
final public CharBuffer put (int index, char value)
{
if (index < 0
|| index >= limit ())
@ -176,14 +176,13 @@ public final class CharBufferImpl extends CharBuffer
if (readOnly)
throw new ReadOnlyBufferException ();
backing_buffer[index] = b;
backing_buffer [index] = value;
return this;
}
public final ByteOrder order()
final public ByteOrder order ()
{
return ByteOrder.BIG_ENDIAN;
return ByteOrder.nativeOrder ();
}
}

View file

@ -75,7 +75,7 @@ public class DirectByteBufferImpl extends ByteBuffer
{
RawData address = allocateImpl (capacity);
if (address == 0)
if (address == null)
throw new InternalError ("Not enough memory to create direct buffer");
return new DirectByteBufferImpl (address, 0, capacity, capacity, 0, -1, false);

View file

@ -1,5 +1,5 @@
/* DoubleBufferImpl.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.java.nio;
import java.nio.ByteBuffer;
@ -48,93 +49,114 @@ import java.nio.ReadOnlyBufferException;
public final class DoubleBufferImpl extends DoubleBuffer
{
private boolean readOnly;
public DoubleBufferImpl(int cap, int off, int lim)
{
super (cap, lim, off, 0);
this.backing_buffer = new double[cap];
readOnly = false;
}
public DoubleBufferImpl(double[] array, int offset, int length)
{
super (array.length, length, offset, 0);
this.backing_buffer = array;
readOnly = false;
}
public DoubleBufferImpl(DoubleBufferImpl copy)
DoubleBufferImpl (int capacity)
{
super (copy.capacity (), copy.limit (), copy.position (), 0);
backing_buffer = copy.backing_buffer;
readOnly = copy.isReadOnly ();
this (new double [capacity], 0, capacity, capacity, 0, -1, false);
}
DoubleBufferImpl (double[] buffer, int offset, int capacity, int limit, int position, int mark, boolean readOnly)
{
super (buffer, offset, capacity, limit, position, mark);
this.readOnly = readOnly;
}
public boolean isReadOnly ()
{
return readOnly;
}
public DoubleBuffer slice ()
{
return new DoubleBufferImpl (this);
return new DoubleBufferImpl (backing_buffer, array_offset + position (), remaining (), remaining (), 0, -1, isReadOnly ());
}
public DoubleBuffer duplicate()
public DoubleBuffer duplicate ()
{
return new DoubleBufferImpl(this);
return new DoubleBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, isReadOnly ());
}
public DoubleBuffer asReadOnlyBuffer()
public DoubleBuffer asReadOnlyBuffer ()
{
DoubleBufferImpl result = new DoubleBufferImpl (this);
result.readOnly = true;
return result;
return new DoubleBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, true);
}
public DoubleBuffer compact()
public DoubleBuffer compact ()
{
int copied = 0;
while (remaining () > 0)
{
put (copied, get ());
copied++;
}
position (copied);
return this;
}
public boolean isDirect()
public boolean isDirect ()
{
return false;
}
final public double get()
/**
* Relative get method. Reads the next <code>double</code> from the buffer.
*/
final public double get ()
{
double e = backing_buffer[position()];
position(position()+1);
return e;
double result = backing_buffer [position ()];
position (position () + 1);
return result;
}
final public DoubleBuffer put(double b)
/**
* Relative put method. Writes <code>value</code> to the next position
* in the buffer.
*
* @exception ReadOnlyBufferException If this buffer is read-only.
*/
final public DoubleBuffer put (double value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
backing_buffer[position()] = b;
position(position()+1);
backing_buffer [position ()] = value;
position (position () + 1);
return this;
}
final public double get(int index)
/**
* Absolute get method. Reads the <code>double</code> at position
* <code>index</code>.
*
* @exception IndexOutOfBoundsException If index is negative or not smaller
* than the buffer's limit.
*/
final public double get (int index)
{
return backing_buffer[index];
return backing_buffer [index];
}
final public DoubleBuffer put(int index, double b)
/**
* Absolute put method. Writes <code>value</value> to position
* <code>index</code> in the buffer.
*
* @exception IndexOutOfBoundsException If index is negative or not smaller
* than the buffer's limit.
* @exception ReadOnlyBufferException If this buffer is read-only.
*/
final public DoubleBuffer put (int index, double value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
backing_buffer[index] = b;
backing_buffer [index] = value;
return this;
}
final public ByteOrder order ()
{
return ByteOrder.BIG_ENDIAN;
return ByteOrder.nativeOrder ();
}
}

View file

@ -1,5 +1,5 @@
/* FloatBufferImpl.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.java.nio;
import java.nio.ByteBuffer;
@ -48,26 +49,16 @@ import java.nio.ReadOnlyBufferException;
public final class FloatBufferImpl extends FloatBuffer
{
private boolean readOnly;
public FloatBufferImpl(int cap, int off, int lim)
FloatBufferImpl (int capacity)
{
super (cap, lim, off, 0);
this.backing_buffer = new float [cap];
readOnly = false;
this (new float [capacity], 0, capacity, capacity, 0, -1, false);
}
public FloatBufferImpl(float[] array, int offset, int length)
FloatBufferImpl (float[] buffer, int offset, int capacity, int limit, int position, int mark, boolean readOnly)
{
super (array.length, length, offset, 0);
this.backing_buffer = array;
readOnly = false;
}
public FloatBufferImpl(FloatBufferImpl copy)
{
super (copy.capacity (), copy.limit (), copy.position (), 0);
backing_buffer = copy.backing_buffer;
readOnly = copy.isReadOnly ();
super (buffer, offset, capacity, limit, position, mark);
this.readOnly = readOnly;
}
public boolean isReadOnly ()
@ -75,66 +66,97 @@ public final class FloatBufferImpl extends FloatBuffer
return readOnly;
}
public FloatBuffer slice()
public FloatBuffer slice ()
{
return new FloatBufferImpl (this);
return new FloatBufferImpl (backing_buffer, array_offset + position (), remaining (), remaining (), 0, -1, isReadOnly ());
}
public FloatBuffer duplicate()
public FloatBuffer duplicate ()
{
return new FloatBufferImpl(this);
return new FloatBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, isReadOnly ());
}
public FloatBuffer asReadOnlyBuffer()
public FloatBuffer asReadOnlyBuffer ()
{
FloatBufferImpl result = new FloatBufferImpl (this);
result.readOnly = true;
return result;
return new FloatBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, true);
}
public FloatBuffer compact()
public FloatBuffer compact ()
{
int copied = 0;
while (remaining () > 0)
{
put (copied, get ());
copied++;
}
position (copied);
return this;
}
public boolean isDirect()
public boolean isDirect ()
{
return false;
}
final public float get()
/**
* Relative get method. Reads the next <code>float</code> from the buffer.
*/
final public float get ()
{
float e = backing_buffer[position()];
position(position()+1);
return e;
float result = backing_buffer [position ()];
position (position () + 1);
return result;
}
final public FloatBuffer put(float b)
/**
* Relative put method. Writes <code>value</code> to the next position
* in the buffer.
*
* @exception ReadOnlyBufferException If this buffer is read-only.
*/
final public FloatBuffer put (float value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
backing_buffer[position()] = b;
position(position()+1);
backing_buffer [position ()] = value;
position (position () + 1);
return this;
}
final public float get(int index)
/**
* Absolute get method. Reads the <code>float</code> at position
* <code>index</code>.
*
* @exception IndexOutOfBoundsException If index is negative or not smaller
* than the buffer's limit.
*/
final public float get (int index)
{
return backing_buffer[index];
return backing_buffer [index];
}
final public FloatBuffer put(int index, float b)
/**
* Absolute put method. Writes <code>value</value> to position
* <code>index</code> in the buffer.
*
* @exception IndexOutOfBoundsException If index is negative or not smaller
* than the buffer's limit.
* @exception ReadOnlyBufferException If this buffer is read-only.
*/
final public FloatBuffer put (int index, float value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
backing_buffer[index] = b;
backing_buffer [index] = value;
return this;
}
final public ByteOrder order ()
{
return ByteOrder.BIG_ENDIAN;
return ByteOrder.nativeOrder ();
}
}

View file

@ -1,5 +1,5 @@
/* IntBufferImpl.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.java.nio;
import java.nio.ByteBuffer;
@ -48,93 +49,114 @@ import java.nio.ReadOnlyBufferException;
public final class IntBufferImpl extends IntBuffer
{
private boolean readOnly;
IntBufferImpl (int capacity)
{
this (new int [capacity], 0, capacity, capacity, 0, -1, false);
}
public IntBufferImpl(int cap, int off, int lim)
IntBufferImpl (int[] buffer, int offset, int capacity, int limit, int position, int mark, boolean readOnly)
{
super (cap, lim, off, 0);
this.backing_buffer = new int[cap];
readOnly = false;
super (buffer, offset, capacity, limit, position, mark);
this.readOnly = readOnly;
}
public IntBufferImpl(int[] array, int offset, int length)
{
super (array.length, length, offset, 0);
this.backing_buffer = array;
readOnly = false;
}
public IntBufferImpl(IntBufferImpl copy)
{
super (copy.capacity (), copy.limit (), copy.position (), 0);
backing_buffer = copy.backing_buffer;
readOnly = copy.isReadOnly ();
}
public boolean isReadOnly()
public boolean isReadOnly ()
{
return readOnly;
}
public IntBuffer slice()
public IntBuffer slice ()
{
return new IntBufferImpl (this);
return new IntBufferImpl (backing_buffer, array_offset + position (), remaining (), remaining (), 0, -1, isReadOnly ());
}
public IntBuffer duplicate()
public IntBuffer duplicate ()
{
return new IntBufferImpl(this);
return new IntBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, isReadOnly ());
}
public IntBuffer asReadOnlyBuffer()
public IntBuffer asReadOnlyBuffer ()
{
IntBufferImpl result = new IntBufferImpl (this);
result.readOnly = true;
return result;
return new IntBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, true);
}
public IntBuffer compact()
public IntBuffer compact ()
{
int copied = 0;
while (remaining () > 0)
{
put (copied, get ());
copied++;
}
position (copied);
return this;
}
public boolean isDirect()
public boolean isDirect ()
{
return false;
}
final public int get()
/**
* Relative get method. Reads the next <code>int</code> from the buffer.
*/
final public int get ()
{
int e = backing_buffer[position()];
position(position()+1);
return e;
int result = backing_buffer [position ()];
position (position () + 1);
return result;
}
final public IntBuffer put(int b)
/**
* Relative put method. Writes <code>value</code> to the next position
* in the buffer.
*
* @exception ReadOnlyBufferException If this buffer is read-only.
*/
final public IntBuffer put (int value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
backing_buffer[position()] = b;
position(position()+1);
backing_buffer [position ()] = value;
position (position () + 1);
return this;
}
final public int get(int index)
/**
* Absolute get method. Reads the <code>int</code> at position
* <code>index</code>.
*
* @exception IndexOutOfBoundsException If index is negative or not smaller
* than the buffer's limit.
*/
final public int get (int index)
{
return backing_buffer[index];
return backing_buffer [index];
}
final public IntBuffer put(int index, int b)
/**
* Absolute put method. Writes <code>value</value> to position
* <code>index</code> in the buffer.
*
* @exception IndexOutOfBoundsException If index is negative or not smaller
* than the buffer's limit.
* @exception ReadOnlyBufferException If this buffer is read-only.
*/
final public IntBuffer put (int index, int value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
backing_buffer[index] = b;
backing_buffer [index] = value;
return this;
}
final public ByteOrder order ()
{
return ByteOrder.BIG_ENDIAN;
return ByteOrder.nativeOrder ();
}
}

View file

@ -1,5 +1,5 @@
/* LongBufferImpl.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.java.nio;
import java.nio.ByteBuffer;
@ -49,92 +50,113 @@ public final class LongBufferImpl extends LongBuffer
{
private boolean readOnly;
public LongBufferImpl(int cap, int off, int lim)
LongBufferImpl (int capacity)
{
super (cap, lim, off, 0);
this.backing_buffer = new long[cap];
readOnly = false;
this (new long [capacity], 0, capacity, capacity, 0, -1, false);
}
public LongBufferImpl(long[] array, int offset, int length)
LongBufferImpl (long[] buffer, int offset, int capacity, int limit, int position, int mark, boolean readOnly)
{
super (array.length, length, offset, 0);
this.backing_buffer = array;
readOnly = false;
super (buffer, offset, capacity, limit, position, mark);
this.readOnly = readOnly;
}
public LongBufferImpl(LongBufferImpl copy)
{
super (copy.capacity (), copy.limit (), copy.position (), 0);
backing_buffer = copy.backing_buffer;
readOnly = copy.isReadOnly ();
}
public boolean isReadOnly()
public boolean isReadOnly ()
{
return readOnly;
}
public LongBuffer slice()
public LongBuffer slice ()
{
return new LongBufferImpl (this);
return new LongBufferImpl (backing_buffer, array_offset + position (), remaining (), remaining (), 0, -1, isReadOnly ());
}
public LongBuffer duplicate()
public LongBuffer duplicate ()
{
return new LongBufferImpl(this);
return new LongBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, isReadOnly ());
}
public LongBuffer asReadOnlyBuffer()
public LongBuffer asReadOnlyBuffer ()
{
LongBufferImpl result = new LongBufferImpl (this);
result.readOnly = true;
return result;
return new LongBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, true);
}
public LongBuffer compact()
public LongBuffer compact ()
{
int copied = 0;
while (remaining () > 0)
{
put (copied, get ());
copied++;
}
position (copied);
return this;
}
public boolean isDirect()
public boolean isDirect ()
{
return false;
}
final public long get()
/**
* Relative get method. Reads the next <code>long</code> from the buffer.
*/
final public long get ()
{
long e = backing_buffer[position()];
position(position()+1);
return e;
long result = backing_buffer [position ()];
position (position () + 1);
return result;
}
final public LongBuffer put(long b)
/**
* Relative put method. Writes <code>value</code> to the next position
* in the buffer.
*
* @exception ReadOnlyBufferException If this buffer is read-only.
*/
final public LongBuffer put (long value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
backing_buffer[position()] = b;
position(position()+1);
backing_buffer [position ()] = value;
position (position () + 1);
return this;
}
final public long get(int index)
/**
* Absolute get method. Reads the <code>long</code> at position
* <code>index</code>.
*
* @exception IndexOutOfBoundsException If index is negative or not smaller
* than the buffer's limit.
*/
final public long get (int index)
{
return backing_buffer[index];
return backing_buffer [index];
}
final public LongBuffer put(int index, long b)
/**
* Absolute put method. Writes <code>value</value> to position
* <code>index</code> in the buffer.
*
* @exception IndexOutOfBoundsException If index is negative or not smaller
* than the buffer's limit.
* @exception ReadOnlyBufferException If this buffer is read-only.
*/
final public LongBuffer put (int index, long value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
backing_buffer[index] = b;
backing_buffer [index] = value;
return this;
}
final public ByteOrder order ()
{
return ByteOrder.BIG_ENDIAN;
return ByteOrder.nativeOrder ();
}
}

View file

@ -1,5 +1,5 @@
/* ShortBufferImpl.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.java.nio;
import java.nio.ByteBuffer;
@ -49,92 +50,113 @@ public final class ShortBufferImpl extends ShortBuffer
{
private boolean readOnly;
public ShortBufferImpl(int cap, int off, int lim)
ShortBufferImpl (int capacity)
{
super (cap, lim, off, 0);
this.backing_buffer = new short [cap];
readOnly = false;
this (new short [capacity], 0, capacity, capacity, 0, -1, false);
}
public ShortBufferImpl(short[] array, int offset, int length)
ShortBufferImpl (short[] buffer, int offset, int capacity, int limit, int position, int mark, boolean readOnly)
{
super (array.length, length, offset, 0);
this.backing_buffer = array;
readOnly = false;
super (buffer, offset, capacity, limit, position, mark);
this.readOnly = readOnly;
}
public ShortBufferImpl(ShortBufferImpl copy)
{
super (copy.capacity (), copy.limit (), copy.position (), 0);
backing_buffer = copy.backing_buffer;
readOnly = copy.isReadOnly ();
}
public boolean isReadOnly()
public boolean isReadOnly ()
{
return readOnly;
}
public ShortBuffer slice()
public ShortBuffer slice ()
{
return new ShortBufferImpl (this);
return new ShortBufferImpl (backing_buffer, array_offset + position (), remaining (), remaining (), 0, -1, isReadOnly ());
}
public ShortBuffer duplicate()
public ShortBuffer duplicate ()
{
return new ShortBufferImpl(this);
return new ShortBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, isReadOnly ());
}
public ShortBuffer asReadOnlyBuffer()
public ShortBuffer asReadOnlyBuffer ()
{
ShortBufferImpl result = new ShortBufferImpl (this);
result.readOnly = true;
return result;
return new ShortBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, true);
}
public ShortBuffer compact()
public ShortBuffer compact ()
{
int copied = 0;
while (remaining () > 0)
{
put (copied, get ());
copied++;
}
position (copied);
return this;
}
public boolean isDirect()
public boolean isDirect ()
{
return false;
}
final public short get()
/**
* Relative get method. Reads the next <code>short</code> from the buffer.
*/
final public short get ()
{
short e = backing_buffer[position()];
position(position()+1);
return e;
short result = backing_buffer [position ()];
position (position () + 1);
return result;
}
final public ShortBuffer put(short b)
/**
* Relative put method. Writes <code>value</code> to the next position
* in the buffer.
*
* @exception ReadOnlyBufferException If this buffer is read-only.
*/
final public ShortBuffer put (short value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
backing_buffer[position()] = b;
position(position()+1);
backing_buffer [position ()] = value;
position (position () + 1);
return this;
}
final public short get(int index)
/**
* Absolute get method. Reads the <code>short</code> at position
* <code>index</code>.
*
* @exception IndexOutOfBoundsException If index is negative or not smaller
* than the buffer's limit.
*/
final public short get (int index)
{
return backing_buffer[index];
return backing_buffer [index];
}
final public ShortBuffer put(int index, short b)
/**
* Absolute put method. Writes <code>value</value> to position
* <code>index</code> in the buffer.
*
* @exception IndexOutOfBoundsException If index is negative or not smaller
* than the buffer's limit.
* @exception ReadOnlyBufferException If this buffer is read-only.
*/
final public ShortBuffer put (int index, short value)
{
if (readOnly)
throw new ReadOnlyBufferException ();
backing_buffer[index] = b;
backing_buffer [index] = value;
return this;
}
final public ByteOrder order ()
{
return ByteOrder.BIG_ENDIAN;
return ByteOrder.nativeOrder ();
}
}

View file

@ -1,82 +0,0 @@
// natByteBufferImpl.cc
/* Copyright (C) 2002, 2003 Free Software Foundation
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
#include <config.h>
#include <gcj/cni.h>
#include <jvm.h>
#include <gnu/java/nio/ByteBufferImpl.h>
void
gnu::java::nio::ByteBufferImpl::nio_put_Char(gnu::java::nio::ByteBufferImpl*, jint, jint, jchar)
{
}
void
gnu::java::nio::ByteBufferImpl::nio_put_Short(gnu::java::nio::ByteBufferImpl*, jint, jint, jshort)
{
}
void
gnu::java::nio::ByteBufferImpl::nio_put_Int(gnu::java::nio::ByteBufferImpl*, jint, jint, jint)
{
}
void
gnu::java::nio::ByteBufferImpl::nio_put_Long(gnu::java::nio::ByteBufferImpl*, jint, jint, jlong)
{
}
void
gnu::java::nio::ByteBufferImpl::nio_put_Float(gnu::java::nio::ByteBufferImpl*, jint, jint, jfloat)
{
}
void
gnu::java::nio::ByteBufferImpl::nio_put_Double(gnu::java::nio::ByteBufferImpl*, jint, jint, jdouble)
{
}
jchar
gnu::java::nio::ByteBufferImpl::nio_get_Char(gnu::java::nio::ByteBufferImpl*, jint, jint)
{
return ' ';
}
jshort
gnu::java::nio::ByteBufferImpl::nio_get_Short(gnu::java::nio::ByteBufferImpl*, jint, jint)
{
return 0;
}
jint
gnu::java::nio::ByteBufferImpl::nio_get_Int(gnu::java::nio::ByteBufferImpl*, jint, jint)
{
return 0;
}
jlong
gnu::java::nio::ByteBufferImpl::nio_get_Long(gnu::java::nio::ByteBufferImpl*, jint, jint)
{
return 0;
}
jfloat
gnu::java::nio::ByteBufferImpl::nio_get_Float(gnu::java::nio::ByteBufferImpl*, jint, jint)
{
return 0.0;
}
jdouble
gnu::java::nio::ByteBufferImpl::nio_get_Double(gnu::java::nio::ByteBufferImpl*, jint, jint)
{
return 0.0;
}

View file

@ -1,22 +0,0 @@
// natCharBufferImpl.cc
/* Copyright (C) 2002, 2003 Free Software Foundation
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
#include <config.h>
#include <gcj/cni.h>
#include <jvm.h>
#include <gnu/java/nio/CharBufferImpl.h>
JArray<jchar>*
gnu::java::nio::CharBufferImpl::nio_cast(JArray<jbyte>*)
{
return NULL;
}