public class BufferBuilder
extends java.lang.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(org.agrona.DirectBuffer srcBuffer,
int srcOffset,
int length)
Append a source buffer to the end of the internal buffer, resizing the internal buffer as required.
|
org.agrona.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.
|
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 org.agrona.MutableDirectBuffer buffer()
MutableDirectBuffer that encapsulates the internal buffer.MutableDirectBuffer that encapsulates the internal buffer.public BufferBuilder reset()
public BufferBuilder compact()
public BufferBuilder append(org.agrona.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-2018 Real Logic Ltd. All Rights Reserved.