2002-10-07 15:12:42 +02:00
|
|
|
/* ByteBuffer.java --
|
2003-05-13 08:04:19 +02:00
|
|
|
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
2002-10-07 15:12:42 +02:00
|
|
|
|
|
|
|
This file is part of GNU Classpath.
|
|
|
|
|
|
|
|
GNU Classpath is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
GNU Classpath is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with GNU Classpath; see the file COPYING. If not, write to the
|
|
|
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
|
|
02111-1307 USA.
|
|
|
|
|
|
|
|
Linking this library statically or dynamically with other modules is
|
|
|
|
making a combined work based on this library. Thus, the terms and
|
|
|
|
conditions of the GNU General Public License cover the whole
|
|
|
|
combination.
|
|
|
|
|
|
|
|
As a special exception, the copyright holders of this library give you
|
|
|
|
permission to link this library with independent modules to produce an
|
|
|
|
executable, regardless of the license terms of these independent
|
|
|
|
modules, and to copy and distribute the resulting executable under
|
|
|
|
terms of your choice, provided that you also meet, for each linked
|
|
|
|
independent module, the terms and conditions of the license of that
|
|
|
|
module. An independent module is a module which is not derived from
|
|
|
|
or based on this library. If you modify this library, you may extend
|
|
|
|
this exception to your version of the library, but you are not
|
|
|
|
obligated to do so. If you do not wish to do so, delete this
|
|
|
|
exception statement from your version. */
|
|
|
|
|
|
|
|
|
ByteBufferImpl.java, [...]: Moved files to java/nio.
2003-05-20 Michael Koch <konqueror@gmx.de>
* gnu/java/nio/ByteBufferImpl.java,
gnu/java/nio/CharBufferImpl.java,
gnu/java/nio/CharViewBufferImpl.java,
gnu/java/nio/DirectByteBufferImpl.java,
gnu/java/nio/DoubleBufferImpl.java,
gnu/java/nio/DoubleViewBufferImpl.java,
gnu/java/nio/FloatBufferImpl.java,
gnu/java/nio/FloatViewBufferImpl.java,
gnu/java/nio/IntBufferImpl.java,
gnu/java/nio/IntViewBufferImpl.java,
gnu/java/nio/LongBufferImpl.java,
gnu/java/nio/LongViewBufferImpl.java,
gnu/java/nio/natDirectByteBufferImpl.cc,
gnu/java/nio/ShortBufferImpl.java,
gnu/java/nio/ShortViewBufferImpl.java:
Moved files to java/nio.
* gnu/java/nio/SocketChannelImpl.java
* java/nio/ByteBuffer.java,
java/nio/CharBuffer.java,
java/nio/DoubleBuffer.java,
java/nio/FloatBuffer.java,
java/nio/IntBuffer.java,
java/nio/LongBuffer.java,
java/nio/ShortBuffer.java:
Dont import anything.
* java/nio/ByteBufferImpl.java,
java/nio/CharBufferImpl.java,
java/nio/CharViewBufferImpl.java,
java/nio/DirectByteBufferImpl.java,
java/nio/DoubleBufferImpl.java,
java/nio/DoubleViewBufferImpl.java,
java/nio/FloatBufferImpl.java,
java/nio/FloatViewBufferImpl.java,
java/nio/IntBufferImpl.java,
java/nio/IntViewBufferImpl.java,
java/nio/LongBufferImpl.java,
java/nio/LongViewBufferImpl.java,
java/nio/natDirectByteBufferImpl.cc,
java/nio/ShortBufferImpl.java,
java/nio/ShortViewBufferImpl.java:
Moved from gnu/java/nio.
* Makefile.am
(ordinary_java_source_files): Moved files from gnu/java/nio to
java/nio.
(nat_source_files): Moved natDirectByteBufferImpl.cc from gnu/java/nio
to java/nio.
* Makefile.in: Regenerated.
From-SVN: r66990
2003-05-20 10:58:31 +02:00
|
|
|
package java.nio;
|
2003-02-12 09:01:10 +01:00
|
|
|
|
2003-02-11 08:42:17 +01:00
|
|
|
/**
|
|
|
|
* @since 1.4
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract class ByteBuffer extends Buffer
|
|
|
|
implements Comparable
|
2002-10-07 15:12:42 +02:00
|
|
|
{
|
2003-02-13 12:37:10 +01:00
|
|
|
private ByteOrder endian = ByteOrder.BIG_ENDIAN;
|
|
|
|
|
2003-05-13 08:04:19 +02:00
|
|
|
int array_offset;
|
2003-02-11 08:42:17 +01:00
|
|
|
byte[] backing_buffer;
|
2003-05-13 08:04:19 +02:00
|
|
|
|
|
|
|
ByteBuffer (int capacity, int limit, int position, int mark)
|
|
|
|
{
|
|
|
|
super (capacity, limit, position, mark);
|
|
|
|
array_offset = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ByteBuffer (byte[] buffer, int offset, int capacity, int limit, int position, int mark)
|
|
|
|
{
|
|
|
|
super (capacity, limit, position, mark);
|
|
|
|
this.backing_buffer = buffer;
|
|
|
|
this.array_offset = offset;
|
|
|
|
}
|
2003-05-19 08:59:23 +02:00
|
|
|
|
2003-02-11 08:42:17 +01:00
|
|
|
/**
|
|
|
|
* Allocates a new direct byte buffer.
|
|
|
|
*/
|
|
|
|
public static ByteBuffer allocateDirect (int capacity)
|
|
|
|
{
|
2003-05-13 08:04:19 +02:00
|
|
|
return DirectByteBufferImpl.allocate (capacity);
|
2003-02-11 08:42:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2003-05-13 08:04:19 +02:00
|
|
|
* Allocates a new <code>ByteBuffer</code> object with a given capacity.
|
2003-02-11 08:42:17 +01:00
|
|
|
*/
|
2002-11-13 19:43:20 +01:00
|
|
|
public static ByteBuffer allocate (int capacity)
|
|
|
|
{
|
2003-05-13 08:04:19 +02:00
|
|
|
return new ByteBufferImpl (capacity);
|
2002-11-13 19:43:20 +01:00
|
|
|
}
|
2003-05-13 08:04:19 +02:00
|
|
|
|
2003-02-11 08:42:17 +01:00
|
|
|
/**
|
2003-05-13 08:04:19 +02:00
|
|
|
* Wraps a <code>byte</code> array into a <code>ByteBuffer</code>
|
|
|
|
* object.
|
|
|
|
*
|
2003-02-11 08:42:17 +01:00
|
|
|
* @exception IndexOutOfBoundsException If the preconditions on the offset
|
|
|
|
* and length parameters do not hold
|
|
|
|
*/
|
2002-11-13 19:43:20 +01:00
|
|
|
final public static ByteBuffer wrap (byte[] array, int offset, int length)
|
|
|
|
{
|
2003-05-13 08:04:19 +02:00
|
|
|
return new ByteBufferImpl (array, 0, array.length, offset + length, offset, -1, false);
|
2002-11-13 19:43:20 +01:00
|
|
|
}
|
|
|
|
|
2003-02-11 08:42:17 +01:00
|
|
|
/**
|
2003-05-13 08:04:19 +02:00
|
|
|
* Wraps a <code>byte</code> array into a <code>ByteBuffer</code>
|
|
|
|
* object.
|
2003-02-11 08:42:17 +01:00
|
|
|
*/
|
2002-11-13 19:43:20 +01:00
|
|
|
final public static ByteBuffer wrap (byte[] array)
|
|
|
|
{
|
|
|
|
return wrap (array, 0, array.length);
|
|
|
|
}
|
2003-05-13 08:04:19 +02:00
|
|
|
|
2003-02-13 12:37:10 +01:00
|
|
|
/**
|
2003-05-13 08:04:19 +02:00
|
|
|
* This method transfers <code>bytes<code> from this buffer into the given
|
|
|
|
* destination array.
|
2003-02-13 12:37:10 +01:00
|
|
|
*
|
|
|
|
* @param dst The destination array
|
2003-05-13 08:04:19 +02:00
|
|
|
* @param offset The offset within the array of the first <code>byte</code>
|
|
|
|
* to be written; must be non-negative and no larger than dst.length.
|
2003-02-13 12:37:10 +01:00
|
|
|
* @param length The maximum number of bytes to be written to the given array;
|
|
|
|
* must be non-negative and no larger than dst.length - offset.
|
|
|
|
*
|
2003-05-13 08:04:19 +02:00
|
|
|
* @exception BufferUnderflowException If there are fewer than length
|
|
|
|
* <code>bytes</code> remaining in this buffer.
|
|
|
|
* @exception IndexOutOfBoundsException If the preconditions on the offset
|
2003-02-13 12:37:10 +01:00
|
|
|
* and length parameters do not hold.
|
|
|
|
*/
|
|
|
|
public ByteBuffer get (byte[] dst, int offset, int length)
|
|
|
|
{
|
|
|
|
if ((offset < 0)
|
|
|
|
|| (offset > dst.length)
|
|
|
|
|| (length < 0)
|
|
|
|
|| (length > (dst.length - offset)))
|
|
|
|
throw new IndexOutOfBoundsException ();
|
|
|
|
|
|
|
|
for (int i = offset; i < offset + length; i++)
|
|
|
|
{
|
2003-05-13 08:04:19 +02:00
|
|
|
dst [i] = get ();
|
2003-02-13 12:37:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2003-05-13 08:04:19 +02:00
|
|
|
* This method transfers <code>bytes<code> from this buffer into the given
|
2003-02-13 12:37:10 +01:00
|
|
|
* destination array.
|
|
|
|
*
|
|
|
|
* @param dst The byte array to write into.
|
|
|
|
*
|
|
|
|
* @exception BufferUnderflowException If there are fewer than dst.length
|
2003-05-13 08:04:19 +02:00
|
|
|
* <code>bytes</code> remaining in this buffer.
|
2003-02-13 12:37:10 +01:00
|
|
|
*/
|
|
|
|
public ByteBuffer get (byte[] dst)
|
|
|
|
{
|
|
|
|
return get (dst, 0, dst.length);
|
|
|
|
}
|
2003-05-13 08:04:19 +02:00
|
|
|
|
2003-02-11 08:42:17 +01:00
|
|
|
/**
|
2003-05-13 08:04:19 +02:00
|
|
|
* Writes the content of the the <code>ByteBUFFER</code> src
|
|
|
|
* into the buffer.
|
2003-02-11 08:42:17 +01:00
|
|
|
*
|
|
|
|
* @param src The source data.
|
|
|
|
*
|
|
|
|
* @exception BufferOverflowException If there is insufficient space in this
|
2003-05-13 08:04:19 +02:00
|
|
|
* buffer for the remaining <code>bytes<code> in the source buffer.
|
2003-02-11 08:42:17 +01:00
|
|
|
* @exception IllegalArgumentException If the source buffer is this buffer.
|
2003-05-13 08:04:19 +02:00
|
|
|
* @exception ReadOnlyBufferException If this buffer is read-only.
|
2003-02-11 08:42:17 +01:00
|
|
|
*/
|
|
|
|
public ByteBuffer put (ByteBuffer src)
|
2002-11-13 19:43:20 +01:00
|
|
|
{
|
2003-02-11 08:42:17 +01:00
|
|
|
if (src == this)
|
|
|
|
throw new IllegalArgumentException ();
|
|
|
|
|
2003-05-13 08:04:19 +02:00
|
|
|
if (src.remaining () > remaining ())
|
|
|
|
throw new BufferOverflowException ();
|
|
|
|
|
|
|
|
if (src.remaining () > 0)
|
|
|
|
{
|
|
|
|
byte[] toPut = new byte [src.remaining ()];
|
|
|
|
src.get (toPut);
|
|
|
|
src.put (toPut);
|
|
|
|
}
|
|
|
|
|
2002-11-13 19:43:20 +01:00
|
|
|
return this;
|
|
|
|
}
|
2003-02-11 08:42:17 +01:00
|
|
|
|
|
|
|
/**
|
2003-05-13 08:04:19 +02:00
|
|
|
* Writes the content of the the <code>byte array</code> src
|
|
|
|
* into the buffer.
|
2003-02-11 08:42:17 +01:00
|
|
|
*
|
|
|
|
* @param src The array to copy into the buffer.
|
|
|
|
* @param offset The offset within the array of the first byte to be read;
|
|
|
|
* must be non-negative and no larger than src.length.
|
|
|
|
* @param length The number of bytes to be read from the given array;
|
|
|
|
* must be non-negative and no larger than src.length - offset.
|
2003-05-13 08:04:19 +02:00
|
|
|
*
|
2003-02-11 08:42:17 +01:00
|
|
|
* @exception BufferOverflowException If there is insufficient space in this
|
2003-05-13 08:04:19 +02:00
|
|
|
* buffer for the remaining <code>bytes<code> in the source array.
|
2003-02-11 08:42:17 +01:00
|
|
|
* @exception IndexOutOfBoundsException If the preconditions on the offset
|
2003-05-13 08:04:19 +02:00
|
|
|
* and length parameters do not hold
|
|
|
|
* @exception ReadOnlyBufferException If this buffer is read-only.
|
2003-02-11 08:42:17 +01:00
|
|
|
*/
|
|
|
|
public ByteBuffer put (byte[] src, int offset, int length)
|
2002-11-13 19:43:20 +01:00
|
|
|
{
|
2003-02-11 08:42:17 +01:00
|
|
|
if ((offset < 0) ||
|
|
|
|
(offset > src.length) ||
|
|
|
|
(length < 0) ||
|
|
|
|
(length > src.length - offset))
|
|
|
|
throw new IndexOutOfBoundsException ();
|
|
|
|
|
2002-11-13 19:43:20 +01:00
|
|
|
for (int i = offset; i < offset + length; i++)
|
|
|
|
put (src [i]);
|
2003-05-13 08:04:19 +02:00
|
|
|
|
2002-11-13 19:43:20 +01:00
|
|
|
return this;
|
|
|
|
}
|
2003-02-11 08:42:17 +01:00
|
|
|
|
|
|
|
/**
|
2003-05-13 08:04:19 +02:00
|
|
|
* Writes the content of the the <code>byte array</code> src
|
|
|
|
* into the buffer.
|
2003-02-11 08:42:17 +01:00
|
|
|
*
|
|
|
|
* @param src The array to copy into the buffer.
|
2003-05-13 08:04:19 +02:00
|
|
|
*
|
2003-02-11 08:42:17 +01:00
|
|
|
* @exception BufferOverflowException If there is insufficient space in this
|
2003-05-13 08:04:19 +02:00
|
|
|
* buffer for the remaining <code>bytes<code> in the source array.
|
|
|
|
* @exception ReadOnlyBufferException If this buffer is read-only.
|
2003-02-11 08:42:17 +01:00
|
|
|
*/
|
2002-11-13 19:43:20 +01:00
|
|
|
public final ByteBuffer put (byte[] src)
|
|
|
|
{
|
|
|
|
return put (src, 0, src.length);
|
|
|
|
}
|
|
|
|
|
2003-02-11 08:42:17 +01:00
|
|
|
/**
|
2003-05-13 08:04:19 +02:00
|
|
|
* Tells whether ot not this buffer is backed by an accessible
|
|
|
|
* <code>byte</code> array.
|
2003-02-11 08:42:17 +01:00
|
|
|
*/
|
|
|
|
public final boolean hasArray ()
|
|
|
|
{
|
|
|
|
return (backing_buffer != null
|
2003-05-13 08:04:19 +02:00
|
|
|
&& !isReadOnly ());
|
2003-02-11 08:42:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2003-05-13 08:04:19 +02:00
|
|
|
* Returns the <code>byte</code> array that backs this buffer.
|
2003-02-11 08:42:17 +01:00
|
|
|
*
|
2003-05-13 08:04:19 +02:00
|
|
|
* @exception ReadOnlyBufferException If this buffer is read-only.
|
2003-02-11 08:42:17 +01:00
|
|
|
* @exception UnsupportedOperationException If this buffer is not backed
|
|
|
|
* by an accessible array.
|
|
|
|
*/
|
|
|
|
public final byte[] array ()
|
|
|
|
{
|
|
|
|
if (backing_buffer == null)
|
|
|
|
throw new UnsupportedOperationException ();
|
|
|
|
|
2003-02-11 10:44:57 +01:00
|
|
|
if (isReadOnly ())
|
2003-02-11 08:42:17 +01:00
|
|
|
throw new ReadOnlyBufferException ();
|
2003-05-13 08:04:19 +02:00
|
|
|
|
2003-02-11 08:42:17 +01:00
|
|
|
return backing_buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2003-05-13 08:04:19 +02:00
|
|
|
* Returns the offset within this buffer's backing array of the first element.
|
2003-02-11 08:42:17 +01:00
|
|
|
*
|
2003-05-13 08:04:19 +02:00
|
|
|
* @exception ReadOnlyBufferException If this buffer is read-only.
|
2003-02-11 08:42:17 +01:00
|
|
|
* @exception UnsupportedOperationException If this buffer is not backed
|
|
|
|
* by an accessible array.
|
|
|
|
*/
|
|
|
|
public final int arrayOffset ()
|
|
|
|
{
|
|
|
|
if (backing_buffer == null)
|
|
|
|
throw new UnsupportedOperationException ();
|
|
|
|
|
2003-02-11 10:44:57 +01:00
|
|
|
if (isReadOnly ())
|
2003-02-11 08:42:17 +01:00
|
|
|
throw new ReadOnlyBufferException ();
|
2003-05-13 08:04:19 +02:00
|
|
|
|
|
|
|
return array_offset;
|
2003-02-11 08:42:17 +01:00
|
|
|
}
|
2003-05-13 08:04:19 +02:00
|
|
|
|
2003-03-11 11:30:52 +01:00
|
|
|
/**
|
2003-05-13 08:04:19 +02:00
|
|
|
* Calculates a hash code for this buffer.
|
2003-03-11 11:30:52 +01:00
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public int hashCode ()
|
2003-03-11 11:30:52 +01:00
|
|
|
{
|
2003-05-13 08:04:19 +02:00
|
|
|
// FIXME: Check what SUN calculates here.
|
|
|
|
return super.hashCode ();
|
2003-03-11 11:30:52 +01:00
|
|
|
}
|
|
|
|
|
2003-02-11 08:42:17 +01:00
|
|
|
/**
|
2003-05-13 08:04:19 +02:00
|
|
|
* Checks if this buffer is equal to obj.
|
2003-02-13 12:37:10 +01:00
|
|
|
*/
|
|
|
|
public boolean equals (Object obj)
|
|
|
|
{
|
|
|
|
if (obj != null &&
|
|
|
|
obj instanceof ByteBuffer)
|
|
|
|
{
|
|
|
|
return compareTo (obj) == 0;
|
|
|
|
}
|
2003-05-13 08:04:19 +02:00
|
|
|
|
2003-02-13 12:37:10 +01:00
|
|
|
return false;
|
|
|
|
}
|
2003-05-13 08:04:19 +02:00
|
|
|
|
2003-02-13 12:37:10 +01:00
|
|
|
/**
|
2003-05-13 08:04:19 +02:00
|
|
|
* Compares two <code>ByteBuffer</code> objects.
|
2003-02-13 12:37:10 +01:00
|
|
|
*
|
2003-05-13 08:04:19 +02:00
|
|
|
* @exception ClassCastException If obj is not an object derived from
|
|
|
|
* <code>ByteBuffer</code>.
|
2003-02-13 12:37:10 +01:00
|
|
|
*/
|
|
|
|
public int compareTo (Object obj)
|
|
|
|
{
|
|
|
|
ByteBuffer a = (ByteBuffer) obj;
|
|
|
|
|
2003-05-13 08:04:19 +02:00
|
|
|
if (a.remaining () != remaining ())
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (! hasArray () ||
|
|
|
|
! a.hasArray ())
|
2003-02-13 12:37:10 +01:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2003-05-13 08:04:19 +02:00
|
|
|
|
|
|
|
int r = remaining ();
|
2003-02-13 12:37:10 +01:00
|
|
|
int i1 = position ();
|
|
|
|
int i2 = a.position ();
|
2003-05-13 08:04:19 +02:00
|
|
|
|
2003-02-13 12:37:10 +01:00
|
|
|
for (int i = 0; i < r; i++)
|
|
|
|
{
|
|
|
|
int t = (int) (get (i1) - a.get (i2));
|
2003-05-13 08:04:19 +02:00
|
|
|
|
2003-02-13 12:37:10 +01:00
|
|
|
if (t != 0)
|
|
|
|
{
|
|
|
|
return (int) t;
|
|
|
|
}
|
|
|
|
}
|
2003-05-13 08:04:19 +02:00
|
|
|
|
2003-02-13 12:37:10 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2003-05-13 08:04:19 +02:00
|
|
|
* Returns the byte order of this buffer.
|
2003-02-13 12:37:10 +01:00
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public final ByteOrder order ()
|
2003-02-13 12:37:10 +01:00
|
|
|
{
|
|
|
|
return endian;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Modifies this buffer's byte order.
|
|
|
|
*/
|
|
|
|
public final ByteBuffer order (ByteOrder endian)
|
|
|
|
{
|
|
|
|
this.endian = endian;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2003-05-13 08:04:19 +02:00
|
|
|
* Reads the <code>byte</code> at this buffer's current position,
|
2003-02-13 12:37:10 +01:00
|
|
|
* and then increments the position.
|
|
|
|
*
|
2003-05-13 08:04:19 +02:00
|
|
|
* @exception BufferUnderflowException If there are no remaining
|
|
|
|
* <code>bytes</code> in this buffer.
|
2003-02-11 08:42:17 +01:00
|
|
|
*/
|
2002-11-13 19:43:20 +01:00
|
|
|
public abstract byte get ();
|
2003-05-13 08:04:19 +02:00
|
|
|
|
2003-02-11 08:42:17 +01:00
|
|
|
/**
|
2003-05-13 08:04:19 +02:00
|
|
|
* Writes the <code>byte</code> at this buffer's current position,
|
|
|
|
* and then increments the position.
|
2003-02-11 08:42:17 +01:00
|
|
|
*
|
2003-05-13 08:04:19 +02:00
|
|
|
* @exception BufferOverflowException If there no remaining
|
|
|
|
* <code>bytes</code> in this buffer.
|
2003-02-11 08:42:17 +01:00
|
|
|
* @exception ReadOnlyBufferException If this buffer is read-only.
|
|
|
|
*/
|
2002-11-13 19:43:20 +01:00
|
|
|
public abstract ByteBuffer put (byte b);
|
2003-05-13 08:04:19 +02:00
|
|
|
|
2003-02-13 12:37:10 +01:00
|
|
|
/**
|
|
|
|
* Absolute get method.
|
|
|
|
*
|
2003-05-13 08:04:19 +02:00
|
|
|
* @exception IndexOutOfBoundsException If index is negative or not smaller
|
|
|
|
* than the buffer's limit.
|
2003-02-13 12:37:10 +01:00
|
|
|
*/
|
|
|
|
public abstract byte get (int index);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Absolute put method.
|
|
|
|
*
|
2003-05-13 08:04:19 +02:00
|
|
|
* @exception IndexOutOfBoundsException If index is negative or not smaller
|
|
|
|
* than the buffer's limit.
|
|
|
|
* @exception ReadOnlyBufferException If this buffer is read-only.
|
2003-02-13 12:37:10 +01:00
|
|
|
*/
|
|
|
|
public abstract ByteBuffer put (int index, byte b);
|
2003-05-13 08:04:19 +02:00
|
|
|
|
2003-02-13 12:37:10 +01:00
|
|
|
/**
|
|
|
|
* Compacts this buffer.
|
2003-05-13 08:04:19 +02:00
|
|
|
*
|
|
|
|
* @exception ReadOnlyBufferException If this buffer is read-only.
|
2003-02-13 12:37:10 +01:00
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract ByteBuffer compact ();
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
2003-05-13 08:04:19 +02:00
|
|
|
* Tells wether or not this buffer is direct.
|
2003-02-13 12:37:10 +01:00
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract boolean isDirect ();
|
|
|
|
|
2003-02-13 12:37:10 +01:00
|
|
|
/**
|
2003-05-13 08:04:19 +02:00
|
|
|
* Creates a new <code>ByteBuffer</code> whose content is a shared
|
|
|
|
* subsequence of this buffer's content.
|
2003-02-13 12:37:10 +01:00
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract ByteBuffer slice ();
|
|
|
|
|
2003-02-13 12:37:10 +01:00
|
|
|
/**
|
2003-05-13 08:04:19 +02:00
|
|
|
* Creates a new <code>ByteBuffer</code> that shares this buffer's
|
|
|
|
* content.
|
2003-02-13 12:37:10 +01:00
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract ByteBuffer duplicate ();
|
|
|
|
|
2003-02-13 12:37:10 +01:00
|
|
|
/**
|
2003-05-13 08:04:19 +02:00
|
|
|
* Creates a new read-only <code>ByteBuffer</code> that shares this
|
|
|
|
* buffer's content.
|
2003-02-13 12:37:10 +01:00
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract ByteBuffer asReadOnlyBuffer ();
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a view of this byte buffer as a short buffer.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract ShortBuffer asShortBuffer ();
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a view of this byte buffer as a char buffer.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract CharBuffer asCharBuffer ();
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a view of this byte buffer as an integer buffer.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract IntBuffer asIntBuffer ();
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a view of this byte buffer as a long buffer.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract LongBuffer asLongBuffer ();
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a view of this byte buffer as a float buffer.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract FloatBuffer asFloatBuffer ();
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a view of this byte buffer as a double buffer.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract DoubleBuffer asDoubleBuffer ();
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Relative get method for reading a character value.
|
|
|
|
*
|
|
|
|
* @exception BufferUnderflowException If there are fewer than two bytes
|
|
|
|
* remaining in this buffer.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract char getChar ();
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Relative put method for writing a character value.
|
|
|
|
*
|
|
|
|
* @exception BufferOverflowException If this buffer's current position is
|
|
|
|
* not smaller than its limit.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract ByteBuffer putChar (char value);
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Absolute get method for reading a character value.
|
|
|
|
*
|
|
|
|
* @exception IndexOutOfBoundsException If there are fewer than two bytes
|
|
|
|
* remaining in this buffer
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract char getChar (int index);
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Absolute put method for writing a character value.
|
|
|
|
*
|
|
|
|
* @exception IndexOutOfBoundsException If index is negative or not smaller
|
|
|
|
* than the buffer's limit, minus one.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract ByteBuffer putChar (int index, char value);
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Relative get method for reading a short value.
|
|
|
|
*
|
|
|
|
* @exception BufferUnderflowException If index is negative or not smaller
|
|
|
|
* than the buffer's limit, minus one.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract short getShort ();
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Relative put method for writing a short value.
|
|
|
|
*
|
|
|
|
* @exception BufferOverflowException If this buffer's current position is
|
|
|
|
* not smaller than its limit.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract ByteBuffer putShort (short value);
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Absolute get method for reading a short value.
|
|
|
|
*
|
|
|
|
* @exception IndexOutOfBoundsException If there are fewer than two bytes
|
|
|
|
* remaining in this buffer
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract short getShort (int index);
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Absolute put method for writing a short value.
|
|
|
|
*
|
|
|
|
* @exception IndexOutOfBoundsException If index is negative or not smaller
|
|
|
|
* than the buffer's limit, minus one.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract ByteBuffer putShort (int index, short value);
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Relative get method for reading an integer value.
|
|
|
|
*
|
|
|
|
* @exception BufferUnderflowException If there are fewer than four bytes
|
|
|
|
* remaining in this buffer.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract int getInt ();
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Relative put method for writing an integer value.
|
|
|
|
*
|
|
|
|
* @exception BufferOverflowException If this buffer's current position is
|
|
|
|
* not smaller than its limit.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract ByteBuffer putInt (int value);
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Absolute get method for reading an integer value.
|
|
|
|
*
|
|
|
|
* @exception IndexOutOfBoundsException If index is negative or not smaller
|
|
|
|
* than the buffer's limit, minus three.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract int getInt (int index);
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Absolute put method for writing an integer value.
|
|
|
|
*
|
|
|
|
* @exception IndexOutOfBoundsException If index is negative or not smaller
|
|
|
|
* than the buffer's limit, minus three.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract ByteBuffer putInt (int index, int value);
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Relative get method for reading a long value.
|
|
|
|
*
|
|
|
|
* @exception BufferUnderflowException If there are fewer than eight bytes
|
|
|
|
* remaining in this buffer.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract long getLong ();
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Relative put method for writing a long value.
|
|
|
|
*
|
|
|
|
* @exception BufferOverflowException If this buffer's current position is
|
|
|
|
* not smaller than its limit.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract ByteBuffer putLong (long value);
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Absolute get method for reading a long value.
|
|
|
|
*
|
|
|
|
* @exception IndexOutOfBoundsException If index is negative or not smaller
|
|
|
|
* than the buffer's limit, minus seven.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract long getLong (int index);
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Absolute put method for writing a float value.
|
|
|
|
*
|
|
|
|
* @exception IndexOutOfBoundsException If index is negative or not smaller
|
|
|
|
* than the buffer's limit, minus seven.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract ByteBuffer putLong (int index, long value);
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Relative get method for reading a float value.
|
|
|
|
*
|
|
|
|
* @exception BufferUnderflowException If there are fewer than four bytes
|
|
|
|
* remaining in this buffer.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract float getFloat ();
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Relative put method for writing a float value.
|
|
|
|
*
|
|
|
|
* @exception BufferOverflowException If there are fewer than four bytes
|
|
|
|
* remaining in this buffer.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract ByteBuffer putFloat (float value);
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Absolute get method for reading a float value.
|
|
|
|
*
|
|
|
|
* @exception IndexOutOfBoundsException If index is negative or not smaller
|
|
|
|
* than the buffer's limit, minus three.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract float getFloat (int index);
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Relative put method for writing a float value.
|
|
|
|
*
|
|
|
|
* @exception IndexOutOfBoundsException If index is negative or not smaller
|
|
|
|
* than the buffer's limit, minus three.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract ByteBuffer putFloat (int index, float value);
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Relative get method for reading a double value.
|
|
|
|
*
|
|
|
|
* @exception BufferUnderflowException If there are fewer than eight bytes
|
|
|
|
* remaining in this buffer.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract double getDouble ();
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Relative put method for writing a double value.
|
|
|
|
*
|
|
|
|
* @exception BufferOverflowException If this buffer's current position is
|
|
|
|
* not smaller than its limit.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract ByteBuffer putDouble (double value);
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Absolute get method for reading a double value.
|
|
|
|
*
|
|
|
|
* @exception IndexOutOfBoundsException If index is negative or not smaller
|
|
|
|
* than the buffer's limit, minus seven.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract double getDouble (int index);
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Absolute put method for writing a double value.
|
|
|
|
*
|
|
|
|
* @exception IndexOutOfBoundsException If index is negative or not smaller
|
|
|
|
* than the buffer's limit, minus seven.
|
|
|
|
*/
|
2003-05-13 08:04:19 +02:00
|
|
|
public abstract ByteBuffer putDouble (int index, double value);
|
2003-02-13 12:37:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a string summarizing the state of this buffer.
|
|
|
|
*/
|
|
|
|
public String toString ()
|
|
|
|
{
|
|
|
|
return getClass ().getName () +
|
|
|
|
"[pos=" + position () +
|
|
|
|
" lim=" + limit () +
|
|
|
|
" cap=" + capacity () + "]";
|
|
|
|
}
|
2002-10-07 15:12:42 +02:00
|
|
|
}
|