com.android.ddmlib.utils
Class ArrayHelper

java.lang.Object
  extended by com.android.ddmlib.utils.ArrayHelper

public final class ArrayHelper
extends Object

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


Constructor Summary
ArrayHelper()
           
 
Method Summary
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'
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayHelper

public ArrayHelper()
Method Detail

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 - The value to swap.
dest - the destination array
offset - the offset in the array where to put the swapped value. Array length must be at least offset + 4

swap32bitFromArray

public static int swap32bitFromArray(byte[] value,
                                     int offset)
Reads a signed 32 bit integer from an array coming from a device.

Parameters:
value - the array containing the int
offset - the offset in the array at which the int starts
Returns:
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 - the array containing the 16 bit int (2 byte).
offset - the offset in the array at which the int starts Array length must be at least offset + 2
Returns:
the integer read from the array.

swap64bitFromArray

public static long swap64bitFromArray(byte[] value,
                                      int offset)
Reads a signed 64 bit integer from an array coming from a device.

Parameters:
value - the array containing the int
offset - the offset in the array at which the int starts Array length must be at least offset + 8
Returns:
the integer read from the array


Copyright © 2008-2012. All Rights Reserved.