public class BluetoothUuid extends 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(String string)
Creates a UUID from a string.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(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.
|
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.IllegalArgumentException
- if the given byte array is not 16 bytes long.public BluetoothUuid(int value)
value
- an integer representing a 16-bit Bluetooth UUID.public BluetoothUuid(String string)
string
- a string representing a 128-bit UUID (in big-endian).IllegalArgumentException
- if the given string does not represent a 128-bit UUID.public boolean equals(@Nullable Object obj)
equals
in class Object
obj
- the reference object with which to compare.true
if this object is the same as the obj argument; false
otherwise.Object.hashCode()
,
HashMap
public short get16BitValue()
IllegalStateException
- if this UUID is not 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.ArrayIndexOutOfBoundsException
- if the given buffer is not big enough to hold the UUID.public int hashCode()
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public boolean is16Bit()