public class CompositeByteArrayRelativeWriter extends java.lang.Object implements IoRelativeWriter
CompositeByteArray.
Using this interface has the advantage that it can be automatically
determined when a component ByteArray can no longer be written
to, and thus components can be automatically flushed. This makes it easier to
use pooling for underlying ByteArrays.
By providing an appropriate Expander it is also possible to
automatically add more backing storage as more data is written.
| 限定符和类型 | 类和说明 |
|---|---|
static class |
CompositeByteArrayRelativeWriter.ChunkedExpander
Expands the supplied
CompositeByteArray by the number of
bytes provided in the constructor |
static interface |
CompositeByteArrayRelativeWriter.Expander
An object that knows how to expand a
CompositeByteArray. |
static interface |
CompositeByteArrayRelativeWriter.Flusher
An object that knows how to flush a
ByteArray. |
static class |
CompositeByteArrayRelativeWriter.NopExpander
No-op expander.
|
| 限定符和类型 | 字段和说明 |
|---|---|
protected CompositeByteArray |
cba
The underlying
CompositeByteArray. |
protected ByteArray.Cursor |
cursor
A cursor of the underlying
CompositeByteArray. |
| 构造器和说明 |
|---|
CompositeByteArrayRelativeWriter(CompositeByteArray cba,
CompositeByteArrayRelativeWriter.Expander expander,
CompositeByteArrayRelativeWriter.Flusher flusher,
boolean autoFlush)
Creates a new instance of CompositeByteArrayRelativeWriter.
|
| 限定符和类型 | 方法和说明 |
|---|---|
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 |
flush()
Flush to the current index.
|
void |
flushTo(int index)
Flush to the given index.
|
void |
free()
Free all resources associated with this object.
|
int |
getIndex() |
int |
getRemaining() |
boolean |
hasRemaining() |
int |
last() |
java.nio.ByteOrder |
order() |
void |
put(byte b)
Puts a
byte and advances the reader. |
void |
put(IoBuffer bb)
Puts enough bytes to fill the
IoBuffer and advances the reader. |
void |
putChar(char c)
Puts a
char and advances the reader. |
void |
putDouble(double d)
Puts a
double and advances the reader. |
void |
putFloat(float f)
Puts a
float and advances the reader. |
void |
putInt(int i)
Puts an
int and advances the reader. |
void |
putLong(long l)
Puts a
long and advances the reader. |
void |
putShort(short s)
Puts a
short and advances the reader. |
void |
skip(int length)
Advances the writer by the given number of bytes.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetRemaining, hasRemaining, orderprotected 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 CompositeByteArrayRelativeWriter(CompositeByteArray cba, CompositeByteArrayRelativeWriter.Expander expander, CompositeByteArrayRelativeWriter.Flusher flusher, boolean autoFlush)
cba - The CompositeByteArray to use to back this classexpander - The expander. Will increase the size of the internal ByteArrayflusher - Flushed the ByteArray when necessaryautoFlush - Should this class automatically flush?public void flush()
public void flushTo(int index)
index - The end positionpublic void skip(int length)
skip 在接口中 IoRelativeWriterlength - The number of bytes to skipprotected 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 put(byte b)
byte and advances the reader.put 在接口中 IoRelativeWriterb - The byte to putpublic void put(IoBuffer bb)
IoBuffer and advances the reader.put 在接口中 IoRelativeWriterbb - The bytes to putpublic void putShort(short s)
short and advances the reader.putShort 在接口中 IoRelativeWriters - The short to putpublic void putInt(int i)
int and advances the reader.putInt 在接口中 IoRelativeWriteri - The int to putpublic void putLong(long l)
long and advances the reader.putLong 在接口中 IoRelativeWriterl - The long to putpublic void putFloat(float f)
float and advances the reader.putFloat 在接口中 IoRelativeWriterf - The float to putpublic void putDouble(double d)
double and advances the reader.putDouble 在接口中 IoRelativeWriterd - The double to putpublic void putChar(char c)
char and advances the reader.putChar 在接口中 IoRelativeWriterc - The char to putpublic 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()