net.named_data.jndn.util
public class DynamicByteBuffer extends Object
Constructor and Description |
---|
DynamicByteBuffer(int initialCapacity)
Create a new DynamicByteBuffer with an initial capacity.
|
Modifier and Type | Method and Description |
---|---|
ByteBuffer |
buffer()
Return the ByteBuffer.
|
void |
ensureCapacity(int capacity)
Ensure that buffer().capacity() is greater than or equal to capacity.
|
void |
ensureCapacityFromBack(int capacity)
Ensure that buffer().capacity() is greater than or equal to capacity.
|
void |
ensuredPut(byte b)
Call ensureCapacity to ensure there is capacity for 1 more byte and call
buffer().put(b).
|
void |
ensuredPut(ByteBuffer buffer)
Call ensureCapacity to ensure there is capacity for buffer.remaining() more
bytes and use buffer().put to copy.
|
void |
ensuredPut(ByteBuffer buffer,
int position,
int limit)
Call ensureCapacity to ensure there is capacity for (limit - position) more
bytes and use buffer().put to copy.
|
void |
ensuredPutFromBack(byte b)
Call setRemainingFromBack to ensure there are remaining bytes for 1 more
byte and put b at the new position.
|
void |
ensureRemainingCapacity(int remainingCapacity)
Use ensureCapacity to ensure there are remainingCapacity bytes after
position().
|
ByteBuffer |
flippedBuffer()
Return a new ByteBuffer which is the flipped version of buffer().
|
int |
limit()
Return buffer_.limit().
|
int |
position()
Return buffer_.position().
|
void |
position(int newPosition)
Call buffer_.position(newPosition).
|
int |
remaining()
Return buffer_.remaining().
|
int |
setRemainingFromBack(int remaining)
Change the position so that there are remaining bytes in the buffer.
|
public DynamicByteBuffer(int initialCapacity)
initialCapacity
- The initial capacity of buffer().public final void ensureCapacity(int capacity)
capacity
- The minimum needed capacity.public final void ensureRemainingCapacity(int remainingCapacity)
remainingCapacity
- The desired minimum capacity after position().public final void ensuredPut(byte b)
b
- The byte to put.public final void ensuredPut(ByteBuffer buffer)
buffer
- The buffer to copy from. This does not change
buffer.position() or buffer.limit().public final void ensuredPut(ByteBuffer buffer, int position, int limit)
buffer
- The buffer to copy from. This does not change
buffer.position() or buffer.limit().position
- The position in buffer to copy from.limit
- The limit in buffer to copy from.public final void ensureCapacityFromBack(int capacity)
capacity
- The minimum needed capacity.public final int setRemainingFromBack(int remaining)
remaining
- The desired remaining bytes which causes the position
to be changed.public final void ensuredPutFromBack(byte b)
b
- The byte to put.public final ByteBuffer buffer()
public final ByteBuffer flippedBuffer()
public final int position()
public final void position(int newPosition)
newPosition
- The new position.public final int limit()
public final int remaining()
Copyright © 2016. All rights reserved.