ArrayHelper

public final class ArrayHelper
extends Object

java.lang.Object
   ↳ com.android.ddmlib.utils.ArrayHelper


Utility class providing array to int/long conversion for data received from devices through adb.

Summary

Public constructors

ArrayHelper()

Public methods

static int swap32bitFromArray(byte[] value, int offset)

Reads a signed 32 bit integer from an array coming from a device.

static void swap32bitsToArray(int value, byte[] dest, int offset)

Swaps an unsigned value around, and puts the result in an array that can be sent to a device.

static long swap64bitFromArray(byte[] value, int offset)

Reads a signed 64 bit integer from an array coming from a device.

static int swapU16bitFromArray(byte[] value, int offset)

Reads an unsigned 16 bit integer from an array coming from a device, and returns it as an 'int'

Public constructors

ArrayHelper

public ArrayHelper ()

Public methods

swap32bitFromArray

public static int swap32bitFromArray (byte[] value, 
                int offset)

Reads a signed 32 bit integer from an array coming from a device.

Parameters
value byte: the array containing the int

offset int: the offset in the array at which the int starts

Returns
int the integer read from the array

swap32bitsToArray

public static void swap32bitsToArray (int value, 
                byte[] dest, 
                int offset)

Swaps an unsigned value around, and puts the result in an array that can be sent to a device.

Parameters
value int: The value to swap.

dest byte: the destination array

offset int: the offset in the array where to put the swapped value. Array length must be at least offset + 4

swap64bitFromArray

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

Reads a signed 64 bit integer from an array coming from a device.

Parameters
value byte: the array containing the int

offset int: the offset in the array at which the int starts Array length must be at least offset + 8

Returns
long the integer read from the array

swapU16bitFromArray

public static int swapU16bitFromArray (byte[] value, 
                int offset)

Reads an unsigned 16 bit integer from an array coming from a device, and returns it as an 'int'

Parameters
value byte: the array containing the 16 bit int (2 byte).

offset int: the offset in the array at which the int starts Array length must be at least offset + 2

Returns
int the integer read from the array.