Methods Summary |
---|
protected abstract void | checkServiceRecord()Ensures that the service record is valid.
|
public abstract void | close()Closes the connection. Connection interface implementation.
|
protected boolean | compareDataElements(javax.bluetooth.DataElement first, javax.bluetooth.DataElement second)Compares two DataElements.
boolean ret = false;
int valueType = first.getDataType();
if (ret = (valueType == second.getDataType())) {
switch (valueType) {
case DataElement.BOOL:
ret = first.getBoolean() == second.getBoolean();
break;
case DataElement.U_INT_1:
case DataElement.U_INT_2:
case DataElement.U_INT_4:
case DataElement.INT_1:
case DataElement.INT_2:
case DataElement.INT_4:
case DataElement.INT_8:
ret = first.getLong() == second.getLong();
break;
default:
Object v1 = first.getValue();
Object v2 = second.getValue();
if (v1 instanceof Enumeration && v2 instanceof Enumeration) {
Enumeration e1 = (Enumeration)v1;
Enumeration e2 = (Enumeration)v2;
ret = true;
while (e1.hasMoreElements() &&
e2.hasMoreElements() && ret) {
ret &= e1.nextElement().equals(e2.nextElement());
}
ret = ret &&
!(e1.hasMoreElements() ||
e2.hasMoreElements());
} else if (v1 instanceof byte[] && v2 instanceof byte[]) {
byte[] a1 = (byte[])v1;
byte[] a2 = (byte[])v2;
ret = a1.length == a2.length;
for (int i = a1.length; --i >= 0 && ret; ) {
ret &= (a1[i] == a2[i]);
}
} else {
ret = v1.equals(v2);
}
break;
}
}
return ret;
|
javax.bluetooth.ServiceRecord | getServiceRecord()Retrieves service record for this notifier.
It always returns the same object reference.
if (isClosed) {
throw new IllegalArgumentException("Notifier is closed.");
}
// IMPL_NOTE: copy should probably be returned instead of a reference,
// but the current implementation returns reference to make TCK pass
// return serviceRec.copy();
return serviceRec;
|
protected void | updateServiceRecord(ServiceRecordImpl record)Stores the service record for this notifier in the local SDDB.
If there is no SDDB version of the service record, this method will
do nothing.
// IMPL_NOTE: the current implementation assumes record and
// this.serviceRec reference the same object to make TCK pass
// ServiceRecordImpl oldRecord = serviceRec;
// serviceRec = record.copy();
try {
checkServiceRecord();
} catch (ServiceRegistrationException e) {
// serviceRec = oldRecord;
throw new IllegalArgumentException(e.getMessage());
}
if (SDDB.getInstance().contains(serviceRec)) {
SDDB.getInstance().updateServiceRecord(serviceRec);
}
|