@Internal public class ExpandableBuffer extends Object
ByteBuffer
.
This class is not thread safe.
Modifier and Type | Class and Description |
---|---|
static class |
ExpandableBuffer.Mode
A buffer's mode.
|
Modifier | Constructor and Description |
---|---|
protected |
ExpandableBuffer(int bufferSize)
Allocates buffer of the given size using the given allocator.
|
Modifier and Type | Method and Description |
---|---|
protected ByteBuffer |
buffer() |
protected int |
capacity()
Returns available capacity of this buffer.
|
protected void |
clear()
Clears buffer.
|
protected void |
ensureAdjustedCapacity(int requiredCapacity)
Ensures the buffer can accommodate at least the required capacity adjusted to multiples of 1024.
|
protected void |
ensureCapacity(int requiredCapacity)
Ensures the buffer can accommodate the exact required capacity.
|
protected void |
expand()
Expands buffer's capacity.
|
protected boolean |
hasData()
Determines if the buffer contains data.
|
protected int |
length()
Returns the length of this buffer.
|
protected ExpandableBuffer.Mode |
mode()
|
protected void |
setInputMode()
Sets the mode to
INPUT . |
protected void |
setOutputMode()
Sets the mode to
OUTPUT . |
String |
toString() |
protected ExpandableBuffer(int bufferSize)
Sets the mode to INPUT
.
bufferSize
- the buffer size.protected ExpandableBuffer.Mode mode()
protected ByteBuffer buffer()
protected void setOutputMode()
OUTPUT
. The buffer can now be read from.protected void setInputMode()
INPUT
. The buffer can now be written into.protected void expand() throws BufferOverflowException
BufferOverflowException
- in case we get over the maximum allowed valueprotected void ensureCapacity(int requiredCapacity)
requiredCapacity
- the required capacity.protected void ensureAdjustedCapacity(int requiredCapacity)
requiredCapacity
- the required capacity.protected boolean hasData()
Sets the mode to output.
true
if there is data in the buffer,
false
otherwise.protected int length()
Sets the mode to output.
protected int capacity()
protected void clear()
Sets the mode to INPUT
.
Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.