|
Bees v0.5.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--bees.core.ByteArray
Wrapper for an array of Bytes. Incorporates offset and length.
Most of the methods in here are final for performance reasons.
Field Summary | |
byte[] |
buf
The actual byte array this object wraps. |
int |
len
The length of the byte array in `buf' that this object wraps. |
int |
offset
The start of the byte array in `buf' that this object wraps. |
Constructor Summary | |
ByteArray(byte[] buf)
Construct a new ByteArray object that wraps the given array. |
|
ByteArray(byte[] buf,
int offset)
Construct a new ByteArray object that wraps the given array. |
|
ByteArray(byte[] buf,
int offset,
int len)
Construct a new ByteArray object that wraps the given array. |
|
ByteArray(ByteArray parent,
int offset)
Construct a new ByteArray object that wraps the byte array encapsulated by another ByteArray object. |
|
ByteArray(ByteArray parent,
int offset,
int len)
Construct a new ByteArray object that wraps the byte array encapsulated by another ByteArray object. |
|
ByteArray(int len)
Construct a new ByteArray object that has the given length. |
Method Summary | |
static byte[] |
concat(byte[][] ba)
Concatenate an array of byte arrays together. |
static byte[] |
concat(byte[] ba1,
byte[] ba2)
Concatenate two byte arrays together. |
static byte[] |
fromFile(File file)
Create a byte array from the contents of the given file. |
byte |
getByte(int index)
|
void |
getBytes(int srcBegin,
byte[] dst,
int dstBegin,
int length)
Copy a range of bytes from the array into a basic byte array. |
int |
length()
|
void |
setByte(int index,
byte val)
|
void |
setBytes(int dstBegin,
byte[] src,
int srcBegin,
int length)
Copy a range of bytes to the array from a basic byte array. |
void |
setBytes(int dstBegin,
ByteArray src,
int srcBegin,
int length)
Copy a range of bytes to the array from another byte array. |
byte[] |
toBytes()
Returns a byte array exactly the right size for the valid data in the buf. |
static void |
toFile(File file,
byte[] bits)
Write the given byte array to the given file. |
static java.lang.String |
toPlainString(byte[] bytes)
Convert a byte array to a string in a hexidecimal representation. |
static java.lang.String |
toPlainString(byte[] bytes,
int maxBytes)
Convert a byte array to a string in a hexidecimal representation. |
java.lang.String |
toString()
|
static java.lang.String |
toString(byte[] bytes)
Convert a byte array to a string in a hexidecimal representation and some extra formatting. |
static java.lang.String |
toString(byte[] bytes,
int maxBytes)
Convert a byte array to a string in a hexidecimal representation and some extra formatting. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public byte[] buf
public int offset
public int len
Constructor Detail |
public ByteArray(int len)
len
- The length of the internal byte array to create.public ByteArray(byte[] buf)
buf
- The byte array to wrap.public ByteArray(byte[] buf, int offset)
buf
- The byte array to wrap.offset
- The start of the byte array in `buf' that this object
should wrap.public ByteArray(byte[] buf, int offset, int len) throws java.lang.IndexOutOfBoundsException
buf
- The byte array to wrap.offset
- The start of the byte array in `buf' that this object
should wrap.len
- The length of the byte array in `buf' that this object
should wrap.java.lang.IndexOutOfBoundsException
- if the given range is outside the
given buffer.public ByteArray(ByteArray parent, int offset)
parent
- The ByteArray object that contains the byte array to
rewrap.offset
- An extra offset to add to the parent's offset.public ByteArray(ByteArray parent, int offset, int len) throws java.lang.IndexOutOfBoundsException
parent
- The ByteArray object that contains the byte array to
rewrap.offset
- An extra offset to add to the parent's offset.len
- The length of the wrapped byte array.java.lang.IndexOutOfBoundsException
- if the given range is outside the
given buffer.Method Detail |
public final int length()
public final byte getByte(int index) throws java.lang.IndexOutOfBoundsException
index
- The index of the byte to return.java.lang.IndexOutOfBoundsException
- if `index' is out of
bounds of the array.public final void setByte(int index, byte val) throws java.lang.IndexOutOfBoundsException
index
- The index of the byte to return.val
- The byte to put at the given index in the array.java.lang.IndexOutOfBoundsException
- if `index' is out of
bounds of the array.public final void getBytes(int srcBegin, byte[] dst, int dstBegin, int length)
srcBegin
- The offset into the byte array to start copying bytes.dst
- The array to copy the bytes into.dstBegin
- The offset in `dst' to start copying.length
- The number of bytes to copy from the array.public final void setBytes(int dstBegin, byte[] src, int srcBegin, int length)
dstBegin
- The offset into the byte array to start copying bytes.src
- The array to copy the bytes from.srcBegin
- The offset in `src' to start copying bytes.length
- The number of bytes to copy to the array.public final void setBytes(int dstBegin, ByteArray src, int srcBegin, int length)
dstBegin
- The offset into the byte array to start copying bytes.src
- The array to copy the bytes from.srcBegin
- The offset in `src' to start copying bytes.length
- The number of bytes to copy to the array.public final byte[] toBytes()
public static final byte[] fromFile(File file) throws java.io.FileNotFoundException, java.io.IOException
file
- The file capability to read from.java.io.FileNotFoundException
- if the file couldn't be found.
XXX This "shouldn't" happen since we have a capability to it.java.io.IOException
- if there is an error reading the file.public static final void toFile(File file, byte[] bits) throws java.io.FileNotFoundException, java.io.IOException
file
- The file capability to write to.bits
- The byte array to write to the file.java.io.FileNotFoundException
- if the file couldn't be found.
XXX This "shouldn't" happen since we have a capability to it.java.io.IOException
- if there is an error writing the file.public static final byte[] concat(byte[][] ba)
ba
- The array of arrays to concatenate. Any null elements will
be ignored.public static final byte[] concat(byte[] ba1, byte[] ba2)
ba1
- The first byte array.ba2
- The second byte array.public static final java.lang.String toPlainString(byte[] bytes, int maxBytes)
bytes
- The byte array to format.maxBytes
- The maximum number of bytes to format.public static final java.lang.String toPlainString(byte[] bytes)
bytes
- The byte array to format.public static final java.lang.String toString(byte[] bytes, int maxBytes)
bytes
- The bytes to turn into a string.maxBytes
- The maximum number of bytes to format.public static final java.lang.String toString(byte[] bytes)
bytes
- The bytes to turn into a string.public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
|
Bees v0.5.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |