public final class BufferBuilder extends Object
The underlying buffer can be byte[] backed or a direct ByteBuffer if the isDirect param to the constructor
is true.
Similar in concept to StringBuilder.
| Constructor and Description |
|---|
BufferBuilder()
Construct a buffer builder with an initial capacity of zero and isDirect false.
|
BufferBuilder(int initialCapacity)
Construct a buffer builder with an initial capacity and isDirect false.
|
BufferBuilder(int initialCapacity,
boolean isDirect)
Construct a buffer builder with an initial capacity.
|
| Modifier and Type | Method and Description |
|---|---|
BufferBuilder |
append(DirectBuffer srcBuffer,
int srcOffset,
int length)
Append a source buffer to the end of the internal buffer, resizing the internal buffer when required.
|
MutableDirectBuffer |
buffer()
The
MutableDirectBuffer that encapsulates the internal buffer. |
int |
capacity()
The current capacity of the buffer.
|
BufferBuilder |
compact()
Compact the buffer to reclaim unused space above the limit.
|
int |
limit()
The current limit of the buffer that has been used by append operations.
|
void |
limit(int limit)
Set this limit for this buffer as the position at which the next append operation will occur.
|
int |
nextTermOffset()
Get the value which the next term offset for a fragment to be assembled should begin at.
|
void |
nextTermOffset(int offset)
Set the value which the next term offset for a fragment to be assembled should begin at.
|
BufferBuilder |
reset()
Reset the builder to restart append operations.
|
public BufferBuilder()
public BufferBuilder(int initialCapacity)
initialCapacity - at which the capacity will start.public BufferBuilder(int initialCapacity,
boolean isDirect)
initialCapacity - at which the capacity will start.isDirect - is the underlying buffer to be a direct ByteBufferpublic int capacity()
public int limit()
public void limit(int limit)
limit - to be the new value.public int nextTermOffset()
public void nextTermOffset(int offset)
offset - which the next term offset for a fragment to be assembled should begin at.public MutableDirectBuffer buffer()
MutableDirectBuffer that encapsulates the internal buffer.MutableDirectBuffer that encapsulates the internal buffer.public BufferBuilder reset()
public BufferBuilder compact()
public BufferBuilder append(DirectBuffer srcBuffer, int srcOffset, int length)
srcBuffer - from which to copy.srcOffset - in the source buffer from which to copy.length - in bytes to copy from the source buffer.Copyright © 2014-2023 Real Logic Limited. All Rights Reserved.