public class BluetoothUuid
extends java.lang.Object
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 equals(Object)
method may be used in order to check if a UUID is equal to an other.
Constructor and Description |
---|
BluetoothUuid(byte[] bytes,
int offset)
Creates a UUID from a byte array.
|
BluetoothUuid(int value)
Creates a UUID from an integer.
|
BluetoothUuid(java.lang.String string)
Creates a UUID from a string.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Returns whether this UUID is equal to the given object.
|
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.
|
int |
hashCode()
Returns the hash code value of this UUID.
|
boolean |
is16Bit()
Returns whether this UUID is a 16-bit Bluetooth UUID.
|
java.lang.String |
toString()
Returns a string representation of this UUID (in big-endian).
|
public BluetoothUuid(byte[] bytes, int offset)
bytes
- a byte array containing a 128-bit UUID (in big-endian).offset
- the offset of the UUID in the byte array.java.lang.IllegalArgumentException
- if the given byte array is not 16 bytes long.public BluetoothUuid(java.lang.String string)
string
- a string representing a 128-bit UUID (in big-endian).java.lang.IllegalArgumentException
- if the given string does not represent a 128-bit UUID.public BluetoothUuid(int value)
value
- an integer representing a 16-bit Bluetooth UUID.public void getBytes(byte[] buffer, int offset)
buffer
- the buffer to write to (in big-endian).offset
- the index in the buffer to write at.java.lang.ArrayIndexOutOfBoundsException
- if the given buffer is not big enough to hold the UUID.public boolean is16Bit()
public short get16BitValue()
java.lang.IllegalStateException
- if this UUID is not a 16-bit Bluetooth UUID.public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(@Nullable java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object