public class ByteArrayWrapper extends java.lang.Object implements java.lang.Comparable<ByteArrayWrapper>
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 |
|---|---|
byte[] |
bytes
Internal byte array.
|
int |
size
Size of the internal byte array used.
|
| Constructor and Description |
|---|
ByteArrayWrapper()
Construct a new ByteArrayWrapper with no data.
|
ByteArrayWrapper(byte[] bytesToAdopt,
int size)
Construct a new ByteArrayWrapper from a byte array and size
|
ByteArrayWrapper(java.nio.ByteBuffer source)
Construct a new ByteArrayWrapper from the contents of a ByteBuffer.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
int |
compareTo(ByteArrayWrapper other)
Compare this object to another ByteArrayWrapper, which must not be null.
|
ByteArrayWrapper |
ensureCapacity(int capacity)
Ensure that the internal byte array is at least of length capacity.
|
boolean |
equals(java.lang.Object other)
Return true if the bytes in each wrapper are equal.
|
int |
hashCode()
Return the hashcode.
|
byte[] |
releaseBytes()
Releases the internal byte array to the caller, resets the internal
byte array to null and its size to 0.
|
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.
|
java.lang.String |
toString()
Returns string value for debugging
|
public byte[] bytes
public int size
public ByteArrayWrapper()
public ByteArrayWrapper(byte[] bytesToAdopt,
int size)
bytesToAdopt - the byte array to adoptsize - the length of valid data in the byte arrayjava.lang.IndexOutOfBoundsException - if bytesToAdopt == null and size != 0, or
size < 0, or size > bytesToAdopt.length.public ByteArrayWrapper(java.nio.ByteBuffer source)
source - the ByteBuffer from which to get the data.public ByteArrayWrapper ensureCapacity(int capacity)
capacity - minimum length of internal byte array.public final ByteArrayWrapper set(byte[] src, int start, int limit)
src - source byte array to copy fromstart - start offset of src to copy fromlimit - end + 1 offset of src to copy frompublic final ByteArrayWrapper append(byte[] src, int start, int limit)
src - source byte array to copy fromstart - start offset of src to copy fromlimit - end + 1 offset of src to copy frompublic final byte[] releaseBytes()
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object other)
equals in class java.lang.Objectother - the object to compare to.public int hashCode()
hashCode in class java.lang.Objectpublic int compareTo(ByteArrayWrapper other)
compareTo in interface java.lang.Comparable<ByteArrayWrapper>other - the object to compare to.java.lang.ClassCastException - if the other object is not a ByteArrayWrapperCopyright © 2016 Unicode, Inc. and others.