|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--danger.util.ByteArray
Utilities for accessing instances of byte[]. Note: Many of
these methods are performed in native code on a device.
| Field Summary | |
static char |
UNICODE_REPLACEMENT_CHARACTER
standard Unicode replacement character for bogus data |
| Method Summary | |
static int |
compareTo(byte[] bytesA,
int offsetA,
int lenA,
byte[] bytesB,
int offsetB,
int lenB)
Compare two ranges of bytes in arrays, returning one of {-1,
0, 1} to indicate whether (respectively) the first is "less
than," "equal to," or "greater than" the second. |
static boolean |
contains(byte[] bytes,
int offset,
int len,
byte[] key)
|
static boolean |
containsIgnoreCase(byte[] bytes,
int offset,
int len,
byte[] keyUpperCase)
|
static int |
decodeUtf8Char(byte[] bytes,
int index,
int maxIndex)
Decode a UTF-8 character from the given byte array at the given index, but not using bytes at or beyond the given maximum index. |
static boolean |
equals(byte[] bytesA,
byte[] bytesB)
Compare two instances of byte[] for equality. |
static int |
readInt(byte[] bytes,
int offset)
Read an int out of a byte[] at the given
offset, in little-endian form (that is, low-order byte first). |
static int |
readShort(byte[] bytes,
int offset)
Read a short out of a byte[] at the given
offset, in little-endian form (that is, low-order byte first). |
static boolean |
startsWith(byte[] bytes,
int offset,
int len,
byte[] key)
|
static boolean |
startsWithIgnoreCase(byte[] bytes,
int offset,
int len,
byte[] key)
|
static void |
writeInt(byte[] bytes,
int offset,
int value)
Write an int to byte[] at the given
offset, in little-endian form (that is, low-order byte first). |
static void |
writeShort(byte[] bytes,
int offset,
int value)
Write a short to byte[] at the given
offset, in little-endian form (that is, low-order byte first). |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final char UNICODE_REPLACEMENT_CHARACTER
| Method Detail |
public static int readInt(byte[] bytes,
int offset)
int out of a byte[] at the given
offset, in little-endian form (that is, low-order byte first).bytes - non-null; the array to read fromoffset - the offset to start reading atintArrayIndexOutOfBoundsException - thrown if offset
is out of rangejava.lang.NullPointerException - thrown of bytes is
passed as null
public static int readShort(byte[] bytes,
int offset)
short out of a byte[] at the given
offset, in little-endian form (that is, low-order byte first).bytes - non-null; the array to read fromoffset - the offset to start reading atshortArrayIndexOutOfBoundsException - thrown if offset
is out of rangejava.lang.NullPointerException - thrown of bytes is
passed as null
public static void writeInt(byte[] bytes,
int offset,
int value)
int to byte[] at the given
offset, in little-endian form (that is, low-order byte first).
If the offset is out of range, then an exception is thrown and
the array is left unaltered.bytes - non-null; the array to store intooffset - the offset to start storing atvalue - the value to storeArrayIndexOutOfBoundsException - thrown if offset
is out of rangejava.lang.NullPointerException - thrown of bytes is
passed as null
public static void writeShort(byte[] bytes,
int offset,
int value)
short to byte[] at the given
offset, in little-endian form (that is, low-order byte first).
If the offset is out of range, then an exception is thrown and
the array is left unaltered.bytes - non-null; the array to store intooffset - the offset to start storing atvalue - the value to storeArrayIndexOutOfBoundsException - thrown if offset
is out of rangejava.lang.NullPointerException - thrown of bytes is
passed as null
public static int compareTo(byte[] bytesA,
int offsetA,
int lenA,
byte[] bytesB,
int offsetB,
int lenB)
{-1,
0, 1} to indicate whether (respectively) the first is "less
than," "equal to," or "greater than" the second. If one of the
arrays is passed as null, then it is considered to be
"less than" the other, unless the other one is also
null, in which case the two are considered equal.
Otherwise, corresponding bytes are compared, starting from early
offsets, up to the smaller of the two lengths passed. Whichever array
contains a byte that is smaller than the other is considered "less
than" the other. If all bytes compared are equal, then the range
with the smaller length is considered "less than" the other. If the
two lengths are the same, then the ranges are considered "equal."bytesA - null-ok; an array to compareoffsetA - the offset to start at in bytesAlenA - the number of bytes in the range in bytesAbytesB - null-ok; another array to compareoffsetB - the offset to start at in bytesBlenB - the number of bytes in the range in bytesB{-1, 0, 1} to indicate whether
(respectively) the first range is "less than," "equal to," or
"greater than" the secondArrayIndexOutOfBoundsException - thrown if the arguments
end up demanding that an out-of-range element be accessed
public static boolean equals(byte[] bytesA,
byte[] bytesB)
byte[] for equality. They
are considered equal if either: both are null; both
are non-null, of the same length, and with equal
contents.bytesA - null-ok; an array to comparebytesB - null-ok; an array to compare it totrue if and only if the two arrays are considered
"equal" to each other
public static boolean startsWith(byte[] bytes,
int offset,
int len,
byte[] key)
public static boolean startsWithIgnoreCase(byte[] bytes,
int offset,
int len,
byte[] key)
public static boolean contains(byte[] bytes,
int offset,
int len,
byte[] key)
public static boolean containsIgnoreCase(byte[] bytes,
int offset,
int len,
byte[] keyUpperCase)
public static int decodeUtf8Char(byte[] bytes,
int index,
int maxIndex)
Note: This decodes in exactly the same way that String
decodes, including error cases.
bytes - non-null; bytes to decode fromindex - the start index for the charactermaxIndex - the limit of decoding (exclusive)(bytesConsumed << 16) | decodedCharacter
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||