ServiceSearcherBasepublic abstract class ServiceSearcherBase extends Object implements SDPResponseListenerThis class saves information about every service descovery request
to provide functionality of DiscoveryAgent using multiple requests
via SDPClient (Service Descovery Protocol) by ServiceSelector
and ServiceSearcher classes. |
Fields Summary |
---|
private static final int | MASK_OVERFLOWMask to determine an attribute ID out of range. | javax.bluetooth.RemoteDevice | btDevRemoteDevice whose response to be listened. | javax.bluetooth.UUID[] | uuidSetThe UUIDs from SDP_ServiceSearchRequest or
SDP_ServiceSearchAttrbuteRequest. | int[] | attrSetAttributes list from SDP_ServiceSearchAttrbuteRequest. |
Constructors Summary |
---|
ServiceSearcherBase(int[] attrSet, javax.bluetooth.UUID[] uuidSet, javax.bluetooth.RemoteDevice btDev)Creates ServiceSearcherBase and save all required info in it.
Object checkObj = new Object();
Hashtable dupChecker = new Hashtable();
Enumeration set;
// checking on null
if (uuidSet == null) {
throw new NullPointerException("null instance of UUID set");
}
if (btDev == null) {
throw new NullPointerException("null instance of RemoteDevice");
}
// check UUID size
if (uuidSet.length == 0) {
throw new IllegalArgumentException("zero UUID set size");
}
// attrSet checking
if (attrSet != null) {
// check attrSet size
if (attrSet.length == 0) {
throw new IllegalArgumentException("zero attrSet size");
} else if (attrSet.length > ServiceRecordImpl.RETRIEVABLE_MAX) {
throw new IllegalArgumentException("attrSet size exceeding");
}
for (int i = 0; i < attrSet.length; i++) {
// check that attribute ID is valid
if ((attrSet[i] & MASK_OVERFLOW) != 0) {
throw new IllegalArgumentException("illegal attrSet");
}
// check attribute ID duplication
if (dupChecker.put(new Integer(attrSet[i]), checkObj) != null) {
throw new IllegalArgumentException(
"duplicated attribute ID");
}
}
}
// adds defaults attribute IDs
for (int i = 0; i <= 0x0004; i++) {
dupChecker.put(new Integer(i), checkObj);
}
// creates attrSet to save attrIDs in the carrier
this.attrSet = new int[dupChecker.size()];
set = dupChecker.keys();
for (int i = 0; set.hasMoreElements(); i++) {
this.attrSet[i] = ((Integer) set.nextElement()).intValue();
}
dupChecker.clear();
// uuidSet checking
for (int i = 0; i < uuidSet.length; i++) {
// check that UUID is not null instance
if (uuidSet[i] == null) {
throw new NullPointerException("null instance of UUID");
}
// check UUID duplication
if (dupChecker.put(uuidSet[i], checkObj) != null) {
throw new IllegalArgumentException("duplicated UUID");
}
}
// creates uuidSet to save UUIDs in the carrier
this.uuidSet = new UUID[dupChecker.size()];
set = dupChecker.keys();
for (int i = 0; set.hasMoreElements(); i++) {
this.uuidSet[i] = (UUID) set.nextElement();
}
this.btDev = btDev;
|
Methods Summary |
---|
public abstract void | errorResponse(int errorCode, java.lang.String info, int transactionID)Informs this listener about errors during Service Discovering process.
| public abstract void | serviceAttributeResponse(int[] attrIDs, javax.bluetooth.DataElement[] attributeValues, int transactionID)Informs this listener about found attributes of specified service record.
| public abstract void | serviceSearchAttributeResponse(int[] attrIDs, javax.bluetooth.DataElement[] attributeValues, int transactionID)Informs this listener about attributes of fisrt found service record.
| public abstract void | serviceSearchResponse(int[] handleList, int transactionID)Informs this listener about found services records.
|
|