: Class ArrayUtils

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.dalsemi.system
Class ArrayUtils

    java.lang.Object
      |
      +--com.dalsemi.system.ArrayUtils

public class ArrayUtils
extends Object

This class implements methods to manage arrays. This includes comparison, copying, filling and inserting and removing simple data types into byte arrays. Simple data types are stored in byte arrays in big-endian format.

Method Summary
`static boolean` | `arrayComp(Object array1, int offset1, Object arayr2, 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`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### arraycopy

    public 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`. 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.
  Parameters:
    `src` - source array
    `src_position` - starting index in source array
    `dst` - target array
    `dst_position` - starting index in target array
    `length` - number of elements to copy
  Returns:
    0 under normal operation. If both `dst` and `src` are arrays of references, and are not the same type, returns -1.

### arrayCopyUnequal

    public 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`.
  If the destination element has more bytes than the source element, the upper bytes of each element are set to zero.
  If the destination element has less bytes than the source element, the upper bytes are truncated.
  Parameters:
    `fromArray` - source array
    `fromIndex` - starting index in source array
    `toArray` - target array
    `toIndex` - starting index in target array
    `length` - number of elements to copy

### arrayComp

    public static boolean arrayComp(Object array1,
                                    int offset1,
                                    Object arayr2,
                                    int offset2,
                                    int length)

  Compares `length` elements in `array1` at `offset1` with the elements in `array2` at `offset2`.
  Parameters:
    `array1` - source array
    `offset1` - starting index in source array
    `array2` - target array
    `offset2` - starting index in target array
    `length` - number of elements to compare
  Returns:
    false if all elements are not the same

### arrayFill

    public static void arrayFill(byte[] thisArray,
                                 int fromIndex,
                                 int toIndex,
                                 byte fillValue)

  Fills `thisArray` from `fromIndex` to `toIndex` with `fillValue`.
  Parameters:
    `thisArray` - target array
    `fromIndex` - starting index for fill
    `toIndex` - ending index for fill
    `fillValue` - value to fill array

### setShort

    public static byte[] setShort(byte[] thisArray,
                                  int offset,
                                  short value)

  Writes a short value `value` to byte array `thisArray` starting at offset `offset`. The values are stored in the array in Big Endian form.
  Parameters:
    `thisArray` - array that will be modified
    `offset` - starting offset
    `value` - value to be written
  Returns:
    array reference to `thisArray`

### setInt

    public static byte[] setInt(byte[] thisArray,
                                int offset,
                                int value)

  Writes an int value `value` to byte array `thisArray` starting at offset `offset`. The values are stored in the array in Big Endian form.
  Parameters:
    `thisArray` - array that will be modified
    `offset` - starting offset
    `value` - value to be written
  Returns:
    array reference to `thisArray`

### setLong

    public static byte[] setLong(byte[] thisArray,
                                 int offset,
                                 long value)

  Writes a long value `value` to byte array `thisArray` starting at offset `offset`. The values are stored in the array in Big Endian form.
  Parameters:
    `thisArray` - array that will be modified
    `offset` - starting offset
    `value` - value to be written
  Returns:
    array reference to `thisArray`

### getShort

    public static short getShort(byte[] thisArray,
                                 int offset)

  Reads a short value from a byte array. The values extracted are assumed to be in Big Endian Form.
  Parameters:
    `thisArray` - array containing the value
    `offset` - starting offset
  Returns:
    value read

### getInt

    public static int getInt(byte[] thisArray,
                             int offset)

  Reads an int value from a byte array. The values extracted are assumed to be in Big Endian Form.
  Parameters:
    `thisArray` - array containing the value
    `offset` - starting offset
  Returns:
    value read

### getLong

    public static long getLong(byte[] thisArray,
                               int offset)

  Reads a long value from a byte array. The values extracted are assumed to be in Big Endian Form.
  Parameters:
    `thisArray` - array containing the value
    `offset` - starting offset
  Returns:
    value read

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD