本文整理汇总了Java中javax.bluetooth.DataElement类的典型用法代码示例。如果您正苦于以下问题:Java DataElement类的具体用法?Java DataElement怎么用?Java DataElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataElement类属于javax.bluetooth包,在下文中一共展示了DataElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serialize
import javax.bluetooth.DataElement; //导入依赖的package包/类
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;
}
}
示例2: copy
import javax.bluetooth.DataElement; //导入依赖的package包/类
public synchronized ServiceRecordImpl copy() {
int count = attributesTable.size();
int[] attrIDs = new int[count];
DataElement[] attrValues = new DataElement[count];
Enumeration ids = attributesTable.keys();
Enumeration values = attributesTable.elements();
for (int i = 0; i < count; i++) {
attrIDs[i] = ((Integer)ids.nextElement()).intValue();
// no nedd to copy elements here; service record constructor
// performs the copying
attrValues[i] = (DataElement)values.nextElement();
}
ServiceRecordImpl servRec = new ServiceRecordImpl(notifier,
attrIDs, attrValues);
servRec.serviceClasses = serviceClasses;
return servRec;
}
示例3: setAttributeValue
import javax.bluetooth.DataElement; //导入依赖的package包/类
public synchronized boolean setAttributeValue(
int attrID, DataElement attrValue) {
if ((attrID & MASK_OVERFLOW) != 0) {
throw new IllegalArgumentException(
"attrID does not represent a 16-bit unsigned integer");
}
if (attrID == SERVICE_RECORD_HANDLE) {
throw new IllegalArgumentException(
"attrID is the value of ServiceRecordHandle (0x0000)");
}
if (remoteDevice != null) {
throw new RuntimeException(
"can't update ServiceRecord of the RemoteDevice");
}
Object key = new Integer(attrID);
if (attrValue == null) {
return attributesTable.remove(key) != null;
} else {
attributesTable.put(key, dataElementCopy(attrValue));
return true;
}
}
示例4: ClientServiceSearchAttributeTransaction
import javax.bluetooth.DataElement; //导入依赖的package包/类
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;
}
示例5: hasProtocolClassUUID
import javax.bluetooth.DataElement; //导入依赖的package包/类
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;
}
示例6: testDATSEQ
import javax.bluetooth.DataElement; //导入依赖的package包/类
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);
}
示例7: getDataElementValue
import javax.bluetooth.DataElement; //导入依赖的package包/类
private Object getDataElementValue(Object o) {
if (o instanceof DataElement) {
// Bluecove throws an exception if the type is unknown
try {
return ((DataElement) o).getValue();
} catch (ClassCastException e) {
return null;
}
}
return null;
}
示例8: servicesDiscovered
import javax.bluetooth.DataElement; //导入依赖的package包/类
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;
}
}
}
}
}
示例9: findService
import javax.bluetooth.DataElement; //导入依赖的package包/类
/**
* Find service for a device that is named: OBEX Object Push
* @param serviceRecords
* @return the service record
*/
private ServiceRecord findService(ServiceRecord[] serviceRecords) {
ServiceRecord retvalue = null;
if(serviceRecords.length == 1) {
retvalue = serviceRecords[0];
} else {
for (int i = 0; i < serviceRecords.length; i++) {
DataElement serviceName = serviceRecords[i].getAttributeValue(0x0100);
if (serviceName != null && serviceName.getValue().equals("DevB")) {
retvalue = serviceRecords[i];
}
}
}
return retvalue;
}
示例10: getDataElementValue
import javax.bluetooth.DataElement; //导入依赖的package包/类
private Object getDataElementValue(Object o) {
if(o instanceof DataElement) {
// Bluecove throws an exception if the type is unknown
try {
return ((DataElement) o).getValue();
} catch(ClassCastException e) {
return null;
}
}
return null;
}
示例11: serviceAttributeResponse
import javax.bluetooth.DataElement; //导入依赖的package包/类
public void serviceAttributeResponse(int[] attrIDs,
DataElement[] attributeValues, int transactionID) {
if (DEBUG) {
System.out.println(cn +
".serviceAttributeResponse: unexpected call");
}
throw new RuntimeException("unexpected call");
}
示例12: serviceSearchAttributeResponse
import javax.bluetooth.DataElement; //导入依赖的package包/类
public void serviceSearchAttributeResponse(int[] attrIDs,
DataElement[] attributeValues, int transactionID) {
if (DEBUG) {
System.out.println(cn + ".serviceSearchAttributeResponse: called");
}
synchronized (this) {
attrSet = attrIDs;
attrValues = attributeValues;
notify();
}
}
示例13: setHandle
import javax.bluetooth.DataElement; //导入依赖的package包/类
public void setHandle(int handle) {
Integer attrID = new Integer(SERVICE_RECORD_HANDLE);
attributesTable.remove(attrID);
attributesTable.put(attrID, new DataElement(
DataElement.U_INT_4, handle));
recHandle = handle;
}
示例14: dataElementCopy
import javax.bluetooth.DataElement; //导入依赖的package包/类
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;
}
}
示例15: getAttributeValue
import javax.bluetooth.DataElement; //导入依赖的package包/类
public DataElement getAttributeValue(int attrID) {
if ((attrID & MASK_OVERFLOW) != 0) {
throw new IllegalArgumentException(
"attrID isn't a 16-bit unsigned integer");
}
DataElement attrValue = (DataElement) attributesTable.get(new
Integer(attrID));
if (attrValue == null) {
return null;
} else {
return dataElementCopy(attrValue);
}
}