当前位置: 首页>>代码示例>>Java>>正文


Java DataElement.UUID属性代码示例

本文整理汇总了Java中javax.bluetooth.DataElement.UUID属性的典型用法代码示例。如果您正苦于以下问题:Java DataElement.UUID属性的具体用法?Java DataElement.UUID怎么用?Java DataElement.UUID使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.bluetooth.DataElement的用法示例。


在下文中一共展示了DataElement.UUID属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hasProtocolClassUUID

boolean hasProtocolClassUUID(UUID uuid) {
    DataElement protocolDescriptor = getAttributeValue(BluetoothConsts.ProtocolDescriptorList);
    if ((protocolDescriptor == null) || (protocolDescriptor.getDataType() != DataElement.DATSEQ)) {
        // DebugLog.debug("Bogus ProtocolDescriptorList");
        return false;
    }

    for (Enumeration protocolsSeqEnum = (Enumeration) protocolDescriptor.getValue(); protocolsSeqEnum
            .hasMoreElements();) {
        DataElement elementSeq = (DataElement) protocolsSeqEnum.nextElement();

        if (elementSeq.getDataType() == DataElement.DATSEQ) {
            Enumeration elementSeqEnum = (Enumeration) elementSeq.getValue();
            if (elementSeqEnum.hasMoreElements()) {
                DataElement protocolElement = (DataElement) elementSeqEnum.nextElement();
                if (protocolElement.getDataType() != DataElement.UUID) {
                    continue;
                }
                if (uuid.equals(protocolElement.getValue())) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:26,代码来源:ServiceRecordImpl.java

示例2: servicesDiscovered

public void servicesDiscovered( int transID, ServiceRecord[] serviceRecords )
{
    DataElement e;
    ServiceRecord r;
    Enumeration< DataElement > en;
    boolean keepRun = true;
    for( int i = 0; i < serviceRecords.length && keepRun; i++ ) {
        r = serviceRecords[ i ];
        // Search for the desired UUID
        if( (e=r.getAttributeValue( 0x0001 )) != null ) {
            if ( e.getDataType() == DataElement.DATSEQ ) {
                en = (Enumeration< DataElement >)e.getValue();
                Object o;
                while( en.hasMoreElements() ) {
                    o = en.nextElement().getValue();
                    if ( o instanceof UUID ) {
                        if ( ((UUID)o).equals( uuid ) ) {
                            serviceRecord = r;
                            keepRun = false;
                        }
                    }
                }
            } else if ( e.getDataType() == DataElement.UUID ) {
                if ( ((UUID)e.getValue()).equals( uuid ) ) {
                    serviceRecord = r;
                    keepRun = false;
                }
            }
        }
    }
}
 
开发者ID:jolie,项目名称:jolie,代码行数:31,代码来源:BTServiceDiscoveryListener.java

示例3: getDataSize

public long getDataSize(DataElement data) {
    int type = data.getDataType();
    long size = getPureDataSize(data);
    if ((type == DataElement.NULL) || (type == DataElement.BOOL)
            || (type == DataElement.INT_1) || (type == DataElement.U_INT_1)
            || (type == DataElement.INT_2) || (type == DataElement.U_INT_2)
            || (type == DataElement.INT_4) || (type == DataElement.U_INT_4)
            || (type == DataElement.INT_8) || (type == DataElement.U_INT_8)
            || (type == DataElement.INT_16)
            || (type == DataElement.U_INT_16)
            || (type == DataElement.UUID)) {
        return size + 1;
    } else if ((type == DataElement.DATSEQ)
            || (type == DataElement.DATALT) || (type == DataElement.STRING)
            || (type == DataElement.URL)) {
        if (size <= 0xffL) {
            return size + 2;
        } else if (size <= 0xffffL) {
            return size + 3;
        } else if (size <= 0xffffffffL) {
            return size + 5;
        } else {
            throw new RuntimeException("Data size is too large.");
        }
    } else {
        throw new RuntimeException("Unexpected data type.");
    }
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:28,代码来源:DataElementSerializer.java

示例4: getPureDataSize

public long getPureDataSize(DataElement data) {
    switch (data.getDataType()) {
        case DataElement.NULL:
            return 0;
        case DataElement.BOOL:
        case DataElement.INT_1:
        case DataElement.U_INT_1:
            return 1;
        case DataElement.INT_2:
        case DataElement.U_INT_2:
            return 2;
        case DataElement.INT_4:
        case DataElement.U_INT_4:
            return 4;
        case DataElement.INT_8:
        case DataElement.U_INT_8:
            return 8;
        case DataElement.INT_16:
        case DataElement.U_INT_16:
            return 16;
        case DataElement.DATSEQ:
        case DataElement.DATALT:
            long size = 0;
            Enumeration elements = (Enumeration)data.getValue();
            while (elements.hasMoreElements()) {
                size += getDataSize((DataElement)elements.nextElement());
            }
            return size;
        case DataElement.STRING:
        case DataElement.URL:
            return ((String)data.getValue()).length();
        case DataElement.UUID:
            return 16;
        default:
            throw new RuntimeException("Unknown data type.");
    }
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:37,代码来源:DataElementSerializer.java

示例5: hasServiceClassUUID

/**
 * Internal implementation function
 */
boolean hasServiceClassUUID(UUID uuid) {
    DataElement attrDataElement = getAttributeValue(BluetoothConsts.ServiceClassIDList);
    if ((attrDataElement == null) || (attrDataElement.getDataType() != DataElement.DATSEQ)
            || attrDataElement.getSize() == 0) {
        // DebugLog.debug("Bogus ServiceClassIDList");
        return false;
    }

    Object value = attrDataElement.getValue();
    if ((value == null) || (!(value instanceof Enumeration))) {
        DebugLog.debug("Bogus Value in DATSEQ");
        if (value != null) {
            DebugLog.error("DATSEQ class " + value.getClass().getName());
        }
        return false;
    }
    for (Enumeration e = (Enumeration) value; e.hasMoreElements();) {
        Object element = e.nextElement();
        if (!(element instanceof DataElement)) {
            DebugLog.debug("Bogus element in DATSEQ, " + value.getClass().getName());
            continue;
        }
        DataElement dataElement = (DataElement) element;
        if ((dataElement.getDataType() == DataElement.UUID) && (uuid.equals(dataElement.getValue()))) {
            return true;
        }
    }

    return false;
}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:33,代码来源:ServiceRecordImpl.java

示例6: validateServiceRecord

protected void validateServiceRecord(ServiceRecord srvRecord) {
    DataElement protocolDescriptor = srvRecord.getAttributeValue(BluetoothConsts.ProtocolDescriptorList);
    if ((protocolDescriptor == null) || (protocolDescriptor.getDataType() != DataElement.DATSEQ)) {
        throw new IllegalArgumentException("ProtocolDescriptorList is mandatory");
    }

    DataElement serviceClassIDList = srvRecord.getAttributeValue(BluetoothConsts.ServiceClassIDList);
    if ((serviceClassIDList == null) || (serviceClassIDList.getDataType() != DataElement.DATSEQ)
            || serviceClassIDList.getSize() == 0) {
        throw new IllegalArgumentException("ServiceClassIDList is mandatory");
    }

    boolean isL2CAPpresent = false;
    for (Enumeration protocolsSeqEnum = (Enumeration) protocolDescriptor.getValue(); protocolsSeqEnum
            .hasMoreElements();) {
        DataElement elementSeq = (DataElement) protocolsSeqEnum.nextElement();
        if (elementSeq.getDataType() == DataElement.DATSEQ) {
            Enumeration elementSeqEnum = (Enumeration) elementSeq.getValue();
            if (elementSeqEnum.hasMoreElements()) {
                DataElement protocolElement = (DataElement) elementSeqEnum.nextElement();
                if ((protocolElement.getDataType() == DataElement.UUID)
                        && (BluetoothConsts.L2CAP_PROTOCOL_UUID.equals(protocolElement.getValue()))) {
                    isL2CAPpresent = true;
                    break;
                }
            }
        }
    }
    if (!isL2CAPpresent) {
        throw new IllegalArgumentException("L2CAP UUID is mandatory in ProtocolDescriptorList");
    }
}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:32,代码来源:BluetoothConnectionNotifierBase.java

示例7: validateConversion

/**
 * Tests for simple types
 */
private void validateConversion(DataElement element) throws IOException {
    int type = element.getDataType();
    switch (type) {
    case DataElement.NULL:
        validateConversion(element, 0, type, 0, null);
        break;
    case DataElement.BOOL:
        validateConversion(element, 0, type, element.getBoolean() ? 1 : 0, null);
        break;
    case DataElement.U_INT_1:
    case DataElement.INT_1:
    case DataElement.U_INT_2:
    case DataElement.INT_2:
    case DataElement.U_INT_4:
    case DataElement.INT_4:
    case DataElement.INT_8:
        validateConversion(element, 0, type, element.getLong(), null);
        break;
    case DataElement.U_INT_8:
    case DataElement.U_INT_16:
    case DataElement.INT_16:
        validateConversion(element, 0, type, 0, (byte[]) element.getValue());
        break;
    case DataElement.UUID:
        validateConversion(element, 0, type, 0, Utils.UUIDToByteArray((UUID) element.getValue()));
        break;
    case DataElement.STRING:
        byte[] bs = Utils.getUTF8Bytes((String) element.getValue());
        validateConversion(element, 0, type, 0, bs);
        break;
    case DataElement.URL:
        byte[] bu = Utils.getASCIIBytes((String) element.getValue());
        validateConversion(element, 0, type, 0, bu);
        break;
    default:
        throw new IllegalArgumentException();
    }
}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:41,代码来源:NativeSDPStreamOSXTest.java

示例8: sdpServiceAddAttribute

private void sdpServiceAddAttribute(long handle, char handleType, int attrID, DataElement element) throws ServiceRegistrationException {
    int type = element.getDataType();
    switch (type) {
    case DataElement.NULL:
        sdpServiceAddAttribute(handle, handleType, attrID, type, 0, null);
        break;
    case DataElement.BOOL:
        sdpServiceAddAttribute(handle, handleType, attrID, type, element.getBoolean() ? 1 : 0, null);
        break;
    case DataElement.U_INT_1:
    case DataElement.INT_1:
    case DataElement.U_INT_2:
    case DataElement.INT_2:
    case DataElement.U_INT_4:
    case DataElement.INT_4:
    case DataElement.INT_8:
        sdpServiceAddAttribute(handle, handleType, attrID, type, element.getLong(), null);
        break;
    case DataElement.U_INT_8:
    case DataElement.U_INT_16:
    case DataElement.INT_16:
        sdpServiceAddAttribute(handle, handleType, attrID, type, 0, (byte[]) element.getValue());
        break;
    case DataElement.UUID:
        sdpServiceAddAttribute(handle, handleType, attrID, type, 0, Utils.UUIDToByteArray((UUID) element.getValue()));
        break;
    case DataElement.STRING:
        byte[] bs = Utils.getUTF8Bytes((String) element.getValue());
        sdpServiceAddAttribute(handle, handleType, attrID, type, 0, bs);
        break;
    case DataElement.URL:
        byte[] bu = Utils.getASCIIBytes((String) element.getValue());
        sdpServiceAddAttribute(handle, handleType, attrID, type, 0, bu);
        break;
    case DataElement.DATSEQ:
    case DataElement.DATALT:
        sdpServiceSequenceAttributeStart(handle, handleType, attrID, type);
        for (Enumeration e = (Enumeration) element.getValue(); e.hasMoreElements();) {
            DataElement child = (DataElement) e.nextElement();
            sdpServiceAddAttribute(handle, handleType, -1, child);
        }
        sdpServiceSequenceAttributeEnd(handle, handleType, attrID);
        break;
    default:
        throw new IllegalArgumentException();
    }
}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:47,代码来源:BluetoothStackOSX.java

示例9: getChannel

int getChannel(UUID protocolUUID) {

        int channel = -1;

        DataElement protocolDescriptor = getAttributeValue(BluetoothConsts.ProtocolDescriptorList);
        if ((protocolDescriptor == null) || (protocolDescriptor.getDataType() != DataElement.DATSEQ)) {
            return -1;
        }

        /*
         * get RFCOMM Channel or L2CAP PSM ProtocolDescriptorList is DATSEQ of
         * DATSEQ of UUID and optional parameters
         */

        for (Enumeration protocolsSeqEnum = (Enumeration) protocolDescriptor.getValue(); protocolsSeqEnum
                .hasMoreElements();) {
            DataElement elementSeq = (DataElement) protocolsSeqEnum.nextElement();

            if (elementSeq.getDataType() == DataElement.DATSEQ) {
                Enumeration elementSeqEnum = (Enumeration) elementSeq.getValue();

                if (elementSeqEnum.hasMoreElements()) {
                    DataElement protocolElement = (DataElement) elementSeqEnum.nextElement();
                    if (protocolElement.getDataType() != DataElement.UUID) {
                        continue;
                    }
                    Object uuid = protocolElement.getValue();
                    if (elementSeqEnum.hasMoreElements() && (protocolUUID.equals(uuid))) {

                        DataElement protocolPSMElement = (DataElement) elementSeqEnum.nextElement();

                        switch (protocolPSMElement.getDataType()) {
                        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:
                            channel = (int) protocolPSMElement.getLong();
                            break;
                        }
                    }
                }
            }
        }
        return channel;
    }
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:48,代码来源:ServiceRecordImpl.java

示例10: equals

public static boolean equals(DataElement de1, DataElement de2) {
    if ((de1 == null) || (de2 == null)) {
        return false;
    }
    try {
        if (de1.getDataType() != de2.getDataType()) {
            return false;
        }
        switch (de1.getDataType()) {
        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:
            return (de1.getLong() == de2.getLong());
        case DataElement.URL:
        case DataElement.STRING:
        case DataElement.UUID:
            return de1.getValue().equals(de2.getValue());
        case DataElement.INT_16:
        case DataElement.U_INT_8:
        case DataElement.U_INT_16:
            byte[] byteAray1 = (byte[]) de1.getValue();
            byte[] byteAray2 = (byte[]) de2.getValue();
            if (byteAray1.length != byteAray2.length) {
                return false;
            }
            for (int k = 0; k < byteAray1.length; k++) {
                if (byteAray1[k] != byteAray2[k]) {
                    return false;
                }
            }
            return true;
        case DataElement.NULL:
            return true;
        case DataElement.BOOL:
            return (de1.getBoolean() == de2.getBoolean());
        case DataElement.DATSEQ:
        case DataElement.DATALT:
            Enumeration en1 = (Enumeration) de1.getValue();
            Enumeration en2 = (Enumeration) de2.getValue();
            for (; en1.hasMoreElements() && en2.hasMoreElements();) {
                DataElement d1 = (DataElement) en1.nextElement();
                DataElement d2 = (DataElement) en2.nextElement();
                if (!equals(d1, d2)) {
                    return false;
                }
            }
            if (en1.hasMoreElements() || en2.hasMoreElements()) {
                return false;
            }
            return true;
        default:
            return false;
        }
    } catch (Throwable e) {
        e.printStackTrace();
        return false;
    }
}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:62,代码来源:BluetoothStackWIDCOMMSDPInputStreamTest.java

示例11: assertEquals

public static void assertEquals(String message, DataElement de1, DataElement de2) {
    if ((de1 == null) || (de2 == null)) {
        fail(message + "NULL elements");
    }
    assertEquals(message + "Type", de1.getDataType(), de2.getDataType());
    switch (de1.getDataType()) {
    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:
        assertEquals(message + "long", de1.getLong(), de2.getLong());
        return;
    case DataElement.URL:
    case DataElement.STRING:
    case DataElement.UUID:
        assertEquals(message + "value", de1.getValue(), de2.getValue());
        return;
    case DataElement.INT_16:
    case DataElement.U_INT_8:
    case DataElement.U_INT_16:
        byte[] byteAray1 = (byte[]) de1.getValue();
        byte[] byteAray2 = (byte[]) de2.getValue();
        assertEquals(message + "length", byteAray1.length, byteAray2.length);
        for (int k = 0; k < byteAray1.length; k++) {
            assertEquals(message + "byteAray[" + k + "]", byteAray1[k], byteAray2[k]);
        }
        return;
    case DataElement.NULL:
        return;
    case DataElement.BOOL:
        assertEquals(message + "boolean", de1.getBoolean(), de2.getBoolean());
        return;
    case DataElement.DATSEQ:
    case DataElement.DATALT:
        int i = 0;
        Enumeration en1 = (Enumeration) de1.getValue();
        Enumeration en2 = (Enumeration) de2.getValue();
        for (; en1.hasMoreElements() && en2.hasMoreElements();) {
            DataElement d1 = (DataElement) en1.nextElement();
            DataElement d2 = (DataElement) en2.nextElement();
            assertEquals(message + "DataElement[" + i + "]", d1, d2);
            i++;
        }
        if (en1.hasMoreElements() || en2.hasMoreElements()) {
            fail(message + "unknown hasMoreElements");
        }
        return;
    default:
        fail(message + "unknown type");
    }
}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:54,代码来源:SDPStreamTest.java


注:本文中的javax.bluetooth.DataElement.UUID属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。