public class CompositeByteArrayRelativeReader extends java.lang.Object implements IoRelativeReader
CompositeByteArray
. Using this interface has the advantage
that it can be automatically determined when a component
ByteArray
can no longer be read, and thus components can be
automatically freed. This makes it easier to use pooling for underlying
ByteArray
s.限定符和类型 | 字段和说明 |
---|---|
protected CompositeByteArray |
cba
The underlying
CompositeByteArray . |
protected ByteArray.Cursor |
cursor
A cursor of the underlying
CompositeByteArray . |
构造器和说明 |
---|
CompositeByteArrayRelativeReader(CompositeByteArray cba,
boolean autoFree)
Creates a new instance of CompositeByteArrayRelativeReader.
|
限定符和类型 | 方法和说明 |
---|---|
void |
append(ByteArray ba)
Make a
ByteArray available for access at the end of this object. |
protected void |
cursorPassedFirstComponent()
Called whenever the cursor has passed from the
cba 's
first component. |
void |
free()
Free all resources associated with this object.
|
byte |
get() |
void |
get(IoBuffer bb)
places the data starting at current position into the
supplied
IoBuffer |
char |
getChar() |
double |
getDouble() |
float |
getFloat() |
int |
getIndex() |
int |
getInt() |
long |
getLong() |
int |
getRemaining() |
short |
getShort() |
boolean |
hasRemaining() |
int |
last() |
java.nio.ByteOrder |
order() |
void |
skip(int length)
Advances the reader by the given number of bytes.
|
ByteArray |
slice(int length) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getRemaining, hasRemaining, order
protected final CompositeByteArray cba
CompositeByteArray
.protected final ByteArray.Cursor cursor
CompositeByteArray
. This
cursor is never moved directly; its position only changes through calls
to relative read or write methods.public CompositeByteArrayRelativeReader(CompositeByteArray cba, boolean autoFree)
cba
- The backing ByteArrayautoFree
- If data should be freed once it has been passed in the listprotected void cursorPassedFirstComponent()
cba
's
first component. As the first component is no longer used, this provides
a good opportunity for subclasses to perform some action on it (such as
freeing it).public void skip(int length)
skip
在接口中 IoRelativeReader
length
- the number of bytes to skippublic ByteArray slice(int length)
slice
在接口中 IoRelativeReader
length
- The number of bytes to getpublic byte get()
get
在接口中 IoRelativeReader
public void get(IoBuffer bb)
IoBuffer
get
在接口中 IoRelativeReader
bb
- The IoBuffer that will contain the read bytespublic short getShort()
getShort
在接口中 IoRelativeReader
short
and advances the reader.public int getInt()
getInt
在接口中 IoRelativeReader
int
and advances the reader.public long getLong()
getLong
在接口中 IoRelativeReader
long
and advances the reader.public float getFloat()
getFloat
在接口中 IoRelativeReader
float
and advances the reader.public double getDouble()
getDouble
在接口中 IoRelativeReader
double
and advances the reader.public char getChar()
getChar
在接口中 IoRelativeReader
char
and advances the reader.public final int getRemaining()
public final boolean hasRemaining()
public java.nio.ByteOrder order()
public final void append(ByteArray ba)
ByteArray
available for access at the end of this object.ba
- The ByteArray to appendpublic final void free()
public final int getIndex()
public final int last()