summaryrefslogtreecommitdiff
path: root/java/nio/FloatBufferImpl.java
diff options
context:
space:
mode:
authorDalibor Topic <robilad@yahoo.com>2004-06-16 08:57:10 +0000
committerDalibor Topic <robilad@yahoo.com>2004-06-16 08:57:10 +0000
commit891026f13064972d24e015b77304a63514a69a5e (patch)
tree9c50f2517b987ac7b3c9c4fb793f2fb7d2e00e6f /java/nio/FloatBufferImpl.java
parentcbcddf051550f73562cef616d1568685c8f155a4 (diff)
downloadclasspath-891026f13064972d24e015b77304a63514a69a5e.tar.gz
Improved nio error checking
2003-06-15 Dalibor Topic <robilad@kaffe.org> * 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.
Diffstat (limited to 'java/nio/FloatBufferImpl.java')
-rw-r--r--java/nio/FloatBufferImpl.java26
1 files changed, 18 insertions, 8 deletions
diff --git a/java/nio/FloatBufferImpl.java b/java/nio/FloatBufferImpl.java
index 47479845d..a9eb7c1de 100644
--- a/java/nio/FloatBufferImpl.java
+++ b/java/nio/FloatBufferImpl.java
@@ -1,5 +1,5 @@
/* FloatBufferImpl.java --
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -98,10 +98,16 @@ final class FloatBufferImpl extends FloatBuffer
}
/**
- * Relative get method. Reads the next <code>float</code> from the buffer.
+ * Reads the <code>float</code> at this buffer's current position,
+ * and then increments the position.
+ *
+ * @exception BufferUnderflowException If there are no remaining
+ * <code>floats</code> in this buffer.
*/
public float get ()
{
+ checkForUnderflow();
+
float result = backing_buffer [position ()];
position (position () + 1);
return result;
@@ -111,13 +117,15 @@ final class FloatBufferImpl extends FloatBuffer
* Relative put method. Writes <code>value</code> to the next position
* in the buffer.
*
+ * @exception BufferOverflowException If there no remaining
+ * space in this buffer.
* @exception ReadOnlyBufferException If this buffer is read-only.
*/
public FloatBuffer put (float value)
{
- if (readOnly)
- throw new ReadOnlyBufferException ();
-
+ checkIfReadOnly();
+ checkForOverflow();
+
backing_buffer [position ()] = value;
position (position () + 1);
return this;
@@ -132,6 +140,8 @@ final class FloatBufferImpl extends FloatBuffer
*/
public float get (int index)
{
+ checkIndex(index);
+
return backing_buffer [index];
}
@@ -145,9 +155,9 @@ final class FloatBufferImpl extends FloatBuffer
*/
public FloatBuffer put (int index, float value)
{
- if (readOnly)
- throw new ReadOnlyBufferException ();
-
+ checkIfReadOnly();
+ checkIndex(index);
+
backing_buffer [index] = value;
return this;
}