public abstract class BufferByteArray
extends java.lang.Object
ByteArray
backed by a IoBuffer
. This class
is abstract. Subclasses need to override the free()
method. An
implementation backed by a heap IoBuffer
can be created with
a SimpleByteArrayFactory
.ByteArray.Cursor
构造器和说明 |
---|
BufferByteArray(IoBuffer bb)
Creates a new instance of BufferByteArray and uses the supplied
IoBuffer to back this class |
限定符和类型 | 方法和说明 |
---|---|
ByteArray.Cursor |
cursor() |
ByteArray.Cursor |
cursor(int index) |
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() |
abstract void |
free()
Remove any resources associated with this object.
|
byte |
get(int index) |
void |
get(int index,
IoBuffer other)
Gets enough bytes to fill the IoBuffer from the given index.
|
char |
getChar(int index) |
double |
getDouble(int index) |
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 other)
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 |
slice(int index,
int length)
Creates an array with a view of part of this array.
|
protected IoBuffer bb
IoBuffer
.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 slice(int index, int length)
free()
on the returned slice has no effect.index
- The starting positionlength
- The number of bytes to copypublic abstract void free()
public ByteArray.Cursor cursor()
public ByteArray.Cursor cursor(int index)
index
- The starting pointpublic int first()
public int last()
public java.nio.ByteOrder order()
public void order(java.nio.ByteOrder order)
order
- The ByteOrder to usepublic 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 other)
index
- The starting positionother
- The IoBuffer that will be filled with the bytespublic void put(int index, IoBuffer other)
IoBuffer
at the given index.index
- The positionother
- The bytes to putpublic 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)