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:
parent
d3e0dffb76
commit
36d4669b73
19 changed files with 2056 additions and 976 deletions
|
@ -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 ();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue