public class ByteBuffer extends Object implements IoBuffer
| Modifier and Type | Field and Description |
|---|---|
static long |
SIZE_OF_BOOLEAN |
static long |
SIZE_OF_BYTE |
static long |
SIZE_OF_CHAR |
static long |
SIZE_OF_DOUBLE |
static long |
SIZE_OF_FLOAT |
static long |
SIZE_OF_INT |
static long |
SIZE_OF_LONG |
static long |
SIZE_OF_SHORT |
| Constructor and Description |
|---|
ByteBuffer()
construct new java.nio.ByteBuffer-based ByteBuffer with DEFAULT_INITIAL_CAPACITY
|
ByteBuffer(int nCapacity)
construct new java.nio.ByteBuffer-based ByteBuffer with DEFAULT_INITIAL_CAPACITY
|
| Modifier and Type | Method and Description |
|---|---|
int |
capacity() |
IoBuffer |
clear()
Clears this buffer.
|
IoBuffer |
ensureAdditionalCapacity(long capacity) |
IoBuffer |
ensureCapacity(long capacity) |
IoBuffer |
forceCapacity(long length,
long preserve)
Forces buffer to contain the given number of entries, preserving just a part of the array.
|
boolean |
getBoolean() |
boolean[] |
getBooleanArray(boolean[] dst,
long offset,
int length) |
byte |
getByte() |
byte[] |
getByteArray(byte[] dst,
long offset,
int length) |
char |
getChar() |
char[] |
getCharArray(char[] dst,
long offset,
int length) |
double |
getDouble() |
double[] |
getDoubleArray(double[] dst,
long offset,
int length) |
float |
getFloat() |
float[] |
getFloatArray(float[] dst,
long offset,
int length) |
int |
getInt() |
int[] |
getIntArray(int[] dst,
long offset,
int length) |
long |
getLong() |
long[] |
getLongArray(long[] dst,
long offset,
int length) |
short |
getShort() |
short[] |
getShortArray(short[] dst,
long offset,
int length) |
String |
getString() |
String[] |
getStringArray(String[] dst,
long offset,
int length) |
boolean |
hasRemaining() |
boolean |
isReadOnly() |
long |
limit() |
IoBuffer |
limit(int newLimit)
Sets this buffer's limit.
|
ReadWriteLock |
lock()
For efficiency/performance reasons the buffer implementation is not required to safe-guard each put/get method
independently.
|
long |
position() |
IoBuffer |
position(long newPosition)
Sets this buffer's position.
|
IoBuffer |
putBoolean(boolean value) |
IoBuffer |
putBooleanArray(boolean[] src,
long offset,
int nToCopy) |
IoBuffer |
putByte(byte b) |
IoBuffer |
putByteArray(byte[] src,
long offset,
int nToCopy) |
IoBuffer |
putChar(char value) |
IoBuffer |
putCharArray(char[] src,
long offset,
int nToCopy) |
IoBuffer |
putDouble(double value) |
IoBuffer |
putDoubleArray(double[] src,
long offset,
int nToCopy) |
IoBuffer |
putFloat(float value) |
IoBuffer |
putFloatArray(float[] src,
long offset,
int nToCopy) |
IoBuffer |
putInt(int value) |
IoBuffer |
putIntArray(int[] src,
long offset,
int nToCopy) |
IoBuffer |
putLong(long value) |
IoBuffer |
putLongArray(long[] src,
long offset,
int nToCopy) |
IoBuffer |
putShort(short value) |
IoBuffer |
putShortArray(short[] src,
long offset,
int nToCopy) |
IoBuffer |
putString(String string) |
IoBuffer |
putStringArray(String[] src,
long offset,
int nToCopy) |
long |
remaining() |
IoBuffer |
reset()
resets the buffer read/write position to zero
|
IoBuffer |
trim()
Trims the internal buffer array so that the capacity is equal to the size.
|
IoBuffer |
trim(int requestedCapacity)
Trims the internal buffer array if it is too large.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetBooleanArray, getBooleanArray, getByteArray, getByteArray, getCharArray, getCharArray, getDoubleArray, getDoubleArray, getFloatArray, getFloatArray, getIntArray, getIntArray, getLongArray, getLongArray, getShortArray, getShortArray, getStringArray, getStringArray, putBooleanArray, putBooleanArray, putByteArray, putByteArray, putCharArray, putCharArray, putDoubleArray, putDoubleArray, putFloatArray, putFloatArray, putIntArray, putIntArray, putLongArray, putLongArray, putShortArray, putShortArray, putStringArray, putStringArraypublic static final long SIZE_OF_BOOLEAN
public static final long SIZE_OF_BYTE
public static final long SIZE_OF_SHORT
public static final long SIZE_OF_CHAR
public static final long SIZE_OF_INT
public static final long SIZE_OF_LONG
public static final long SIZE_OF_FLOAT
public static final long SIZE_OF_DOUBLE
public ByteBuffer()
public ByteBuffer(int nCapacity)
nCapacity - initial capacitypublic int capacity()
capacity in interface IoBufferHeader<IoBuffer>public IoBuffer clear()
IoBufferHeaderInvoke this method before using a sequence of channel-read or put operations to fill this buffer. For example:
buf.clear(); // Prepare buffer for reading in.read(buf); // Read data
This method does not actually erase the data in the buffer, but it is named as if it did because it will most often be used in situations in which that might as well be the case.
clear in interface IoBufferHeader<IoBuffer>public IoBuffer ensureAdditionalCapacity(long capacity)
ensureAdditionalCapacity in interface IoBufferHeader<IoBuffer>public IoBuffer ensureCapacity(long capacity)
ensureCapacity in interface IoBufferHeader<IoBuffer>public IoBuffer forceCapacity(long length, long preserve)
IoBufferHeaderforceCapacity in interface IoBufferHeader<IoBuffer>length - the new minimum length for this array.preserve - the number of elements of the old buffer that shall be preserved in case a new allocation is
necessary.public boolean getBoolean()
getBoolean in interface IoBufferpublic boolean[] getBooleanArray(boolean[] dst,
long offset,
int length)
getBooleanArray in interface IoBufferpublic byte[] getByteArray(byte[] dst,
long offset,
int length)
getByteArray in interface IoBufferpublic char[] getCharArray(char[] dst,
long offset,
int length)
getCharArray in interface IoBufferpublic double[] getDoubleArray(double[] dst,
long offset,
int length)
getDoubleArray in interface IoBufferpublic float[] getFloatArray(float[] dst,
long offset,
int length)
getFloatArray in interface IoBufferpublic int[] getIntArray(int[] dst,
long offset,
int length)
getIntArray in interface IoBufferpublic long[] getLongArray(long[] dst,
long offset,
int length)
getLongArray in interface IoBufferpublic short[] getShortArray(short[] dst,
long offset,
int length)
getShortArray in interface IoBufferpublic String[] getStringArray(String[] dst, long offset, int length)
getStringArray in interface IoBufferpublic boolean hasRemaining()
hasRemaining in interface IoBufferHeader<IoBuffer>true if, and only if, there is at least one element remaining in this bufferpublic boolean isReadOnly()
isReadOnly in interface IoBufferHeader<IoBuffer>true if, and only if, this buffer is read-onlypublic long limit()
limit in interface IoBufferHeader<IoBuffer>public IoBuffer limit(int newLimit)
IoBufferHeaderlimit in interface IoBufferHeader<IoBuffer>newLimit - the new limit value; must be non-negative and no larger than this buffer's capacitypublic ReadWriteLock lock()
IoBufferHeaderlock in interface IoBufferHeader<IoBuffer>public long position()
position in interface IoBufferHeader<IoBuffer>public IoBuffer position(long newPosition)
IoBufferHeaderposition in interface IoBufferHeader<IoBuffer>newPosition - the new position value; must be non-negative and no larger than the current limitpublic IoBuffer putBoolean(boolean value)
putBoolean in interface IoBufferpublic IoBuffer putBooleanArray(boolean[] src, long offset, int nToCopy)
putBooleanArray in interface IoBufferpublic IoBuffer putByteArray(byte[] src, long offset, int nToCopy)
putByteArray in interface IoBufferpublic IoBuffer putCharArray(char[] src, long offset, int nToCopy)
putCharArray in interface IoBufferpublic IoBuffer putDoubleArray(double[] src, long offset, int nToCopy)
putDoubleArray in interface IoBufferpublic IoBuffer putFloatArray(float[] src, long offset, int nToCopy)
putFloatArray in interface IoBufferpublic IoBuffer putIntArray(int[] src, long offset, int nToCopy)
putIntArray in interface IoBufferpublic IoBuffer putLongArray(long[] src, long offset, int nToCopy)
putLongArray in interface IoBufferpublic IoBuffer putShortArray(short[] src, long offset, int nToCopy)
putShortArray in interface IoBufferpublic IoBuffer putStringArray(String[] src, long offset, int nToCopy)
putStringArray in interface IoBufferpublic long remaining()
remaining in interface IoBufferHeader<IoBuffer>public IoBuffer reset()
IoBufferHeaderreset in interface IoBufferHeader<IoBuffer>public IoBuffer trim()
IoBufferHeadertrim in interface IoBufferHeader<IoBuffer>ArrayList.trimToSize()public IoBuffer trim(int requestedCapacity)
IoBufferHeadern, this method does nothing. Otherwise, it trims the array length to the maximum between
requestedCapacity and IoBufferHeader.capacity().
This method is useful when reusing FastBuffers. Clearing a list leaves the array length untouched. If you are reusing a list many times, you can call this method with a typical size to avoid keeping around a very large array just because of a few large transient lists.
trim in interface IoBufferHeader<IoBuffer>requestedCapacity - the threshold for the trimming.Copyright © 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH. All rights reserved.