public final class CompositeByteArray
extends java.lang.Object
限定符和类型 | 类和说明 |
---|---|
static interface |
CompositeByteArray.CursorListener
Allows for efficient detection of component boundaries when using a cursor.
|
ByteArray.Cursor
构造器和说明 |
---|
CompositeByteArray()
Creates a new instance of CompositeByteArray.
|
CompositeByteArray(ByteArrayFactory byteArrayFactory)
Creates a new instance of CompositeByteArray.
|
限定符和类型 | 方法和说明 |
---|---|
void |
addFirst(ByteArray ba)
Adds the specified
ByteArray to the first
position in the list |
void |
addLast(ByteArray ba)
Adds the specified
ByteArray to the end of the list |
ByteArray.Cursor |
cursor() |
ByteArray.Cursor |
cursor(CompositeByteArray.CursorListener listener)
Get a cursor starting at index 0 (which may not be the start of the
array) and with the given listener.
|
ByteArray.Cursor |
cursor(int index) |
ByteArray.Cursor |
cursor(int index,
CompositeByteArray.CursorListener listener)
Get a cursor starting at the given index and with the given listener.
|
boolean |
equals(java.lang.Object other)
A ByteArray is equal to another ByteArray if they start and end at the
same index, have the same byte order, and contain the same bytes at each
index.
|
int |
first() |
void |
free()
Remove any resources associated with this object.
|
byte |
get(int index) |
void |
get(int index,
IoBuffer bb)
Gets enough bytes to fill the IoBuffer from the given index.
|
char |
getChar(int index) |
double |
getDouble(int index) |
ByteArray |
getFirst() |
float |
getFloat(int index) |
int |
getInt(int index) |
java.lang.Iterable<IoBuffer> |
getIoBuffers() |
long |
getLong(int index) |
short |
getShort(int index) |
IoBuffer |
getSingleIoBuffer() |
int |
last() |
int |
length() |
java.nio.ByteOrder |
order() |
void |
order(java.nio.ByteOrder order)
Set the byte order of the array.
|
void |
put(int index,
byte b)
Puts a
byte at the given index. |
void |
put(int index,
IoBuffer bb)
Puts bytes from the
IoBuffer at the given index. |
void |
putChar(int index,
char c)
Puts a
char at the given index. |
void |
putDouble(int index,
double d)
Puts a
double at the given index. |
void |
putFloat(int index,
float f)
Puts a
float at the given index. |
void |
putInt(int index,
int i)
Puts an
int at the given index. |
void |
putLong(int index,
long l)
Puts a
long at the given index. |
void |
putShort(int index,
short s)
Puts a
short at the given index. |
ByteArray |
removeFirst()
Remove the first
ByteArray in the list |
ByteArray |
removeLast()
Removes the last
ByteArray in the list |
ByteArray |
removeTo(int index)
Remove component
ByteArray s to the given index (splitting
them if necessary) and returning them in a single ByteArray . |
ByteArray |
slice(int index,
int length)
Creates an array with a view of part of this array.
|
public CompositeByteArray()
public CompositeByteArray(ByteArrayFactory byteArrayFactory)
byteArrayFactory
- The factory used to create the ByteArray objectspublic void addFirst(ByteArray ba)
ByteArray
to the first
position in the listba
- The ByteArray to add to the listpublic ByteArray removeFirst()
ByteArray
in the listpublic ByteArray removeTo(int index)
ByteArray
s to the given index (splitting
them if necessary) and returning them in a single ByteArray
.
The caller is responsible for freeing the returned object.
TODO: Document free behaviour more thoroughly.index
- The index from where we will remove bytespublic void addLast(ByteArray ba)
ByteArray
to the end of the listba
- The ByteArray to add to the end of the listpublic ByteArray removeLast()
ByteArray
in the listpublic void free()
public java.lang.Iterable<IoBuffer> getIoBuffers()
IoBuffer
s that back this array.
Compared to getSingleIoBuffer()
, this method should be
relatively efficient for all implementations.public IoBuffer getSingleIoBuffer()
IoBuffer
that backs this array. Some
implementations may initially have data split across multiple buffers, so
calling this method may require a new buffer to be allocated and
populated.public ByteArray.Cursor cursor()
public ByteArray.Cursor cursor(int index)
index
- The starting pointpublic ByteArray.Cursor cursor(CompositeByteArray.CursorListener listener)
listener
- The listener to useByteArray.Cursor
instancepublic ByteArray.Cursor cursor(int index, CompositeByteArray.CursorListener listener)
index
- The position of the array to start the Cursor atlistener
- The listener for the Cursor that is returnedpublic ByteArray slice(int index, int length)
index
- The starting positionlength
- The number of bytes to copypublic byte get(int index)
index
- The starting positionpublic void put(int index, byte b)
byte
at the given index.index
- The positionb
- The byte to putpublic void get(int index, IoBuffer bb)
index
- The starting positionbb
- The IoBuffer that will be filled with the bytespublic void put(int index, IoBuffer bb)
IoBuffer
at the given index.index
- The positionbb
- The bytes to putpublic int first()
public int last()
public java.nio.ByteOrder order()
public void order(java.nio.ByteOrder order)
order
- The ByteOrder to usepublic short getShort(int index)
index
- The starting positionpublic void putShort(int index, short s)
short
at the given index.index
- The positions
- The short to putpublic int getInt(int index)
index
- The starting positionpublic void putInt(int index, int i)
int
at the given index.index
- The positioni
- The int to putpublic long getLong(int index)
index
- The starting positionpublic void putLong(int index, long l)
long
at the given index.index
- The positionl
- The long to putpublic float getFloat(int index)
index
- The starting positionpublic void putFloat(int index, float f)
float
at the given index.index
- The positionf
- The float to putpublic double getDouble(int index)
index
- The starting positionpublic void putDouble(int index, double d)
double
at the given index.index
- The positiond
- The doubvle to putpublic char getChar(int index)
index
- The starting positionpublic void putChar(int index, char c)
char
at the given index.index
- The positionc
- The char to putpublic final int length()
length
在接口中 IoAbsoluteReader
public final boolean equals(java.lang.Object other)