aboutsummaryrefslogtreecommitdiff
path: root/libjava/gnu/java/nio/CharBufferImpl.java
diff options
context:
space:
mode:
authorMichael Koch <konqueror@gmx.de>2003-05-12 20:45:20 +0000
committerMichael Koch <mkoch@gcc.gnu.org>2003-05-12 20:45:20 +0000
commit36d4669b735c0e6f665e9a83bdd0848e23fc6662 (patch)
treeeba2e2a8271971b25fa39af84cbebe056dd27e91 /libjava/gnu/java/nio/CharBufferImpl.java
parentd3e0dffb76fd85d777f5c5de71f47816121bc5e3 (diff)
downloadgcc-36d4669b735c0e6f665e9a83bdd0848e23fc6662.zip
gcc-36d4669b735c0e6f665e9a83bdd0848e23fc6662.tar.gz
gcc-36d4669b735c0e6f665e9a83bdd0848e23fc6662.tar.bz2
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
Diffstat (limited to 'libjava/gnu/java/nio/CharBufferImpl.java')
-rw-r--r--libjava/gnu/java/nio/CharBufferImpl.java93
1 files changed, 46 insertions, 47 deletions
diff --git a/libjava/gnu/java/nio/CharBufferImpl.java b/libjava/gnu/java/nio/CharBufferImpl.java
index ca76974..fcf0e15 100644
--- a/libjava/gnu/java/nio/CharBufferImpl.java
+++ b/libjava/gnu/java/nio/CharBufferImpl.java
@@ -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 ();
}
}