use of org.eclipse.milo.opcua.stack.core.serialization.codecs.DataTypeCodec in project milo by eclipse.
the class OpcUaXmlStreamDecoder method readMessage.
@Override
public UaMessage readMessage(String field) throws UaSerializationException {
if (currentNode(field)) {
Node node = currentNode;
String typeName = node.getLocalName();
DataTypeCodec codec = context.getDataTypeManager().getCodec(Namespaces.OPC_UA_XSD, String.format("//xs:element[@name='%s']", typeName));
if (codec instanceof OpcUaXmlDataTypeCodec<?>) {
currentNode = node.getFirstChild();
try {
return (UaMessage) ((OpcUaXmlDataTypeCodec<?>) codec).decode(context, this);
} finally {
currentNode = node.getNextSibling();
}
} else {
throw new UaSerializationException(StatusCodes.Bad_DecodingError, "no codec registered: " + typeName);
}
} else {
// TODO could be better if we passed Class<?> into method
return null;
}
}
Aggregations