Generally passed as an argument object into a method. The method takes responsibility of writing into the internal byte array and increasing its size when necessary.
| Modifier and Type | Field and Description |
|---|---|
| public byte[] | bytes
Internal byte array. |
| public int | size
Size of the internal byte array used. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | ByteArrayWrapper(byte[]
the byte array to adopt bytesToAdopt, int the length of valid data in the byte array size)Construct a new ByteArrayWrapper from a byte array and size |
| public | ByteArrayWrapper(ByteBuffer
the ByteBuffer from which to get the data. source)Construct a new ByteArrayWrapper from the contents of a ByteBuffer. |
| Modifier and Type | Method and Description |
|---|---|
| public final ByteArrayWrapper | Returns: this ByteArrayWrappersource byte array to copy from src, int start offset of src to copy from start, int end + 1 offset of src to copy from limit)Appends the internal byte array from offset size with the contents of src from offset start to limit. |
| public int | Returns: a value <0, 0, or >0 as this compares less than, equal to, or greater than other.the object to compare to. other)Implements java. |
| private static final void | copyBytes(byte[]
source byte array to copy from src, int start offset of src to copy from srcoff, byte[] target byte array to copy to tgt, int start offset of tgt to copy to tgtoff, int size of contents to copy length)Copies the contents of src byte array from offset srcoff to the target of tgt byte array at the offset tgtoff. |
| public ByteArrayWrapper | Returns: this ByteArrayWrapperminimum length of internal byte array. capacity)Ensure that the internal byte array is at least of length capacity. |
| public boolean | Returns: true if the two objects are equal.the object to compare to. other)Overrides java. |
| public int | |
| public final byte[] | Returns: internal byte array.Releases the internal byte array to the caller, resets the internal byte array to null and its size to 0. |
| public final ByteArrayWrapper | Returns: this ByteArrayWrappersource byte array to copy from src, int start offset of src to copy from start, int end + 1 offset of src to copy from limit)Set the internal byte array from offset 0 to (limit - start) with the contents of src from offset start to limit. |
| public String |
| bytes | back to summary |
|---|---|
| public byte[] bytes Internal byte array.
| |
| size | back to summary |
|---|---|
| public int size Size of the internal byte array used. Different from bytes.length, size will be <= bytes.length. Semantics of size is similar to java.util.Vector.size().
| |
| ByteArrayWrapper | back to summary |
|---|---|
| public ByteArrayWrapper() Construct a new ByteArrayWrapper with no data.
| |
| ByteArrayWrapper | back to summary |
|---|---|
| public ByteArrayWrapper(byte[] bytesToAdopt, int size) Construct a new ByteArrayWrapper from a byte array and size
| |
| ByteArrayWrapper | back to summary |
|---|---|
| public ByteArrayWrapper(ByteBuffer source) Construct a new ByteArrayWrapper from the contents of a ByteBuffer.
| |
| append | back to summary |
|---|---|
| public final ByteArrayWrapper append(byte[] src, int start, int limit) Appends the internal byte array from offset size with the contents of src from offset start to limit. This increases the size of the internal byte array to (size + limit - start).
| |
| compareTo | back to summary |
|---|---|
| public int compareTo(ByteArrayWrapper other) Implements java. Compare this object to another ByteArrayWrapper, which must not be null.
| |
| copyBytes | back to summary |
|---|---|
| private static final void copyBytes(byte[] src, int srcoff, byte[] tgt, int tgtoff, int length) Copies the contents of src byte array from offset srcoff to the target of tgt byte array at the offset tgtoff.
| |
| ensureCapacity | back to summary |
|---|---|
| public ByteArrayWrapper ensureCapacity(int capacity) Ensure that the internal byte array is at least of length capacity. If the byte array is null or its length is less than capacity, a new byte array of length capacity will be allocated. The contents of the array (between 0 and size) remain unchanged.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Return true if the bytes in each wrapper are equal. | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Return the hashcode. | |
| releaseBytes | back to summary |
|---|---|
| public final byte[] releaseBytes() Releases the internal byte array to the caller, resets the internal byte array to null and its size to 0.
| |
| set | back to summary |
|---|---|
| public final ByteArrayWrapper set(byte[] src, int start, int limit) Set the internal byte array from offset 0 to (limit - start) with the contents of src from offset start to limit. If the byte array is null or its length is less than capacity, a new byte array of length (limit - start) will be allocated. This resets the size of the internal byte array to (limit - start).
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns string value for debugging
| |