public class StreamBufferImpl extends java.lang.Object implements StreamBuffer
| Modifier and Type | Field and Description |
|---|---|
java.lang.String |
debugTag |
| Constructor and Description |
|---|
StreamBufferImpl() |
StreamBufferImpl(byte[] inBytes) |
| Modifier and Type | Method and Description |
|---|---|
StreamBuffer |
advance(int relPosition)
Adjust the position by a relative amount.
|
StreamBuffer |
clear()
Clear the contents of the stream buffer, setting position and length to 0.
|
StreamBuffer |
clear(int clearBytes)
Clear bytes from the current position, cutting them from the buffer.
|
void |
consolidateAndFree()
Copies buffer contents into a single heap buffer and frees unused buffers.
|
StreamBuffer |
debugCopy() |
StreamBuffer |
duplicate() |
StreamBuffer |
duplicate(int viewLength) |
StreamBuffer |
flip()
Sets the position of the buffer to 0 and resets the insert mode.
|
byte |
get()
Read a byte from the underlying buffers.
|
int |
get(byte[] dst)
Read bytes from the underlying buffers into a byte array.
|
int |
get(byte[] dst,
int offset,
int getLength)
Read bytes from the underlying buffers into a byte array, starting at
the provided offset and reading a total of length bytes.
|
int |
get(java.nio.ByteBuffer dstBuffer)
Read as many bytes as possible from the underlying buffers into a byte buffer.
|
char |
getChar()
Read a char from the underlying buffers.
|
double |
getDouble()
Read a double from the underlying buffers.
|
float |
getFloat()
Read a float from the underlying buffers.
|
int |
getInt()
Read an integer from the underlying buffers.
|
long |
getLong()
Read a long from the underlying buffers.
|
short |
getShort()
Read a short from the underlying buffers.
|
void |
growthPolicy(boolean newGrowth)
Set the current growth policy, defaulting to true.
|
boolean |
hasRemaining() |
StreamBuffer |
insert(boolean insert)
Set the current insert mode.
|
int |
length() |
int |
position() |
StreamBuffer |
position(int newPosition)
Set the current buffer position.
|
void |
preAllocate(int minLength)
Pre-allocate buffers for writing, extending the length to the passed size.
|
StreamBuffer |
put(byte value)
Write a byte to the underlying buffers, allocating more if needed.
|
StreamBuffer |
put(byte[] src)
Write a byte array to the underlying buffers, allocating more if needed.
|
StreamBuffer |
put(byte[] src,
int offset,
int putLength)
Write part of a byte array to the underlying buffers, starting at the
provided offset and limited by the provided length, allocating more if
needed.
|
StreamBuffer |
put(java.nio.ByteBuffer... srcBuffers)
Write ByteBuffer contents to the underlying buffers,
allocating more if needed.
|
StreamBuffer |
putChar(char value)
Write a char to the underlying buffers, allocating more if needed.
|
StreamBuffer |
putDouble(double value)
Write a double to the underlying buffers, allocating more if needed.
|
StreamBuffer |
putFloat(float value)
Write a float to the underlying buffers, allocating more if needed.
|
StreamBuffer |
putInt(int value)
Write an integer to the underlying buffers, allocating more if needed.
|
StreamBuffer |
putLong(long value)
Write a long to the underlying buffers, allocating more if needed.
|
StreamBuffer |
putNoCopy(java.nio.ByteBuffer... ncBuffers)
Add ByteBuffers to the list of underlying buffers, the position is
advanced by the content length.
|
StreamBuffer |
putShort(short value)
Write a short to the underlying buffers, allocating more if needed.
|
void |
recyclePolicy(boolean newRecyle)
Set the current recycle policy, defaulting to false.
|
int |
remaining() |
StreamBuffer |
rewind()
Sets the position of the buffer to 0 and resets the insert mode.
|
byte[] |
toByteArray()
Obtain the contents of this buffer as a byte array.
|
java.nio.ByteBuffer[] |
toByteBuffers()
Obtain the contents of this buffer as byte buffers.
|
java.lang.String |
toString() |
public StreamBufferImpl()
public StreamBufferImpl(byte[] inBytes)
public int length()
length in interface StreamBufferpublic int position()
position in interface StreamBufferpublic StreamBuffer position(int newPosition)
StreamBufferposition in interface StreamBuffernewPosition - An int from 0 to the length of the buffer.public StreamBuffer advance(int relPosition)
StreamBufferadvance in interface StreamBufferrelPosition - The relative number of bytes to adjust the position.public int remaining()
remaining in interface StreamBufferpublic boolean hasRemaining()
hasRemaining in interface StreamBufferpublic StreamBuffer insert(boolean insert)
StreamBufferinsert in interface StreamBufferinsert - True to insert, false to overwritepublic void growthPolicy(boolean newGrowth)
StreamBuffergrowthPolicy in interface StreamBuffernewGrowth - True to grow, false to limit puts to the length.public void recyclePolicy(boolean newRecyle)
StreamBufferrecyclePolicy in interface StreamBufferpublic StreamBuffer flip()
StreamBufferflip in interface StreamBufferpublic StreamBuffer rewind()
StreamBufferrewind in interface StreamBufferpublic StreamBuffer clear()
StreamBufferclear in interface StreamBufferpublic StreamBuffer clear(int clearBytes)
StreamBufferclear in interface StreamBufferclearBytes - - The number of bytes to clear from the current position.public StreamBuffer debugCopy()
public StreamBuffer duplicate()
duplicate in interface StreamBufferpublic StreamBuffer duplicate(int viewLength)
duplicate in interface StreamBufferviewLength - - The number of bytes from the current position to include.public void preAllocate(int minLength)
StreamBufferpreAllocate in interface StreamBufferpublic void consolidateAndFree()
StreamBufferconsolidateAndFree in interface StreamBufferpublic StreamBuffer put(byte value)
StreamBufferput in interface StreamBuffervalue - The byte to write to buffer.public StreamBuffer putChar(char value)
StreamBufferputChar in interface StreamBuffervalue - The char to write to buffer.public StreamBuffer putShort(short value)
StreamBufferputShort in interface StreamBuffervalue - The short to write to buffer.public StreamBuffer putInt(int value)
StreamBufferputInt in interface StreamBuffervalue - The integer to write to buffer.public StreamBuffer putLong(long value)
StreamBufferputLong in interface StreamBuffervalue - The long to write to buffer.public StreamBuffer putFloat(float value)
StreamBufferputFloat in interface StreamBuffervalue - The float to write to buffer.public StreamBuffer putDouble(double value)
StreamBufferputDouble in interface StreamBuffervalue - The double to write to buffer.public StreamBuffer put(byte[] src)
StreamBufferput in interface StreamBuffersrc - The byte array to write to buffer.public StreamBuffer put(byte[] src, int offset, int putLength)
StreamBufferput in interface StreamBufferoffset - The starting offset in the byte array.putLength - The number of bytes to write from the offset.public StreamBuffer put(java.nio.ByteBuffer... srcBuffers)
StreamBufferput in interface StreamBuffersrcBuffers - One or more ByteBuffers to copy into this buffer.public StreamBuffer putNoCopy(java.nio.ByteBuffer... ncBuffers)
StreamBufferputNoCopy in interface StreamBufferncBuffers - One or more byte buffers to copy into this buffer.public byte get()
StreamBufferget in interface StreamBufferpublic char getChar()
StreamBuffergetChar in interface StreamBufferpublic short getShort()
StreamBuffergetShort in interface StreamBufferpublic int getInt()
StreamBuffergetInt in interface StreamBufferpublic long getLong()
StreamBuffergetLong in interface StreamBufferpublic float getFloat()
StreamBuffergetFloat in interface StreamBufferpublic double getDouble()
StreamBuffergetDouble in interface StreamBufferpublic int get(byte[] dst)
StreamBufferget in interface StreamBufferdst - The byte array to read into.public int get(byte[] dst,
int offset,
int getLength)
StreamBufferget in interface StreamBufferdst - The byte array to read into.offset - The starting offset in the byte array.getLength - The number of bytes to read into the byte array.public int get(java.nio.ByteBuffer dstBuffer)
StreamBufferget in interface StreamBufferdstBuffer - The byte buffer to read into.public byte[] toByteArray()
StreamBuffertoByteArray in interface StreamBufferpublic java.nio.ByteBuffer[] toByteBuffers()
StreamBuffertoByteBuffers in interface StreamBufferpublic java.lang.String toString()
toString in class java.lang.Object