本文整理汇总了Java中javax.bluetooth.DataElement.getLong方法的典型用法代码示例。如果您正苦于以下问题:Java DataElement.getLong方法的具体用法?Java DataElement.getLong怎么用?Java DataElement.getLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.bluetooth.DataElement
的用法示例。
在下文中一共展示了DataElement.getLong方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getHandle
import javax.bluetooth.DataElement; //导入方法依赖的package包/类
public int getHandle() {
DataElement handle = getAttributeValue(SERVICE_RECORD_HANDLE);
return handle != null ? (int)handle.getLong() : 0;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
}