public class ArrayUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
arrayComp(Object array1,
int offset1,
Object array2,
int offset2,
int length)
Compares
length elements in array1 at offset1 with the elements in
array2 at offset2. |
static int |
arraycopy(Object src,
int src_position,
Object dst,
int dst_position,
int length)
Copies
length elements from the src array at index src_position to the
dst array at index dst_position. |
static void |
arrayCopyUnequal(Object fromArray,
int fromOffset,
Object toArray,
int toOffset,
int length)
Copies
length common lower element bytes from fromArray at fromOffset into
toArray at toOffset. |
static void |
arrayFill(byte[] thisArray,
int fromIndex,
int toIndex,
byte fillValue)
Fills
thisArray from fromIndex to toIndex with fillValue. |
static int |
getInt(byte[] thisArray,
int offset)
Reads an int value from a byte array.
|
static long |
getLong(byte[] thisArray,
int offset)
Reads a long value from a byte array.
|
static short |
getShort(byte[] thisArray,
int offset)
Reads a short value from a byte array.
|
static byte[] |
setInt(byte[] thisArray,
int offset,
int value)
Writes an int value
value to byte array thisArray starting at offset offset. |
static byte[] |
setLong(byte[] thisArray,
int offset,
long value)
Writes a long value
value to byte array thisArray starting at offset offset. |
static byte[] |
setShort(byte[] thisArray,
int offset,
short value)
Writes a short value
value to byte array thisArray starting at offset offset. |
static int |
swapEndian(int value)
Reverses the byte order of a value.
|
static long |
swapEndian(long value)
Reverses the byte order of a value.
|
static short |
swapEndian(short value)
Reverses the byte order of a value.
|
public static int arraycopy(Object src, int src_position, Object dst, int dst_position, int length)
length elements from the src array at index src_position to the
dst array at index dst_position. The src and dst arrays must be of
the same type. This is similar to java.lang.System.arraycopy(), but more restrictive. This allows it to be
slightly faster, and calls one less method than the same array copy performed through the java.lang.System
class.src - source arraysrc_position - starting index in source arraydst - target arraydst_position - starting index in target arraylength - number of elements to copydst and src are arrays of references, and are not the
same type, returns -1.public static void arrayCopyUnequal(Object fromArray, int fromOffset, Object toArray, int toOffset, int length)
length common lower element bytes from fromArray at fromOffset into
toArray at toOffset. fromArray - source arrayfromOffset - starting index in source arraytoArray - target arraytoOffset - starting index in target arraylength - number of elements to copypublic static boolean arrayComp(Object array1, int offset1, Object array2, int offset2, int length)
length elements in array1 at offset1 with the elements in
array2 at offset2.array1 - source arrayoffset1 - starting index in source arrayarray2 - target arrayoffset2 - starting index in target arraylength - number of elements to comparepublic static void arrayFill(byte[] thisArray,
int fromIndex,
int toIndex,
byte fillValue)
thisArray from fromIndex to toIndex with fillValue.thisArray - target arrayfromIndex - starting index for fill, inclusivetoIndex - ending index for fill, exclusivefillValue - value to fill arraypublic static byte[] setShort(byte[] thisArray,
int offset,
short value)
value to byte array thisArray starting at offset offset. The
values are stored in the array in Big Endian form.thisArray - array that will be modifiedoffset - starting offsetvalue - value to be writtenthisArraypublic static byte[] setInt(byte[] thisArray,
int offset,
int value)
value to byte array thisArray starting at offset offset. The
values are stored in the array in Big Endian form.thisArray - array that will be modifiedoffset - starting offsetvalue - value to be writtenthisArraypublic static byte[] setLong(byte[] thisArray,
int offset,
long value)
value to byte array thisArray starting at offset offset. The
values are stored in the array in Big Endian form.thisArray - array that will be modifiedoffset - starting offsetvalue - value to be writtenthisArraypublic static short getShort(byte[] thisArray,
int offset)
thisArray - array containing the valueoffset - starting offsetpublic static int getInt(byte[] thisArray,
int offset)
thisArray - array containing the valueoffset - starting offsetpublic static long getLong(byte[] thisArray,
int offset)
thisArray - array containing the valueoffset - starting offsetpublic static short swapEndian(short value)
value - short value (2 bytes)public static int swapEndian(int value)
value - int value (4 bytes)public static long swapEndian(long value)
value - long value (8 bytes)