本文整理汇总了Java中com.digitalpetri.opcua.stack.core.StatusCodes.Bad_DecodingError方法的典型用法代码示例。如果您正苦于以下问题:Java StatusCodes.Bad_DecodingError方法的具体用法?Java StatusCodes.Bad_DecodingError怎么用?Java StatusCodes.Bad_DecodingError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.digitalpetri.opcua.stack.core.StatusCodes
的用法示例。
在下文中一共展示了StatusCodes.Bad_DecodingError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decodeGuid
import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@Override
public UUID decodeGuid(String field) throws UaSerializationException {
requireNextStartElement(field);
UUID uuid;
if (nextStartElement("String")) {
try {
String text = streamReader.getElementText();
uuid = UUID.fromString(text);
// getElementText() advances to end of element
requireNextEndElement(field);
} catch (XMLStreamException e) {
throw new UaSerializationException(StatusCodes.Bad_DecodingError, e);
}
} else {
uuid = new UUID(0, 0);
requireCurrentElement(field);
}
return uuid;
}
示例2: decodeNodeId
import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@Override
public NodeId decodeNodeId(String field) throws UaSerializationException {
requireNextStartElement(field);
NodeId nodeId;
if (nextStartElement("Identifier")) {
try {
String text = streamReader.getElementText();
nodeId = NodeId.parse(text);
// getElementText() advances to end of element
requireNextEndElement(field);
} catch (XMLStreamException e) {
throw new UaSerializationException(StatusCodes.Bad_DecodingError, e);
}
} else {
nodeId = NodeId.NULL_VALUE;
}
return nodeId;
}
示例3: decodeVariant
import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@Override
public Variant decodeVariant(String field) {
if (nextStartElement(field)) {
Object value = null;
if (nextStartElement("Value")) {
try {
value = decodeVariantValue();
} catch (XMLStreamException e) {
throw new UaSerializationException(StatusCodes.Bad_DecodingError, e);
}
requireNextEndElement("Value");
}
requireNextEndElement(field);
return new Variant(value);
} else {
return Variant.NULL_VALUE;
}
}
示例4: decodeXmlElement
import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@Override
public XmlElement decodeXmlElement(String field) throws UaSerializationException {
ByteString byteString = decodeByteString(null);
byte[] bs = byteString.bytes();
if (bs == null) {
return new XmlElement(null);
} else {
try {
String fragment = new String(bs, "UTF-8");
return new XmlElement(fragment);
} catch (UnsupportedEncodingException e) {
throw new UaSerializationException(StatusCodes.Bad_DecodingError, e);
}
}
}
示例5: decodeExtensionObject
import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@Override
public ExtensionObject decodeExtensionObject(String field) throws UaSerializationException {
NodeId encodingTypeId = decodeNodeId(null);
int encoding = buffer.readByte();
if (encoding == 0) {
return new ExtensionObject((ByteString) null, encodingTypeId);
} else if (encoding == 1) {
ByteString byteString = decodeByteString(null);
return new ExtensionObject(byteString, encodingTypeId);
} else if (encoding == 2) {
XmlElement xmlElement = decodeXmlElement(null);
return new ExtensionObject(xmlElement, encodingTypeId);
} else {
throw new UaSerializationException(StatusCodes.Bad_DecodingError, "unknown ExtensionObject encoding: " + encoding);
}
}
示例6: getDecoder
import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> DecoderDelegate<T> getDecoder(T t) throws UaSerializationException {
try {
return (DecoderDelegate<T>) decodersByClass.get(t.getClass());
} catch (NullPointerException e) {
throw new UaSerializationException(StatusCodes.Bad_DecodingError,
"no decoder registered for class=" + t);
}
}
示例7: decodeFromXmlElement
import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@Override
public Object decodeFromXmlElement(XmlElement encoded, NodeId encodingTypeId) {
try {
DecoderDelegate<Object> delegate = DelegateRegistry.getDecoder(encodingTypeId);
XmlDecoder decoder = new XmlDecoder();
decoder.setInput(new StringReader(encoded.getFragment()));
return delegate.decode(decoder);
} catch (XMLStreamException e) {
throw new UaSerializationException(StatusCodes.Bad_DecodingError, e);
}
}
示例8: encodeXmlElement
import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@Override
public void encodeXmlElement(String field, XmlElement value) throws UaSerializationException {
if (value == null || value.isNull()) {
buffer.writeInt(-1);
} else {
try {
encodeByteString(null, new ByteString(value.getFragment().getBytes("UTF-8")));
} catch (UnsupportedEncodingException e) {
throw new UaSerializationException(StatusCodes.Bad_DecodingError, e);
}
}
}
示例9: getNextStartElement
import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
private String getNextStartElement() throws UaSerializationException {
try {
streamReader.nextTag();
if (streamReader.getEventType() == XMLStreamConstants.START_ELEMENT) {
return streamReader.getLocalName();
} else {
throw new UaSerializationException(StatusCodes.Bad_DecodingError, "expected start element");
}
} catch (XMLStreamException e) {
throw new UaSerializationException(StatusCodes.Bad_DecodingError, e);
}
}
示例10: nextEndElement
import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
private boolean nextEndElement(String element) throws UaSerializationException {
try {
if (element == null || element.isEmpty()) return true;
streamReader.nextTag();
return streamReader.getEventType() == XMLStreamConstants.END_ELEMENT &&
element.equals(streamReader.getLocalName());
} catch (XMLStreamException e) {
throw new UaSerializationException(StatusCodes.Bad_DecodingError, e);
}
}
示例11: readCharacterContent
import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
private String readCharacterContent() throws UaSerializationException {
try {
while (streamReader.hasNext()) {
streamReader.next();
if (streamReader.getEventType() == XMLStreamReader.CHARACTERS) {
return streamReader.getText();
}
}
throw new UaSerializationException(StatusCodes.Bad_DecodingError, "no character content found");
} catch (XMLStreamException e) {
throw new UaSerializationException(StatusCodes.Bad_DecodingError, e);
}
}
示例12: decodeNodeId
import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@Override
public NodeId decodeNodeId(String field) throws UaSerializationException {
int format = buffer.readByte() & 0x0F;
if (format == 0x00) {
/* Two-byte format */
return new NodeId(Unsigned.ushort(0), Unsigned.uint(buffer.readUnsignedByte()));
} else if (format == 0x01) {
/* Four-byte format */
return new NodeId(Unsigned.ushort(buffer.readUnsignedByte()), Unsigned.uint(buffer.readUnsignedShort()));
} else if (format == 0x02) {
/* Numeric format */
return new NodeId(Unsigned.ushort(buffer.readUnsignedShort()), Unsigned.uint(buffer.readUnsignedInt()));
} else if (format == 0x03) {
/* String format */
return new NodeId(Unsigned.ushort(buffer.readUnsignedShort()), decodeString(null));
} else if (format == 0x04) {
/* Guid format */
return new NodeId(Unsigned.ushort(buffer.readUnsignedShort()), decodeGuid(null));
} else if (format == 0x05) {
/* Opaque format */
return new NodeId(Unsigned.ushort(buffer.readUnsignedShort()), decodeByteString(null));
} else {
throw new UaSerializationException(StatusCodes.Bad_DecodingError, "invalid NodeId format: " + format);
}
}
示例13: decodeBuiltinType
import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
private Object decodeBuiltinType(int typeId) throws UaSerializationException {
switch (typeId) {
case 1: return decodeBoolean(null);
case 2: return decodeSByte(null);
case 3: return decodeByte(null);
case 4: return decodeInt16(null);
case 5: return decodeUInt16(null);
case 6: return decodeInt32(null);
case 7: return decodeUInt32(null);
case 8: return decodeInt64(null);
case 9: return decodeUInt64(null);
case 10: return decodeFloat(null);
case 11: return decodeDouble(null);
case 12: return decodeString(null);
case 13: return decodeDateTime(null);
case 14: return decodeGuid(null);
case 15: return decodeByteString(null);
case 16: return decodeXmlElement(null);
case 17: return decodeNodeId(null);
case 18: return decodeExpandedNodeId(null);
case 19: return decodeStatusCode(null);
case 20: return decodeQualifiedName(null);
case 21: return decodeLocalizedText(null);
case 22: return decodeExtensionObject(null);
case 23: return decodeDataValue(null);
case 24: return decodeVariant(null);
case 25: return decodeDiagnosticInfo(null);
default: throw new UaSerializationException(StatusCodes.Bad_DecodingError, "unknown builtin type: " + typeId);
}
}
示例14: decodeBuiltinType
import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
private Object decodeBuiltinType(String type) throws UaSerializationException {
switch (type) {
case "Boolean":
return decodeBoolean(null);
case "SByte":
return decodeSByte(null);
case "Byte":
return decodeByte(null);
case "Int16":
return decodeInt16(null);
case "UInt16":
return decodeUInt16(null);
case "Int32":
return decodeInt32(null);
case "UInt32":
return decodeUInt32(null);
case "Int64":
return decodeInt64(null);
case "UInt64":
return decodeUInt64(null);
case "Float":
return decodeFloat(null);
case "Double":
return decodeDouble(null);
case "String":
return decodeString(null);
case "DateTime":
return decodeDateTime(null);
case "Guid":
return decodeGuid(null);
case "ByteString":
return decodeByteString(null);
case "XmlElement":
return decodeXmlElement(null);
case "NodeId":
return decodeNodeId(null);
case "ExpandedNodeId":
return decodeExpandedNodeId(null);
case "StatusCode":
return decodeStatusCode(null);
case "QualifiedName":
return decodeQualifiedName(null);
case "LocalizedText":
return decodeLocalizedText(null);
case "ExtensionObject":
return decodeExtensionObject(null);
case "DataValue":
return decodeDataValue(null);
case "Variant":
return decodeVariant(null);
case "DiagnosticInfo":
return decodeDiagnosticInfo(null);
default:
throw new UaSerializationException(StatusCodes.Bad_DecodingError, "unknown builtin type: " + type);
}
}
示例15: encodeBuiltinType
import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
private void encodeBuiltinType(int typeId, Object value) throws UaSerializationException {
switch (typeId) {
case 1:
encodeBoolean(null, (Boolean) value);
break;
case 2:
encodeSByte(null, (Byte) value);
break;
case 3:
encodeByte(null, (UByte) value);
break;
case 4:
encodeInt16(null, (Short) value);
break;
case 5:
encodeUInt16(null, (UShort) value);
break;
case 6:
encodeInt32(null, (Integer) value);
break;
case 7:
encodeUInt32(null, (UInteger) value);
break;
case 8:
encodeInt64(null, (Long) value);
break;
case 9:
encodeUInt64(null, (ULong) value);
break;
case 10:
encodeFloat(null, (Float) value);
break;
case 11:
encodeDouble(null, (Double) value);
break;
case 12:
encodeString(null, (String) value);
break;
case 13:
encodeDateTime(null, (DateTime) value);
break;
case 14:
encodeGuid(null, (UUID) value);
break;
case 15:
encodeByteString(null, (ByteString) value);
break;
case 16:
encodeXmlElement(null, (XmlElement) value);
break;
case 17:
encodeNodeId(null, (NodeId) value);
break;
case 18:
encodeExpandedNodeId(null, (ExpandedNodeId) value);
break;
case 19:
encodeStatusCode(null, (StatusCode) value);
break;
case 20:
encodeQualifiedName(null, (QualifiedName) value);
break;
case 21:
encodeLocalizedText(null, (LocalizedText) value);
break;
case 22:
encodeExtensionObject(null, (ExtensionObject) value);
break;
case 23:
encodeDataValue(null, (DataValue) value);
break;
case 24:
encodeVariant(null, (Variant) value);
break;
case 25:
encodeDiagnosticInfo(null, (DiagnosticInfo) value);
break;
default:
throw new UaSerializationException(StatusCodes.Bad_DecodingError, "unknown builtin type: " + typeId);
}
}