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.Modifier and Type | Field and Description |
---|---|
protected CompositeByteArray |
cba
The underlying
CompositeByteArray . |
protected ByteArray.Cursor |
cursor
A cursor of the underlying
CompositeByteArray . |
Constructor and Description |
---|
CompositeByteArrayRelativeReader(CompositeByteArray cba,
boolean autoFree)
Creates a new instance of CompositeByteArrayRelativeReader.
|
Modifier and Type | Method and Description |
---|---|
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()
Returns the byte at the current position in the buffer
|
void |
get(IoBuffer bb)
places the data starting at current position into the
supplied
IoBuffer |
char |
getChar()
Gets a
char and advances the reader. |
double |
getDouble()
Gets a
double and advances the reader. |
float |
getFloat()
Gets a
float and advances the reader. |
int |
getIndex()
Get the index that will be used for the next access.
|
int |
getInt()
Gets an
int and advances the reader. |
long |
getLong()
Gets a
long and advances the reader. |
int |
getRemaining() |
short |
getShort()
Gets a
short and advances the reader. |
boolean |
hasRemaining() |
int |
last()
Get the index after the last byte that can be accessed.
|
java.nio.ByteOrder |
order() |
void |
skip(int length)
Advances the reader by the given number of bytes.
|
ByteArray |
slice(int length)
Creates an array with a view of part of this array.
|
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)
IoRelativeReader
skip
in interface IoRelativeReader
public ByteArray slice(int length)
IoRelativeReader
slice
in interface IoRelativeReader
public byte get()
get
in interface IoRelativeReader
public void get(IoBuffer bb)
IoBuffer
get
in interface IoRelativeReader
public short getShort()
IoRelativeReader
short
and advances the reader.getShort
in interface IoRelativeReader
public int getInt()
IoRelativeReader
int
and advances the reader.getInt
in interface IoRelativeReader
public long getLong()
IoRelativeReader
long
and advances the reader.getLong
in interface IoRelativeReader
public float getFloat()
IoRelativeReader
float
and advances the reader.getFloat
in interface IoRelativeReader
public double getDouble()
IoRelativeReader
double
and advances the reader.getDouble
in interface IoRelativeReader
public char getChar()
IoRelativeReader
char
and advances the reader.getChar
in interface IoRelativeReader
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.public final void free()
public final int getIndex()
public final int last()
Copyright © 2004-2019 Apache MINA Project. All Rights Reserved.