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


Java DataElement.DATSEQ属性代码示例

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


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

示例1: serialize

public static synchronized byte[] serialize(ServiceRecord record) {
    DataElement seq = new DataElement(DataElement.DATSEQ);
    int[] attrIDs = record.getAttributeIDs();
    for (int i = 0; i < attrIDs.length; i++) {
        DataElement attrID = new DataElement(DataElement.U_INT_2,
                attrIDs[i]);
        DataElement attrValue = record.getAttributeValue(attrIDs[i]);
        if (attrValue != null) {
            seq.addElement(attrID);
            seq.addElement(attrValue);
        }
    }
    try {
        return des.serialize(seq);
    } catch (IOException e) {
        return null;
    }
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:18,代码来源:ServiceRecordSerializer.java

示例2: ClientServiceSearchAttributeTransaction

public ClientServiceSearchAttributeTransaction(JavaSDPClient client, int transactionID,
        SDPResponseListener listener, int[] attrSet,
        UUID[] uuidSet) {
    super(client, SDPClientTransaction.SDP_SERVICE_SEARCH_ATTRIBUTE_REQUEST, transactionID,
            listener);
    attrData = new DataElement(DataElement.DATSEQ);
    uuidData = new DataElement(DataElement.DATSEQ);
    for (int i = 0; i < attrSet.length; i++) {
        attrData.addElement(new DataElement(DataElement.U_INT_2,
                attrSet[i]));
    }
    for (int i = 0; i < uuidSet.length; i++) {
        uuidData.addElement(new DataElement(DataElement.UUID,
                uuidSet[i]));
    }
    parameterLength = super.client.getConnection().getReaderWriter().getDataSize(attrData) +
            super.client.getConnection().getReaderWriter().getDataSize(uuidData) + 2;
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:18,代码来源:ClientServiceSearchAttributeTransaction.java

示例3: 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

示例4: testDATSEQ

public void testDATSEQ() throws IOException {
	DataElement seq1 = new DataElement(DataElement.DATSEQ);
	seq1.addElement(new DataElement(DataElement.STRING, "BlueCove-seq1"));
	seq1.addElement(new DataElement(DataElement.U_INT_1, 0x12));
	seq1.addElement(new DataElement(DataElement.URL, "http://blueCove/"));
	seq1.addElement(new DataElement(DataElement.STRING, stringUTFData));
	seq1.addElement(new DataElement(DataElement.UUID, new UUID("B10C0BE1111111111111111111110001", false)));

	DataElement seq2 = new DataElement(DataElement.DATSEQ);
	seq2.addElement(new DataElement(DataElement.U_INT_8, new byte[] { 1, -2, 3, 4, -5, 6, 7, -8 }));
	seq2.addElement(new DataElement(DataElement.STRING, getLongString(0x100 + 2)));
	seq2.addElement(new DataElement(DataElement.U_INT_2, 0x14));

	DataElement seq3 = new DataElement(DataElement.DATSEQ);
	seq3.addElement(new DataElement(DataElement.U_INT_4, 0x15));
	seq3.addElement(new DataElement(DataElement.STRING, stringUTFData));
	seq3.addElement(new DataElement(DataElement.UUID, new UUID(0x1105)));
	seq3.addElement(new DataElement(DataElement.INT_8, 0x16));

	seq1.addElement(seq2);
	seq1.addElement(seq3);
	seq1.addElement(new DataElement(DataElement.INT_4, 0x1BCDEF35l));
	validateConversion(seq1);
}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:24,代码来源:SDPStreamTest.java

示例5: 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

示例6: dataElementCopy

private DataElement dataElementCopy(DataElement original) {
    if ((original.getDataType() == DataElement.DATSEQ)
            || (original.getDataType() == DataElement.DATALT)) {
        DataElement copy = new DataElement(original.getDataType());
        Enumeration elements = (Enumeration) original.getValue();

        while (elements.hasMoreElements()) {
            copy.addElement(dataElementCopy((DataElement)
                    elements.nextElement()));
        }
        return copy;
    } else {
        return original;
    }
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:15,代码来源:ServiceRecordImpl.java

示例7: ClientServiceSearchTransaction

public ClientServiceSearchTransaction(JavaSDPClient client, int transactionID,
        SDPResponseListener listener, UUID[] uuidSet) {
    super(client, SDPClientTransaction.SDP_SERVICE_SEARCH_REQUEST, transactionID, listener);
    serviceSearchPattern = new DataElement(DataElement.DATSEQ);
    for (int i = 0; i < uuidSet.length; i++) {
        serviceSearchPattern.addElement(new DataElement(
                DataElement.UUID, uuidSet[i]));
    }
    parameterLength = super.des.getDataSize(serviceSearchPattern) + 2;
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:10,代码来源:ClientServiceSearchTransaction.java

示例8: 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

示例9: 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

示例10: ClientServiceAttributeTransaction

ClientServiceAttributeTransaction(JavaSDPClient client, int transactionID,
        SDPResponseListener listener, int recordHandle,
        int[] attrSet) {
    super(client, SDPClientTransaction.SDP_SERVICE_ATTRIBUTE_REQUEST, transactionID, listener);
    serviceRecordHandle = recordHandle;
    attributeIDList = new DataElement(DataElement.DATSEQ);
    for (int i = 0; i < attrSet.length; i++) {
        attributeIDList.addElement(new DataElement(
                DataElement.U_INT_2, attrSet[i]));
    }
    parameterLength = super.client.getConnection().getReaderWriter().getDataSize(attributeIDList) + 6;
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:12,代码来源:ClientServiceAttributeTransaction.java

示例11: loadByteArray

void loadByteArray(byte data[]) throws IOException {
	DataElement element = (new SDPInputStream(new ByteArrayInputStream(data))).readElement();
	if (element.getDataType() != DataElement.DATSEQ) {
		throw new IOException("DATSEQ expected instead of " + element.getDataType());
	}
	Enumeration en = (Enumeration) element.getValue();
	while (en.hasMoreElements()) {
		DataElement id = (DataElement) en.nextElement();
		if (id.getDataType() != DataElement.U_INT_2) {
			throw new IOException("U_INT_2 expected instead of " + id.getDataType());
		}
		DataElement value = (DataElement) en.nextElement();
		this.populateAttributeValue((int) id.getLong(), value);
	}
}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:15,代码来源:ServiceRecordImpl.java

示例12: 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

示例13: populateL2CAPAttributes

void populateL2CAPAttributes(int handle, int channel, UUID uuid, String name) {

		this.populateAttributeValue(BluetoothConsts.ServiceRecordHandle, new DataElement(DataElement.U_INT_4, handle));

		/*
		 * service class ID list
		 */

		DataElement serviceClassIDList = new DataElement(DataElement.DATSEQ);
		serviceClassIDList.addElement(new DataElement(DataElement.UUID, uuid));

		this.populateAttributeValue(BluetoothConsts.ServiceClassIDList, serviceClassIDList);

		/*
		 * protocol descriptor list
		 */
		DataElement protocolDescriptorList = new DataElement(DataElement.DATSEQ);

		DataElement L2CAPDescriptor = new DataElement(DataElement.DATSEQ);
		L2CAPDescriptor.addElement(new DataElement(DataElement.UUID, BluetoothConsts.L2CAP_PROTOCOL_UUID));
		L2CAPDescriptor.addElement(new DataElement(DataElement.U_INT_2, channel));
		protocolDescriptorList.addElement(L2CAPDescriptor);

		this.populateAttributeValue(BluetoothConsts.ProtocolDescriptorList, protocolDescriptorList);

		if (name != null) {
			this.populateAttributeValue(BluetoothConsts.AttributeIDServiceName, new DataElement(DataElement.STRING,
					name));
		}
	}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:30,代码来源:ServiceRecordImpl.java

示例14: 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

示例15: testDATSEQ16

public void testDATSEQ16() throws IOException {
	DataElement seq = new DataElement(DataElement.DATSEQ);
	// INT_8 = 9 bytes;
	int nElements = (0xFF / 9) + 1;
	for (int i = 0; i < nElements; i++) {
		seq.addElement(new DataElement(DataElement.INT_8, i));
	}
	int l = SDPOutputStream.getLength(seq);
	assertTrue("DATSEQ16 len(" + l + ")>0xFF", l > 0xFF);
	assertTrue("DATSEQ16 len(" + l + ")<0xFFFF", l < 0xFFFF);
	validateConversion(seq);
}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:12,代码来源:SDPStreamTest.java


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