|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.util.ByteArray
A ByteArray is a utility class that represents a number of data bytes. It is generally used as a buffer for data storage.
Associated with the ByteArray is a byte [] value called "data" which holds the data bytes (starting from index 0) and the "length" variable specifies how many of those bytes are considered valid (which may be less than the actual length of the data variable).
| Field Summary | |
byte[] |
data
The data bytes. |
int |
length
The number of valid bytes in the data. |
| Constructor Summary | |
ByteArray()
|
|
ByteArray(byte[] data)
This will actually use the "data" byte array as the data for the byte array. |
|
| Method Summary | |
void |
append(byte data)
Append a single byte of data. |
void |
append(byte[] src,
int start,
int length)
Add bytes to the end of the ByteArray. |
void |
appendInt(int value)
Append a four-byte integer value. |
void |
appendInt(int value,
int numBytes)
Append an integer value as up to four bytes in big-endian format. |
void |
appendLong(long value)
Append a long value as eight bytes in big-endian format. |
void |
clear()
This sets the length of the array back to zero without releasing the data bytes. |
void |
copyFrom(byte[] data)
Copy the bytes from the supplied array, re-using the interal byte array if possible. |
void |
copyFrom(byte[] data,
int offset,
int length)
Copy the bytes from the supplied array, re-using the interal byte array if possible. |
boolean |
delete(int where,
int numBytes)
This removes bytes from within the data. |
Object |
getCopy()
Get a copy of this ByteArray with its own copy of this data. |
void |
insert(int where,
byte[] src,
int start,
int length)
Insert bytes into the ByteArray. |
void |
insertInt(int where,
int value,
int numBytes)
Insert an integer value as up to four bytes in big-endian format. |
void |
insertLong(int where,
long value)
Insert a long value as eight bytes in big-endian format. |
boolean |
makeSpace(int where,
int numBytes)
This adds space to the ByteArray at the specified index, increasing the length value by numBytes. |
void |
setLength(int len)
This sets the length of the valid data within the array, but does NOT extend OR truncate the array. |
byte[] |
toBytes()
Return a copy of the data in the ByteArray as a byte array of the exact length of the data. |
void |
write(int where,
byte[] src,
int start,
int length)
This writes into the data at the specific location. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, toString |
| Field Detail |
public byte[] data
public int length
| Constructor Detail |
public ByteArray()
public ByteArray(byte[] data)
| Method Detail |
public Object getCopy()
getCopy in interface Copyable
public boolean makeSpace(int where,
int numBytes)
public void write(int where,
byte[] src,
int start,
int length)
public void insert(int where,
byte[] src,
int start,
int length)
where - The index in this ByteArray where the data will go.src - The source data bytes.start - The start index in the source data.length - The number of bytes to copy.
public void append(byte[] src,
int start,
int length)
src - The source data bytes.start - The start index in the source data.length - The number of bytes to copy.public void append(byte data)
data - The byte to append.
public void insertInt(int where,
int value,
int numBytes)
where - the index at which to insert the integer.value - the value to insert.numBytes - the number of bytes (starting from the least significant) to insert.
public void appendInt(int value,
int numBytes)
value - the value to append.numBytes - the number of bytes (starting from the least significant) to insert.public void appendInt(int value)
value - the value to append.
public void insertLong(int where,
long value)
where - the index at which to insert the integer.value - the value to insert.public void appendLong(long value)
value - the value to append.
public boolean delete(int where,
int numBytes)
public void clear()
public void setLength(int len)
public byte[] toBytes()
public void copyFrom(byte[] data,
int offset,
int length)
public void copyFrom(byte[] data)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||