public class ExpansibleByteBuffer extends Object
| Modifier and Type | Field and Description |
|---|---|
private byte[] |
buf
the bytes of the buffer
|
private static int |
DEFAULT_INITIAL_SIZE
the default initial buffer size
|
private int |
initialSize
the initial size of the buffer in number of bytes: also increment for allocations
|
private int |
pos
the position into the buffer
|
| Constructor and Description |
|---|
ExpansibleByteBuffer()
Create a default ExpansibleByteBuffer capable of holding 10 bytes
|
ExpansibleByteBuffer(int initialSize)
Creates a ExpansibleByteBuffer which has an initialze size
|
| Modifier and Type | Method and Description |
|---|---|
void |
append(byte b)
Appends a byte to this buffer.
|
void |
append(byte[] bytes)
Appends the bytes to this buffer.
|
void |
append(int val)
Appends an int to this buffer.
|
byte[] |
buffer()
Get's the bytes, the backing store for this buffer.
|
int |
capacity() |
void |
clear()
Reset the Buffer position to 0.
|
byte[] |
copyOfUsedBytes()
Get's a copy of the bytes used.
|
byte |
get(int i)
Returns the byte at a given position.
|
private void |
growBuffer() |
private void |
growBuffer(int size) |
int |
position() |
void |
position(int pos)
Set the position to a specific value
|
private static final int DEFAULT_INITIAL_SIZE
private final int initialSize
private int pos
private byte[] buf
public ExpansibleByteBuffer()
public ExpansibleByteBuffer(int initialSize)
initialSize - The initial buffer sizepublic final void clear()
public final int position()
public final void position(int pos)
pos - the new positionpublic final int capacity()
public final byte get(int i)
i - The positionpublic final byte[] buffer()
public final byte[] copyOfUsedBytes()
public final void append(byte[] bytes)
bytes - The byte[] to append to the bufferpublic final void append(byte b)
b - The byte to append to the bufferpublic final void append(int val)
val - The integer to append to the bufferprivate void growBuffer(int size)
private void growBuffer()
Copyright © 2003–2019 The Apache Software Foundation. All rights reserved.