FileDocCategorySizeDatePackage
ServiceSearcherBase.javaAPI DocphoneME MR2 API (J2ME)6537Wed May 02 18:00:32 BST 2007com.sun.kvem.jsr082.bluetooth

ServiceSearcherBase

public abstract class ServiceSearcherBase extends Object implements SDPResponseListener
This 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_OVERFLOW
Mask to determine an attribute ID out of range.
javax.bluetooth.RemoteDevice
btDev
RemoteDevice whose response to be listened.
javax.bluetooth.UUID[]
uuidSet
The UUIDs from SDP_ServiceSearchRequest or SDP_ServiceSearchAttrbuteRequest.
int[]
attrSet
Attributes 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 voiderrorResponse(int errorCode, java.lang.String info, int transactionID)
Informs this listener about errors during Service Discovering process.

param
errorCode error code recieved from server or generated locally due to transaction terminating.
param
info detail information about the error
param
transactionID ID of transaction response recieved within.

public abstract voidserviceAttributeResponse(int[] attrIDs, javax.bluetooth.DataElement[] attributeValues, int transactionID)
Informs this listener about found attributes of specified service record.

param
attrIDs list of attributes whose values requested from server within SDP_ServiceAttributesRequest.
param
attributeValues values returned by server within SDP_ServiceAttributesResponse.
param
transactionID ID of transaction response recieved within.

public abstract voidserviceSearchAttributeResponse(int[] attrIDs, javax.bluetooth.DataElement[] attributeValues, int transactionID)
Informs this listener about attributes of fisrt found service record.

public abstract voidserviceSearchResponse(int[] handleList, int transactionID)
Informs this listener about found services records.

param
handleList service records handles returned by server within SDP_ServiceSearchResponse.
param
transactionID ID of transaction response recieved within.