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


Java DataElement.getValue方法代码示例

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


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

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

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

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

示例4: getPureDataSize

import javax.bluetooth.DataElement; //导入方法依赖的package包/类
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,代码行数:38,代码来源:DataElementSerializer.java

示例5: complete

import javax.bluetooth.DataElement; //导入方法依赖的package包/类
public void complete() {
    DataElement attrList;
    DataElementSerializer des = new DataElementSerializer();
    try {
        attrList = des.restore(attributes);
    } catch (IOException e) {
        listener.serviceAttributeResponse(null, null,
                ssTransID);
        return;
    }
    int size = attrList.getSize() / 2;
    if (size == 0) {
        listener.serviceAttributeResponse(null, null,
                ssTransID);
        return;
    }
    Enumeration elements = (Enumeration)attrList.getValue();
    final int[] attrIDs = new int[size];
    final DataElement[] attrValues = new DataElement[size];
    for (int i = 0; elements.hasMoreElements(); i++) {
        attrIDs[i] = (int)((DataElement)
                elements.nextElement()).getLong();
        attrValues[i] = ((DataElement)
                elements.nextElement());
    }
    listener.serviceAttributeResponse(attrIDs, attrValues, ssTransID);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:28,代码来源:ClientServiceAttributeTransaction.java

示例6: loadByteArray

import javax.bluetooth.DataElement; //导入方法依赖的package包/类
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,代码行数:16,代码来源:ServiceRecordImpl.java

示例7: hasServiceClassUUID

import javax.bluetooth.DataElement; //导入方法依赖的package包/类
/**
 * 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,代码行数:34,代码来源:ServiceRecordImpl.java

示例8: validateServiceRecord

import javax.bluetooth.DataElement; //导入方法依赖的package包/类
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,代码行数:33,代码来源:BluetoothConnectionNotifierBase.java

示例9: compareDataElements

import javax.bluetooth.DataElement; //导入方法依赖的package包/类
protected boolean compareDataElements(DataElement first,
        DataElement second) {
    boolean ret = false;
    int valueType = first.getDataType();
    if (ret = (valueType == second.getDataType())) {
        switch (valueType) {
        case DataElement.BOOL:
            ret = first.getBoolean() == second.getBoolean();
            break;
        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:
            ret = first.getLong() == second.getLong();
            break;
        default:
            Object v1 = first.getValue();
            Object v2 = second.getValue();
            if (v1 instanceof Enumeration && v2 instanceof Enumeration) {
                Enumeration e1 = (Enumeration)v1;
                Enumeration e2 = (Enumeration)v2;
                ret = true;
                while (e1.hasMoreElements() &&
                       e2.hasMoreElements() && ret) {
                    ret &= e1.nextElement().equals(e2.nextElement());
                }
                ret = ret &&
                    !(e1.hasMoreElements() ||
                      e2.hasMoreElements());
            } else if (v1 instanceof byte[] && v2 instanceof byte[]) {
                byte[] a1 = (byte[])v1;
                byte[] a2 = (byte[])v2;
                ret = a1.length == a2.length;
                for (int i = a1.length; --i >= 0 && ret; ) {
                    ret &= (a1[i] == a2[i]);
                }
            } else {
                ret = v1.equals(v2);
            }
            break;
        }
    }
    return ret;
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:48,代码来源:BluetoothNotifier.java

示例10: populateServicesRecordAttributeValues

import javax.bluetooth.DataElement; //导入方法依赖的package包/类
public boolean populateServicesRecordAttributeValues(ServiceRecordImpl serviceRecord, int[] attrIDs) throws IOException {
    if (attrIDs.length > ATTR_RETRIEVABLE_MAX) {
        throw new IllegalArgumentException();
    }
    boolean anyRetrived = false;
    for (int i = 0; i < attrIDs.length; i++) {
        int id = attrIDs[i];
        try {
            byte[] sdpStruct = getServiceAttribute(id, serviceRecord.getHandle());
            if (sdpStruct != null) {
                if (BluetoothStackWIDCOMMSDPInputStream.debug) {
                    DebugLog.debug("decode attribute " + id + " Ox" + Integer.toHexString(id));
                }
                DataElement element = (new BluetoothStackWIDCOMMSDPInputStream(new ByteArrayInputStream(sdpStruct))).readElement();

                // Do special case conversion for only one element in the
                // list.
                if (id == BluetoothConsts.ProtocolDescriptorList) {
                    Enumeration protocolsSeqEnum = (Enumeration) element.getValue();
                    if (protocolsSeqEnum.hasMoreElements()) {
                        DataElement protocolElement = (DataElement) protocolsSeqEnum.nextElement();
                        if (protocolElement.getDataType() != DataElement.DATSEQ) {
                            DataElement newMainSeq = new DataElement(DataElement.DATSEQ);
                            newMainSeq.addElement(element);
                            element = newMainSeq;
                        }
                    }
                }

                serviceRecord.populateAttributeValue(id, element);
                anyRetrived = true;
            } else {
                if (BluetoothStackWIDCOMMSDPInputStream.debug) {
                    DebugLog.debug("no data for attribute " + id + " Ox" + Integer.toHexString(id));
                }
            }
        } catch (Throwable e) {
            if (BluetoothStackWIDCOMMSDPInputStream.debug) {
                DebugLog.error("error populate attribute " + id + " Ox" + Integer.toHexString(id), e);
            }
        }
    }
    return anyRetrived;
}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:45,代码来源:BluetoothStackWIDCOMM.java

示例11: sdpServiceAddAttribute

import javax.bluetooth.DataElement; //导入方法依赖的package包/类
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,代码行数:48,代码来源:BluetoothStackOSX.java

示例12: getChannel

import javax.bluetooth.DataElement; //导入方法依赖的package包/类
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,代码行数:49,代码来源:ServiceRecordImpl.java

示例13: equals

import javax.bluetooth.DataElement; //导入方法依赖的package包/类
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,代码行数:63,代码来源:BluetoothStackWIDCOMMSDPInputStreamTest.java

示例14: assertEquals

import javax.bluetooth.DataElement; //导入方法依赖的package包/类
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,代码行数:55,代码来源:SDPStreamTest.java

示例15: getRemoteNodeName

import javax.bluetooth.DataElement; //导入方法依赖的package包/类
/**
 * 
 * This method fetches the name of the remote node. 
 *
 * @param input An object representing the connection to the found node.
 * @return The name of the remote node.
 */
public String getRemoteNodeName(Object input){        
    DataElement data = ((ServiceRecord)input).getAttributeValue(0x0100);   
    return (String)data.getValue();
}
 
开发者ID:meisamhe,项目名称:GPLshared,代码行数:12,代码来源:BluetoothNetwork.java


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