public class ByteArrayBuilder
extends java.lang.Object
byte[]s where the final size of the
data is not known beforehand. The API is similar to ByteBuffer but
the data is not actually written to a byte[] until toBuffer() or toArray() is called.| Modifier and Type | Class and Description |
|---|---|
private static class |
ByteArrayBuilder.BufData |
private static class |
ByteArrayBuilder.ByteData |
private static class |
ByteArrayBuilder.BytesData |
private static class |
ByteArrayBuilder.Data |
private static class |
ByteArrayBuilder.IntData |
private static class |
ByteArrayBuilder.ShortData |
| Modifier and Type | Field and Description |
|---|---|
private java.util.List<ByteArrayBuilder.Data> |
_data |
private int |
_pos |
| Constructor and Description |
|---|
ByteArrayBuilder() |
| Modifier and Type | Method and Description |
|---|---|
int |
position() |
ByteArrayBuilder |
put(byte val) |
ByteArrayBuilder |
put(byte[] val) |
private ByteArrayBuilder |
put(ByteArrayBuilder.Data data) |
ByteArrayBuilder |
put(java.nio.ByteBuffer val) |
ByteArrayBuilder |
putInt(int val) |
ByteArrayBuilder |
putInt(int pos,
int val) |
ByteArrayBuilder |
putShort(int pos,
short val) |
ByteArrayBuilder |
putShort(short val) |
ByteArrayBuilder |
reserve(int bytes) |
ByteArrayBuilder |
reserveInt() |
ByteArrayBuilder |
reserveShort() |
byte[] |
toArray() |
java.nio.ByteBuffer |
toBuffer() |
java.nio.ByteBuffer |
toBuffer(java.nio.ByteBuffer buf) |
private int _pos
private final java.util.List<ByteArrayBuilder.Data> _data
public int position()
public ByteArrayBuilder reserveInt()
public ByteArrayBuilder reserveShort()
public ByteArrayBuilder reserve(int bytes)
public ByteArrayBuilder put(byte val)
public ByteArrayBuilder putInt(int val)
public ByteArrayBuilder putInt(int pos, int val)
public ByteArrayBuilder putShort(short val)
public ByteArrayBuilder putShort(int pos, short val)
public ByteArrayBuilder put(byte[] val)
public ByteArrayBuilder put(java.nio.ByteBuffer val)
private ByteArrayBuilder put(ByteArrayBuilder.Data data)
public java.nio.ByteBuffer toBuffer()
public java.nio.ByteBuffer toBuffer(java.nio.ByteBuffer buf)
public byte[] toArray()