Package ej.bluetooth

## Class BluetoothUuid

- java.lang.Object
- - ej.bluetooth.BluetoothUuid

-     public class BluetoothUuid
      extends Object

  The `BluetoothUuid` class represents the UUID of a service or attribute.

  UUIDs may be created from byte arrays or strings representing 128-bit UUIDs or from integers representing 16-bit Bluetooth UUIDs.

  A string representation of a UUID may be retrieved by calling the `toString()` method of the object. The `Object.equals(Object)` method may be used in order to check if a UUID is equal to an other.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `BluetoothUuid​(byte[] bytes, int offset)` | Creates a UUID from a byte array.
    `BluetoothUuid​(int value)` | Creates a UUID from an integer.
    `BluetoothUuid​(String string)` | Creates a UUID from a string.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `short` | `get16BitValue()` | Returns the integer representing this 16-bit Bluetooth UUID.
    `void` | `getBytes​(byte[] buffer, int offset)` | Writes this UUID to the given byte array.
    `boolean` | `is16Bit()` | Returns whether this UUID is a 16-bit Bluetooth UUID.

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

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

- - ### Constructor Detail

    - #### BluetoothUuid

          public BluetoothUuid​(byte[] bytes,
                               int offset)

      Creates a UUID from a byte array.
      Parameters:
        `bytes` - a byte array containing a 128-bit UUID (in big-endian).
        `offset` - the offset of the UUID in the byte array.
      Throws:
        `IllegalArgumentException` - if the given byte array is not 16 bytes long.

    - #### BluetoothUuid

          public BluetoothUuid​(String string)

      Creates a UUID from a string.
      Parameters:
        `string` - a string representing a 128-bit UUID (in big-endian).
      Throws:
        `IllegalArgumentException` - if the given string does not represent a 128-bit UUID.

    - #### BluetoothUuid

          public BluetoothUuid​(int value)

      Creates a UUID from an integer.
      Parameters:
        `value` - an integer representing a 16-bit Bluetooth UUID.

  - ### Method Detail

    - #### getBytes

          public void getBytes​(byte[] buffer,
                               int offset)

      Writes this UUID to the given byte array.
      Parameters:
        `buffer` - the buffer to write to (in big-endian).
        `offset` - the index in the buffer to write at.
      Throws:
        `ArrayIndexOutOfBoundsException` - if the given buffer is not big enough to hold the UUID.

    - #### is16Bit

          public boolean is16Bit()

      Returns whether this UUID is a 16-bit Bluetooth UUID.
      Returns:
        true if this UUID is a 16-bit Bluetooth UUID, false otherwise.

    - #### get16BitValue

          public short get16BitValue()

      Returns the integer representing this 16-bit Bluetooth UUID.
      Returns:
        the integer representing this 16-bit Bluetooth UUID.
      Throws:
        `IllegalStateException` - if this UUID is not a 16-bit Bluetooth UUID.