public class ByteArray extends Object implements Serializable, Comparable<ByteArray>
| Constructor and Description |
|---|
ByteArray()
Creates an empty ByteArray.
|
ByteArray(byte[] data)
Sets valid = data.length, unless data is null
Sets offset = 0
|
ByteArray(byte[] data,
int offset,
int length)
Sets offset = offset
Sets valid = length
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(ByteArray ba) |
boolean |
equals(Object o) |
byte[] |
getData()
Returns the underlying byte array.
|
int |
getOffset()
Returns the offset into the byte array.
|
int |
getValid()
Count how many of the bytes in the array are 'valid'.
|
int |
hashCode() |
void |
setData(byte[] data)
Sets the underlying byte array.
|
void |
setOffset(int offset)
Sets the offset into the byte array.
|
void |
setValid(int valid)
Sets the number of valid bytes.
|
String |
toBase64()
Returns this ByteArray as a Base64 encoded string.
|
String |
toString() |
public ByteArray()
public ByteArray(byte[] data)
data - the byte array, may be nullpublic ByteArray(byte[] data,
int offset,
int length)
data - the byte array, may be null but why would you do thatoffset - the starting offsetlength - the valid lengthpublic final int compareTo(ByteArray ba)
compareTo in interface Comparable<ByteArray>public byte[] getData()
public int getOffset()
public int getValid()
public void setData(byte[] data)
data - the new byte arraypublic void setOffset(int offset)
offset - the new offsetpublic void setValid(int valid)
valid - the new valid countpublic final String toBase64()