From 3b6b673dabbab53b8e57cc7ad533f336841356f5 Mon Sep 17 00:00:00 2001 From: Michael Koch Date: Tue, 13 May 2003 06:04:19 +0000 Subject: 2003-05-13 Michael Koch * gnu/java/nio/ByteBufferImpl.java (ByteBufferImpl): All constructors revised. (slice): Reimplemented. (duplicate): Reimplemented. (asReadOnlyBuffer): Reimplemented. * java/nio/ByteBuffer.java: Reformatted. (array_offset): Renamed from "offset" to match all other buffer classes. (ByteBuffer): All constructors revised. (allocateDirect): Implemented. (allocate): New implementation, documentation reworked. (wrap): Likewise. (get): Documentation reworked. (put): New implementation, documentation reworked. (hasArray): Documentation reworked. (arrayOffset): Likewise. (hashCode): Likewise. (equals): Likewise. (compareTo): Likewise. (order): Likewise. (compact): Likewise. (isDirect): Likewise. (slice): Likewise. (duplicate): Likewise. (asReadOnlyBuffer): Likewise. * Makefile.am (ordinary_java_source_files): Added gnu/java/nio/DirectByteBufferImpl.java. (nat_source_files): Added gnu/java/nio/natDirectByteBufferImpl.cc. * Makefile.in: Regenerated. From-SVN: r66749 --- libjava/gnu/java/nio/ByteBufferImpl.java | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'libjava/gnu') diff --git a/libjava/gnu/java/nio/ByteBufferImpl.java b/libjava/gnu/java/nio/ByteBufferImpl.java index 7b7f72e..cc7fabb 100644 --- a/libjava/gnu/java/nio/ByteBufferImpl.java +++ b/libjava/gnu/java/nio/ByteBufferImpl.java @@ -53,19 +53,16 @@ import java.nio.ShortBuffer; public final class ByteBufferImpl extends ByteBuffer { private boolean readOnly; - - public ByteBufferImpl (int cap, int off, int lim) + + ByteBufferImpl (int capacity) { - super (cap, lim, off, 0); - this.backing_buffer = new byte [cap]; - readOnly = false; + this (new byte [capacity], 0, capacity, capacity, 0, -1, false); } - - public ByteBufferImpl (byte[] array, int offset, int length) + + ByteBufferImpl (byte[] 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 ByteBufferImpl (ByteBufferImpl copy) @@ -117,19 +114,17 @@ public final class ByteBufferImpl extends ByteBuffer public ByteBuffer slice () { - return new ByteBufferImpl (this); + return new ByteBufferImpl (backing_buffer, array_offset + position (), remaining (), remaining (), 0, -1, isReadOnly ()); } public ByteBuffer duplicate () { - return new ByteBufferImpl (this); + return new ByteBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, isReadOnly ()); } public ByteBuffer asReadOnlyBuffer () { - ByteBufferImpl a = new ByteBufferImpl (this); - a.readOnly = true; - return a; + return new ByteBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, true); } public ByteBuffer compact () -- cgit v1.1