public class BluetoothAddress extends Object
BluetoothAddress
class represents the address of a Bluetooth device.
Addresses may be created by using the class constructor
or retrieved by
listening to connection
events
while scanning
.
A string representation of an address may be retrieved by calling the toString()
method of the
object. The equals(Object)
method may be used in order to check if an address is equal to an other.
Constructor and Description |
---|
BluetoothAddress(byte[] bytes,
int offset,
boolean isPublic)
Creates an address from the given byte array.
|
BluetoothAddress(String string,
boolean isPublic)
Creates an address from the given string.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Returns whether this address is equal to the given object.
|
void |
getBytes(byte[] buffer,
int offset)
Writes this address to the given byte array.
|
int |
hashCode()
Returns the hash code value of this address.
|
boolean |
isPublic()
Returns whether this address is a public address.
|
String |
toString()
Returns a string representation of this address (in big-endian).
|
public BluetoothAddress(byte[] bytes, int offset, boolean isPublic)
bytes
- a byte array containing a Bluetooth address (in big-endian).offset
- the offset of the address in the byte array.isPublic
- true to create a public address, false to create a private address.ArrayIndexOutOfBoundsException
- if the given byte array is not 6 bytes long.public BluetoothAddress(String string, boolean isPublic)
string
- a string representing a Bluetooth address (in big-endian).isPublic
- true to create a public address, false to create a private address.IllegalArgumentException
- if the given string does not represent a Bluetooth address.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 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 address.public int hashCode()
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public boolean isPublic()