com.qualcomm.robotcore.util

## Class TypeConversion

- java.lang.Object
- - com.qualcomm.robotcore.util.TypeConversion

-     public class TypeConversion
      extends java.lang.Object

  Utility class for performing type conversions

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `byteArrayToInt(byte[] byteArray)` convert a byte array into an int; big endian is assumed
    `static int` | `byteArrayToInt(byte[] byteArray, java.nio.ByteOrder byteOrder)` convert a byte array into an int
    `static long` | `byteArrayToLong(byte[] byteArray)` convert a byte array into a long; big endian is assumed
    `static long` | `byteArrayToLong(byte[] byteArray, java.nio.ByteOrder byteOrder)` convert a byte array into a long
    `static short` | `byteArrayToShort(byte[] byteArray)` convert a byte array into a short; big endian is assumed
    `static short` | `byteArrayToShort(byte[] byteArray, java.nio.ByteOrder byteOrder)` convert a byte array into a short
    `static short` | `byteArrayToShort(byte[] byteArray, int ibFirst, java.nio.ByteOrder byteOrder)`
    `static double` | `doubleFromFixed(int value, int fractionBits)`
    `static double` | `doubleFromFixed(long value, int fractionBits)`
    `static int` | `doubleToFixedInt(double value, int fractionBits)`
    `static long` | `doubleToFixedLong(double value, int fractionBits)`
    `static byte[]` | `intToByteArray(int integer)` convert an int into a byte array; big endian is assumed
    `static byte[]` | `intToByteArray(int integer, java.nio.ByteOrder byteOrder)` convert an int into a byte array
    `static byte[]` | `longToByteArray(long longInt)` convert a long into a byte array; big endian is assumed
    `static byte[]` | `longToByteArray(long longInt, java.nio.ByteOrder byteOrder)` convert a long into a byte array
    `static byte[]` | `shortToByteArray(short shortInt)` convert a short into a byte array; big endian is assumed
    `static byte[]` | `shortToByteArray(short shortInt, java.nio.ByteOrder byteOrder)` convert a short into a byte array
    `static byte[]` | `stringToUtf8(java.lang.String javaString)` Convert a Java String into a UTF-8 byte array
    `static boolean` | `toBoolean(java.lang.Boolean value)`
    `static boolean` | `toBoolean(java.lang.Boolean value, boolean defaultValue)`
    `static double` | `unsignedByteToDouble(byte b)` Accept a byte, treat that byte as an unsigned byte, then covert it to the return type
    `static int` | `unsignedByteToInt(byte b)` Accept a byte, treat that byte as an unsigned byte, then covert it to the return type
    `static long` | `unsignedIntToLong(int i)` Accept an int, treat that int as an unsigned int, then covert it to the return type
    `static int` | `unsignedShortToInt(short s)` Treats a short as an unsigned value and returns that value as a int
    `static java.lang.String` | `utf8ToString(byte[] utf8String)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### shortToByteArray

          public static byte[] shortToByteArray(short shortInt)

      convert a short into a byte array; big endian is assumed
      Parameters:
        `shortInt` -
      Returns:
        byte array

    - #### shortToByteArray

          public static byte[] shortToByteArray(short shortInt,
                                                java.nio.ByteOrder byteOrder)

      convert a short into a byte array
      Parameters:
        `shortInt` -
        `byteOrder` -
      Returns:
        byte array

    - #### intToByteArray

          public static byte[] intToByteArray(int integer)

      convert an int into a byte array; big endian is assumed
      Parameters:
        `integer` -
      Returns:
        byte array

    - #### intToByteArray

          public static byte[] intToByteArray(int integer,
                                              java.nio.ByteOrder byteOrder)

      convert an int into a byte array
      Parameters:
        `integer` -
        `byteOrder` -
      Returns:
        byte array

    - #### longToByteArray

          public static byte[] longToByteArray(long longInt)

      convert a long into a byte array; big endian is assumed
      Parameters:
        `longInt` -
      Returns:
        byte array

    - #### longToByteArray

          public static byte[] longToByteArray(long longInt,
                                               java.nio.ByteOrder byteOrder)

      convert a long into a byte array
      Parameters:
        `longInt` -
        `byteOrder` -
      Returns:
        byte array

    - #### byteArrayToShort

          public static short byteArrayToShort(byte[] byteArray)

      convert a byte array into a short; big endian is assumed
      Parameters:
        `byteArray` -
      Returns:
        byte array

    - #### byteArrayToShort

          public static short byteArrayToShort(byte[] byteArray,
                                               java.nio.ByteOrder byteOrder)

      convert a byte array into a short
      Parameters:
        `byteArray` -
        `byteOrder` -
      Returns:
        byte array

    - #### byteArrayToShort

          public static short byteArrayToShort(byte[] byteArray,
                                               int ibFirst,
                                               java.nio.ByteOrder byteOrder)

    - #### byteArrayToInt

          public static int byteArrayToInt(byte[] byteArray)

      convert a byte array into an int; big endian is assumed
      Parameters:
        `byteArray` -
      Returns:
        an integer

    - #### byteArrayToInt

          public static int byteArrayToInt(byte[] byteArray,
                                           java.nio.ByteOrder byteOrder)

      convert a byte array into an int
      Parameters:
        `byteArray` -
        `byteOrder` -
      Returns:
        an integer

    - #### byteArrayToLong

          public static long byteArrayToLong(byte[] byteArray)

      convert a byte array into a long; big endian is assumed
      Parameters:
        `byteArray` -
      Returns:
        an integer

    - #### byteArrayToLong

          public static long byteArrayToLong(byte[] byteArray,
                                             java.nio.ByteOrder byteOrder)

      convert a byte array into a long
      Parameters:
        `byteArray` -
        `byteOrder` -
      Returns:
        a long

    - #### unsignedByteToInt

          public static int unsignedByteToInt(byte b)

      Accept a byte, treat that byte as an unsigned byte, then covert it to the return type
      Parameters:
        `b` - byte to treat as unsigned byte
      Returns:
        a positive value between 0 and 255

    - #### unsignedShortToInt

          public static int unsignedShortToInt(short s)

      Treats a short as an unsigned value and returns that value as a int
      Parameters:
        `s` - the short to be converted to an int
      Returns:
        a positive value between 0 and 65535

    - #### unsignedByteToDouble

          public static double unsignedByteToDouble(byte b)

      Accept a byte, treat that byte as an unsigned byte, then covert it to the return type
      Parameters:
        `b` - byte to treat as unsigned byte
      Returns:
        a positive between 0 and 255

    - #### unsignedIntToLong

          public static long unsignedIntToLong(int i)

      Accept an int, treat that int as an unsigned int, then covert it to the return type
      Parameters:
        `i` - int to treat as unsigned int
      Returns:
        a positive between 0 and 2^32

    - #### stringToUtf8

          public static byte[] stringToUtf8(java.lang.String javaString)

      Convert a Java String into a UTF-8 byte array
      Parameters:
        `javaString` - Java String to convert
      Returns:
        UTF-8 byte array
      Throws:
        `java.lang.IllegalArgumentException` - if unable to cleanly convert the Java String

    - #### doubleToFixedInt

          public static int doubleToFixedInt(double value,
                                             int fractionBits)

    - #### doubleFromFixed

          public static double doubleFromFixed(int value,
                                               int fractionBits)

    - #### doubleToFixedLong

          public static long doubleToFixedLong(double value,
                                               int fractionBits)

    - #### doubleFromFixed

          public static double doubleFromFixed(long value,
                                               int fractionBits)

    - #### utf8ToString

          public static java.lang.String utf8ToString(byte[] utf8String)

    - #### toBoolean

          public static boolean toBoolean(java.lang.Boolean value)

    - #### toBoolean

          public static boolean toBoolean(java.lang.Boolean value,
                                          boolean defaultValue)