Buffer.java, [...]: Fixed javadocs all over.
2004-07-09 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. From-SVN: r84366
This commit is contained in:
committed by
Michael Koch
parent
e484d7d5b3
commit
23c41c0833
@@ -42,32 +42,6 @@ package java.nio;
|
||||
*/
|
||||
final class ByteBufferHelper
|
||||
{
|
||||
private static void checkRemainingForRead (ByteBuffer buffer, int bytes)
|
||||
{
|
||||
if (buffer.remaining() < bytes)
|
||||
throw new BufferUnderflowException();
|
||||
}
|
||||
|
||||
private static void checkRemainingForWrite (ByteBuffer buffer, int bytes)
|
||||
{
|
||||
if (buffer.remaining() < bytes)
|
||||
throw new BufferOverflowException();
|
||||
}
|
||||
|
||||
private static void checkAvailableForRead (ByteBuffer buffer,
|
||||
int index, int bytes)
|
||||
{
|
||||
if (buffer.limit() < (index + bytes))
|
||||
throw new BufferUnderflowException();
|
||||
}
|
||||
|
||||
private static void checkAvailableForWrite (ByteBuffer buffer,
|
||||
int index, int bytes)
|
||||
{
|
||||
if (buffer.limit() < (index + bytes))
|
||||
throw new BufferOverflowException();
|
||||
}
|
||||
|
||||
public static char getChar (ByteBuffer buffer, ByteOrder order)
|
||||
{
|
||||
return (char) getShort (buffer, order);
|
||||
@@ -91,7 +65,7 @@ final class ByteBufferHelper
|
||||
|
||||
public static short getShort (ByteBuffer buffer, ByteOrder order)
|
||||
{
|
||||
checkRemainingForRead (buffer, 2);
|
||||
buffer.checkForUnderflow(2);
|
||||
|
||||
if (order == ByteOrder.LITTLE_ENDIAN)
|
||||
{
|
||||
@@ -105,7 +79,7 @@ final class ByteBufferHelper
|
||||
|
||||
public static void putShort (ByteBuffer buffer, short value, ByteOrder order)
|
||||
{
|
||||
checkRemainingForWrite (buffer, 2);
|
||||
buffer.checkForOverflow(2);
|
||||
|
||||
if (order == ByteOrder.LITTLE_ENDIAN)
|
||||
{
|
||||
@@ -122,8 +96,6 @@ final class ByteBufferHelper
|
||||
public static short getShort (ByteBuffer buffer,
|
||||
int index, ByteOrder order)
|
||||
{
|
||||
checkAvailableForRead (buffer, index, 2);
|
||||
|
||||
if (order == ByteOrder.LITTLE_ENDIAN)
|
||||
{
|
||||
return (short) ((buffer.get (index) & 0xff)
|
||||
@@ -137,8 +109,6 @@ final class ByteBufferHelper
|
||||
public static void putShort (ByteBuffer buffer, int index,
|
||||
short value, ByteOrder order)
|
||||
{
|
||||
checkAvailableForWrite (buffer, index, 2);
|
||||
|
||||
if (order == ByteOrder.LITTLE_ENDIAN)
|
||||
{
|
||||
buffer.put (index, (byte) value);
|
||||
@@ -153,7 +123,7 @@ final class ByteBufferHelper
|
||||
|
||||
public static int getInt (ByteBuffer buffer, ByteOrder order)
|
||||
{
|
||||
checkRemainingForRead (buffer, 4);
|
||||
buffer.checkForUnderflow(4);
|
||||
|
||||
if (order == ByteOrder.LITTLE_ENDIAN)
|
||||
{
|
||||
@@ -171,7 +141,7 @@ final class ByteBufferHelper
|
||||
|
||||
public static void putInt (ByteBuffer buffer, int value, ByteOrder order)
|
||||
{
|
||||
checkRemainingForWrite (buffer, 4);
|
||||
buffer.checkForOverflow(4);
|
||||
|
||||
if (order == ByteOrder.LITTLE_ENDIAN)
|
||||
{
|
||||
@@ -191,8 +161,6 @@ final class ByteBufferHelper
|
||||
|
||||
public static int getInt (ByteBuffer buffer, int index, ByteOrder order)
|
||||
{
|
||||
checkAvailableForRead (buffer, index, 4);
|
||||
|
||||
if (order == ByteOrder.LITTLE_ENDIAN)
|
||||
{
|
||||
return ((buffer.get (index) & 0xff)
|
||||
@@ -210,8 +178,6 @@ final class ByteBufferHelper
|
||||
public static void putInt (ByteBuffer buffer, int index,
|
||||
int value, ByteOrder order)
|
||||
{
|
||||
checkAvailableForWrite (buffer, index, 4);
|
||||
|
||||
if (order == ByteOrder.LITTLE_ENDIAN)
|
||||
{
|
||||
buffer.put (index, (byte) value);
|
||||
@@ -230,7 +196,7 @@ final class ByteBufferHelper
|
||||
|
||||
public static long getLong (ByteBuffer buffer, ByteOrder order)
|
||||
{
|
||||
checkRemainingForRead (buffer, 8);
|
||||
buffer.checkForUnderflow(8);
|
||||
|
||||
if (order == ByteOrder.LITTLE_ENDIAN)
|
||||
{
|
||||
@@ -256,7 +222,7 @@ final class ByteBufferHelper
|
||||
|
||||
public static void putLong (ByteBuffer buffer, long value, ByteOrder order)
|
||||
{
|
||||
checkRemainingForWrite (buffer, 8);
|
||||
buffer.checkForOverflow(8);
|
||||
|
||||
if (order == ByteOrder.LITTLE_ENDIAN)
|
||||
{
|
||||
@@ -284,8 +250,6 @@ final class ByteBufferHelper
|
||||
|
||||
public static long getLong (ByteBuffer buffer, int index, ByteOrder order)
|
||||
{
|
||||
checkAvailableForRead (buffer, index, 8);
|
||||
|
||||
if (order == ByteOrder.LITTLE_ENDIAN)
|
||||
{
|
||||
return ((buffer.get (index) & 0xff)
|
||||
@@ -311,8 +275,6 @@ final class ByteBufferHelper
|
||||
public static void putLong (ByteBuffer buffer, int index,
|
||||
long value, ByteOrder order)
|
||||
{
|
||||
checkAvailableForWrite (buffer, index, 8);
|
||||
|
||||
if (order == ByteOrder.LITTLE_ENDIAN)
|
||||
{
|
||||
buffer.put (index, (byte) value);
|
||||
|
||||
Reference in New Issue
Block a user