diff options
Diffstat (limited to 'libjava/java/nio/ByteBufferImpl.java')
-rw-r--r-- | libjava/java/nio/ByteBufferImpl.java | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/libjava/java/nio/ByteBufferImpl.java b/libjava/java/nio/ByteBufferImpl.java index f79ae63..7734dbf 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 <code>byte</code> from the buffer. + * Reads the <code>byte</code> at this buffer's current position, + * and then increments the position. + * + * @exception BufferUnderflowException If there are no remaining + * <code>bytes</code> 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 <code>value</code> 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; } |