public class CompositeByteArrayRelativeReader extends CompositeByteArrayRelativeBase 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
ByteArrays.| Modifier and Type | Field and Description |
|---|---|
private boolean |
autoFree
Whether or not to free component
CompositeByteArrays when
the cursor moves past them. |
cba, cursor| Constructor and Description |
|---|
CompositeByteArrayRelativeReader(CompositeByteArray cba,
boolean autoFree)
Creates a new instance of CompositeByteArrayRelativeReader.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
cursorPassedFirstComponent()
Called whenever the cursor has passed from the
cba's
first component. |
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 |
getInt()
Gets an
int and advances the reader. |
long |
getLong()
Gets a
long and advances the reader. |
short |
getShort()
Gets a
short and advances the reader. |
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.
|
append, free, getIndex, getRemaining, hasRemaining, last, orderclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetRemaining, hasRemaining, orderprivate final boolean autoFree
CompositeByteArrays when
the cursor moves past them.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()
CompositeByteArrayRelativeBasecba'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).cursorPassedFirstComponent in class CompositeByteArrayRelativeBasepublic void skip(int length)
IoRelativeReaderskip in interface IoRelativeReaderpublic ByteArray slice(int length)
IoRelativeReaderslice in interface IoRelativeReaderpublic byte get()
get in interface IoRelativeReaderpublic void get(IoBuffer bb)
IoBufferget in interface IoRelativeReaderpublic short getShort()
IoRelativeReadershort and advances the reader.getShort in interface IoRelativeReaderpublic int getInt()
IoRelativeReaderint and advances the reader.getInt in interface IoRelativeReaderpublic long getLong()
IoRelativeReaderlong and advances the reader.getLong in interface IoRelativeReaderpublic float getFloat()
IoRelativeReaderfloat and advances the reader.getFloat in interface IoRelativeReaderpublic double getDouble()
IoRelativeReaderdouble and advances the reader.getDouble in interface IoRelativeReaderpublic char getChar()
IoRelativeReaderchar and advances the reader.getChar in interface IoRelativeReader