|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.android.dx.util.ByteArray
public final class ByteArray
Wrapper for a byte[], which provides read-only access and
can "reveal" a partial slice of the underlying array.
Note: Multibyte accessors all use big-endian order.
| Nested Class Summary | |
|---|---|
static interface |
ByteArray.GetCursor
Helper interface that allows one to get the cursor (of a stream). |
static class |
ByteArray.MyDataInputStream
Helper class for makeDataInputStream(). |
class |
ByteArray.MyInputStream
Helper class for makeInputStream(), which implements the
stream functionality. |
| Constructor Summary | |
|---|---|
ByteArray(byte[] bytes)
Constructs an instance from an entire byte[]. |
|
ByteArray(byte[] bytes,
int start,
int end)
Constructs an instance. |
|
| Method Summary | |
|---|---|
int |
getByte(int off)
Gets the signed byte value at a particular offset. |
void |
getBytes(byte[] out,
int offset)
Copies the contents of this instance into the given raw byte[] at the given offset. |
int |
getInt(int off)
Gets the signed int value at a particular offset. |
long |
getLong(int off)
Gets the signed long value at a particular offset. |
int |
getShort(int off)
Gets the signed short value at a particular offset. |
int |
getUnsignedByte(int off)
Gets the unsigned byte value at a particular offset. |
int |
getUnsignedShort(int off)
Gets the unsigned short value at a particular offset. |
ByteArray.MyDataInputStream |
makeDataInputStream()
Gets a DataInputStream that reads from this instance,
with the cursor starting at the beginning of this instance's data. |
ByteArray.MyInputStream |
makeInputStream()
Gets a InputStream that reads from this instance,
with the cursor starting at the beginning of this instance's data. |
int |
size()
Gets the size of the array, in bytes. |
ByteArray |
slice(int start,
int end)
Returns a slice (that is, a sub-array) of this instance. |
int |
underlyingOffset(int offset,
byte[] bytes)
Returns the offset into the given array represented by the given offset into this instance. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ByteArray(byte[] bytes,
int start,
int end)
bytes - non-null; the underlying arraystart - >= 0; start index of the slice (inclusive)end - >= start, <= bytes.length; end index of
the slice (exclusive)public ByteArray(byte[] bytes)
byte[].
bytes - non-null; the underlying array| Method Detail |
|---|
public int size()
>= 0; the size
public ByteArray slice(int start,
int end)
start - >= 0; start index of the slice (inclusive)end - >= start, <= size(); end index of
the slice (exclusive)
non-null; the slice
public int underlyingOffset(int offset,
byte[] bytes)
offset - offset into this instancebytes - non-null; (alleged) underlying array
bytes
IllegalArgumentException - thrown if bytes is
not the underlying array of this instancepublic int getByte(int off)
signed byte value at a particular offset.
off - >= 0, < size(); offset to fetch
signed byte at that offsetpublic int getShort(int off)
signed short value at a particular offset.
off - >= 0, < (size() - 1); offset to fetch
signed short at that offsetpublic int getInt(int off)
signed int value at a particular offset.
off - >= 0, < (size() - 3); offset to fetch
signed int at that offsetpublic long getLong(int off)
signed long value at a particular offset.
off - >= 0, < (size() - 7); offset to fetch
signed int at that offsetpublic int getUnsignedByte(int off)
unsigned byte value at a particular offset.
off - >= 0, < size(); offset to fetch
unsigned byte at that offsetpublic int getUnsignedShort(int off)
unsigned short value at a particular offset.
off - >= 0, < (size() - 1); offset to fetch
unsigned short at that offset
public void getBytes(byte[] out,
int offset)
byte[] at the given offset. The given array must be
large enough.
out - non-null; array to hold the outputoffset - non-null; index into out for the first
byte of outputpublic ByteArray.MyDataInputStream makeDataInputStream()
DataInputStream that reads from this instance,
with the cursor starting at the beginning of this instance's data.
Note: The returned instance may be cast to #GetCursor
if needed.
non-null; an appropriately-constructed
DataInputStream instancepublic ByteArray.MyInputStream makeInputStream()
InputStream that reads from this instance,
with the cursor starting at the beginning of this instance's data.
Note: The returned instance may be cast to #GetCursor
if needed.
non-null; an appropriately-constructed
InputStream instancex
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||