Top Description Fields Constructors Methods
org.python.core.stringlib

public final Class ByteArrayBuilder

extends Forward
Class Inheritance

An elastic buffer of byte values, somewhat like the java.lang.StringBuilder, but for arrays of bytes. The client appends data and may finally take the built array, often without copying the data.

Field Summary

Modifier and TypeField and Description
pack-priv static final byte[]
private int
private byte
private byte[]

Constructor Summary

AccessConstructor and Description
public
ByteArrayBuilder(int
initially
capacity
)

Create an empty buffer of a defined initial capacity.

public
ByteArrayBuilder()

Create an empty buffer of a default initial capacity.

Method Summary

Modifier and TypeMethod 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 byte array.

public void
appendIntBE(int
the value
v
)

Append the 4 bytes of a int value big-endian.

public void
appendIntLE(int
the value
v
)

Append the 4 bytes of a int value little-endian.

public void
appendLongBE(long
the value
v
)

Append the 8 bytes of a long value big-endian.

public void
appendLongLE(long
the value
v
)

Append the 8 bytes of a long value little-endian.

public void
appendShortBE(int
the value
v
)

Append the 2 bytes of a short value big-endian.

public void
appendShortLE(int
the value
v
)

Append the 2 bytes of a short value little-endian.

protected void
appendUnchecked(int
to append
v
)

Implements abstract org.python.core.stringlib.AbstractIntArrayBuilder.Forward.appendUnchecked.

Append one element without ensuring that there is space.
protected void
ensure(int
to make space for
n
)

Implements abstract org.python.core.stringlib.AbstractIntArrayBuilder.ensure.

Ensure there is room for another n elements.
public int
length()

Implements abstract org.python.core.stringlib.AbstractIntArrayBuilder.length.

The number of elements currently
public int
max()

Implements abstract org.python.core.stringlib.AbstractIntArrayBuilder.max.

The maximum value stored.
public byte[]
take()

Implements abstract org.python.core.stringlib.AbstractIntArrayBuilder.take.

Provide the contents as an array and reset the builder to empty.
protected int[]
value()

Implements abstract org.python.core.stringlib.AbstractIntArrayBuilder.value.

An array of the elements in the buffer (not modified by methods on this object hereafter).
Inherited from org.python.core.stringlib.AbstractIntArrayBuilder.Forward:
appendappendappend

Field Detail

EMPTY_BYTE_ARRAYback to summary
pack-priv static final byte[] EMPTY_BYTE_ARRAY
lenback to summary
private int len
maxback to summary
private byte max
valueback to summary
private byte[] value

Constructor Detail

ByteArrayBuilderback to summary
public ByteArrayBuilder(int capacity)

Create an empty buffer of a defined initial capacity.

Parameters
capacity:int

initially

ByteArrayBuilderback to summary
public ByteArrayBuilder()

Create an empty buffer of a default initial capacity.

Method Detail

appendback to summary
public void append(byte[] b, int off, int n)

Append a specified number of bytes from a given offset in a byte array.

Parameters
b:byte[]

the value

off:int

index of the first byte written

n:int

number of bytes to write

appendIntBEback to summary
public void appendIntBE(int v)

Append the 4 bytes of a int value big-endian.

Parameters
v:int

the value

appendIntLEback to summary
public void appendIntLE(int v)

Append the 4 bytes of a int value little-endian.

Parameters
v:int

the value

appendLongBEback to summary
public void appendLongBE(long v)

Append the 8 bytes of a long value big-endian.

Parameters
v:long

the value

appendLongLEback to summary
public void appendLongLE(long v)

Append the 8 bytes of a long value little-endian.

Parameters
v:long

the value

appendShortBEback to summary
public void appendShortBE(int v)

Append the 2 bytes of a short value big-endian.

Parameters
v:int

the value

appendShortLEback to summary
public void appendShortLE(int v)

Append the 2 bytes of a short value little-endian.

Parameters
v:int

the value

appendUncheckedback to summary
protected void appendUnchecked(int v)

Implements abstract org.python.core.stringlib.AbstractIntArrayBuilder.Forward.appendUnchecked.

Doc from org.python.core.stringlib.AbstractIntArrayBuilder.Forward.appendUnchecked.

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(int) has been called.

Parameters
v:int

to append

Annotations
@Override
ensureback to summary
protected void ensure(int n)

Implements abstract org.python.core.stringlib.AbstractIntArrayBuilder.ensure.

Ensure there is room for another n elements.

Parameters
n:int

to make space for

Annotations
@Override
lengthback to summary
public int length()

Implements abstract org.python.core.stringlib.AbstractIntArrayBuilder.length.

Doc from org.python.core.stringlib.AbstractIntArrayBuilder.length.

The number of elements currently

Returns:int

the number of elements currently.

Annotations
@Override
maxback to summary
public int max()

Implements abstract org.python.core.stringlib.AbstractIntArrayBuilder.max.

Doc from org.python.core.stringlib.AbstractIntArrayBuilder.max.

The maximum value stored.

Returns:int

The maximum int stored.

Annotations
@Override
takeback to summary
public byte[] take()

Implements abstract org.python.core.stringlib.AbstractIntArrayBuilder.take.

Doc from org.python.core.stringlib.AbstractIntArrayBuilder.take.

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, int[] or byte[]).

Returns:byte[]

the contents as a Python str

Annotations
@Override
valueback to summary
protected int[] value()

Implements abstract org.python.core.stringlib.AbstractIntArrayBuilder.value.

Doc from org.python.core.stringlib.AbstractIntArrayBuilder.value.

An array of the elements in the buffer (not modified by methods on this object hereafter).

Returns:int[]

the elements in the buffer

Annotations
@Override