use of org.apache.plc4x.java.api.exceptions.PlcRuntimeException in project plc4x by apache.
the class PlcStruct method serialize.
@Override
public void serialize(WriteBuffer writeBuffer) throws SerializationException {
writeBuffer.pushContext("PlcStruct");
for (Map.Entry<String, PlcValue> entry : map.entrySet()) {
String fieldName = entry.getKey();
writeBuffer.pushContext(fieldName);
PlcValue fieldValue = entry.getValue();
if (!(fieldValue instanceof Serializable)) {
throw new PlcRuntimeException("Error serializing. List item doesn't implement XmlSerializable");
}
((Serializable) fieldValue).serialize(writeBuffer);
writeBuffer.pushContext(fieldName);
}
writeBuffer.popContext("PlcStruct");
}
use of org.apache.plc4x.java.api.exceptions.PlcRuntimeException in project plc4x by apache.
the class ReadBufferJsonBased method readLong.
@Override
public long readLong(String logicalName, int bitLength, WithReaderArgs... readerArgs) throws ParseException {
logicalName = sanitizeLogicalName(logicalName);
move(bitLength);
Map element = getElement(logicalName);
validateAttr(logicalName, element, rwIntKey, bitLength);
Integer value = (Integer) element.get(logicalName);
if (value == null) {
throw new PlcRuntimeException(String.format(REQUIRED_ELEMENT_NOT_FOUND, logicalName, stack.peek()));
}
return Long.valueOf(value);
}
use of org.apache.plc4x.java.api.exceptions.PlcRuntimeException in project plc4x by apache.
the class ReadBufferJsonBased method readUnsignedShort.
@Override
public short readUnsignedShort(String logicalName, int bitLength, WithReaderArgs... readerArgs) throws ParseException {
logicalName = sanitizeLogicalName(logicalName);
move(bitLength);
Map element = getElement(logicalName);
validateAttr(logicalName, element, rwUintKey, bitLength);
Integer value = (Integer) element.get(logicalName);
if (value == null) {
throw new PlcRuntimeException(String.format(REQUIRED_ELEMENT_NOT_FOUND, logicalName, stack.peek()));
}
return value.shortValue();
}
use of org.apache.plc4x.java.api.exceptions.PlcRuntimeException in project plc4x by apache.
the class ReadBufferJsonBased method readBigInteger.
@Override
public BigInteger readBigInteger(String logicalName, int bitLength, WithReaderArgs... readerArgs) throws ParseException {
logicalName = sanitizeLogicalName(logicalName);
move(bitLength);
Map element = getElement(logicalName);
validateAttr(logicalName, element, rwIntKey, bitLength);
Integer value = (Integer) element.get(logicalName);
if (value == null) {
throw new PlcRuntimeException(String.format(REQUIRED_ELEMENT_NOT_FOUND, logicalName, stack.peek()));
}
return BigInteger.valueOf(value);
}
use of org.apache.plc4x.java.api.exceptions.PlcRuntimeException in project plc4x by apache.
the class ReadBufferJsonBased method readUnsignedByte.
@Override
public byte readUnsignedByte(String logicalName, int bitLength, WithReaderArgs... readerArgs) throws ParseException {
logicalName = sanitizeLogicalName(logicalName);
move(bitLength);
Map element = getElement(logicalName);
validateAttr(logicalName, element, rwUintKey, bitLength);
Integer value = (Integer) element.get(logicalName);
if (value == null) {
throw new PlcRuntimeException(String.format(REQUIRED_ELEMENT_NOT_FOUND, logicalName, stack.peek()));
}
return value.byteValue();
}
Aggregations