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


Java DataElement类代码示例

本文整理汇总了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;
    }
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:19,代码来源:ServiceRecordSerializer.java

示例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;
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:21,代码来源:ServiceRecordImpl.java

示例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;
    }
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:27,代码来源:ServiceRecordImpl.java

示例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;
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:19,代码来源:ClientServiceSearchAttributeTransaction.java

示例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;
}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:27,代码来源:ServiceRecordImpl.java

示例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);
}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:25,代码来源:SDPStreamTest.java

示例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;
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:12,代码来源:InvitationListener.java

示例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;
				}
			}
		}
	}
}
 
开发者ID:jolie,项目名称:jolie,代码行数:32,代码来源:BTServiceDiscoveryListener.java

示例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;
}
 
开发者ID:Ardulink,项目名称:Ardulink-1,代码行数:20,代码来源:ArdulinkDiscoveryListener.java

示例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;
}
 
开发者ID:kiggundu,项目名称:briar,代码行数:12,代码来源:InvitationListener.java

示例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");
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:9,代码来源:ServiceSelector.java

示例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();
    }
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:12,代码来源:ServiceSelector.java

示例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;
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:8,代码来源:ServiceRecordImpl.java

示例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;
    }
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:16,代码来源:ServiceRecordImpl.java

示例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);
    }
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:15,代码来源:ServiceRecordImpl.java


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