From 23c41c08339da4bdf677ade01e17d940b7ce6201 Mon Sep 17 00:00:00 2001 From: Dalibor Topic Date: Fri, 9 Jul 2004 13:40:29 +0000 Subject: Buffer.java, [...]: Fixed javadocs all over. 2004-07-09 Dalibor Topic * java/nio/Buffer.java, java/nio/ByteBuffer.java, java/nio/ByteBufferHelper.java, java/nio/ByteBufferImpl.java, java/nio/CharBuffer.java, java/nio/CharBufferImpl.java, java/nio/CharViewBufferImpl.java, java/nio/DirectByteBufferImpl.java, java/nio/DoubleBuffer.java, java/nio/DoubleBufferImpl.java, java/nio/DoubleViewBufferImpl.java, java/nio/FloatBuffer.java, java/nio/FloatBufferImpl.java, java/nio/FloatViewBufferImpl.java, java/nio/IntBuffer.java, java/nio/IntBufferImpl.java, java/nio/IntViewBufferImpl.java, java/nio/LongBuffer.java, java/nio/LongBufferImpl.java, java/nio/LongViewBufferImpl.java, java/nio/MappedByteBufferImpl.java, java/nio/ShortBuffer.java, java/nio/ShortBufferImpl.java, java/nio/ShortViewBufferImpl.java: Fixed javadocs all over. Improved input error checking. * java/nio/Buffer.java (checkForUnderflow, checkForOverflow, checkIndex, checkIfReadOnly, checkArraySize): New helper methods for error checking. * java/nio/ByteBufferHelper.java (checkRemainingForRead, checkRemainingForWrite, checkAvailableForRead, checkAvailableForWrite): Removed no longer needed methods. From-SVN: r84366 --- libjava/java/nio/ByteBufferImpl.java | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'libjava/java/nio/ByteBufferImpl.java') diff --git a/libjava/java/nio/ByteBufferImpl.java b/libjava/java/nio/ByteBufferImpl.java index f79ae630acb..7734dbf12cd 100644 --- a/libjava/java/nio/ByteBufferImpl.java +++ b/libjava/java/nio/ByteBufferImpl.java @@ -129,10 +129,16 @@ final class ByteBufferImpl extends ByteBuffer } /** - * Relative get method. Reads the next byte from the buffer. + * Reads the byte at this buffer's current position, + * and then increments the position. + * + * @exception BufferUnderflowException If there are no remaining + * bytes in this buffer. */ public byte get () { + checkForUnderflow(); + byte result = backing_buffer [position () + array_offset]; position (position () + 1); return result; @@ -141,13 +147,15 @@ final class ByteBufferImpl extends ByteBuffer /** * Relative put method. Writes value to the next position * in the buffer. - * + * + * @exception BufferOverflowException If there is no remaining + * space in this buffer. * @exception ReadOnlyBufferException If this buffer is read-only. */ public ByteBuffer put (byte value) { - if (readOnly) - throw new ReadOnlyBufferException (); + checkIfReadOnly(); + checkForOverflow(); int pos = position(); backing_buffer [pos + array_offset] = value; @@ -164,6 +172,8 @@ final class ByteBufferImpl extends ByteBuffer */ public byte get (int index) { + checkIndex(index); + return backing_buffer [index + array_offset]; } @@ -177,9 +187,9 @@ final class ByteBufferImpl extends ByteBuffer */ public ByteBuffer put (int index, byte value) { - if (readOnly) - throw new ReadOnlyBufferException (); - + checkIfReadOnly(); + checkIndex(index); + backing_buffer [index + array_offset] = value; return this; } -- cgit v1.2.3