java.lang.StringBuilder
, but for arrays of bytes. The
client appends data and may finally take the built array, often
without copying the data.
Modifier and Type | Field and Description |
---|---|
pack-priv static final byte[] | |
private int | |
private byte | |
private byte[] |
Access | Constructor and Description |
---|---|
public | |
public |
Modifier and Type | Method and Description |
---|---|
public void | append(byte[]
the value b, int index of the first byte written off, int number of bytes to write n)Append a specified number of bytes from a given offset in a
|
public void | |
public void | |
public void | |
public void | |
public void | |
public void | |
protected void | appendUnchecked(int
to append v)Implements abstract org. |
protected void | ensure(int
to make space for n)Implements abstract org. n elements.
|
public int | length()
Implements abstract org. |
public int | max()
Implements abstract org. |
public byte[] | take()
Implements abstract org. |
protected int[] | value()
Implements abstract org. |
EMPTY_BYTE_ARRAY | back to summary |
---|---|
pack-priv static final byte[] EMPTY_BYTE_ARRAY |
len | back to summary |
---|---|
private int len |
max | back to summary |
---|---|
private byte max |
value | back to summary |
---|---|
private byte[] value |
ByteArrayBuilder | back to summary |
---|---|
public ByteArrayBuilder(int capacity) Create an empty buffer of a defined initial capacity.
|
ByteArrayBuilder | back to summary |
---|---|
public ByteArrayBuilder() Create an empty buffer of a default initial capacity. |
append | back to summary |
---|---|
public void append(byte[] b, int off, int n) Append a specified number of bytes from a given offset in a
|
appendIntBE | back to summary |
---|---|
public void appendIntBE(int v) Append the 4 bytes of a
|
appendIntLE | back to summary |
---|---|
public void appendIntLE(int v) Append the 4 bytes of a
|
appendLongBE | back to summary |
---|---|
public void appendLongBE(long v) Append the 8 bytes of a
|
appendLongLE | back to summary |
---|---|
public void appendLongLE(long v) Append the 8 bytes of a
|
appendShortBE | back to summary |
---|---|
public void appendShortBE(int v) Append the 2 bytes of a
|
appendShortLE | back to summary |
---|---|
public void appendShortLE(int v) Append the 2 bytes of a
|
appendUnchecked | back to summary |
---|---|
protected void appendUnchecked(int v) Implements abstract org. Doc from org. Append one element without ensuring that there is space. This
method is for use when it is known that there is space for the
element, for example, inside a loop before which when
|
ensure | back to summary |
---|---|
protected void ensure(int n) Implements abstract org. Ensure there is room for another
|
length | back to summary |
---|---|
public int length() Implements abstract org. Doc from org. The number of elements currently
|
max | back to summary |
---|---|
public int max() Implements abstract org. Doc from org. The maximum value stored.
|
take | back to summary |
---|---|
public byte[] take() Implements abstract org. Doc from org. Provide the contents as an array and reset the builder to empty.
(This is a "destructive read".) The return type is Object in
order that sub-classes may define the specific type (for example,
|
value | back to summary |
---|---|
protected int[] value() Implements abstract org. Doc from org. An array of the elements in the buffer (not modified by methods on this object hereafter).
|