text: public final int serialize(int offset, byte[] data) {int dataSize = getDataSize();int recSize = 4 + dataSize;try (LittleEndianByteArrayOutputStream out =new LittleEndianByteArrayOutputStream(data, offset, recSize)) {out.writeShort(getSid());out.writeShort(dataSize);serialize(out);if (out.getWriteIndex() - offset != recSize) {throw new IllegalStateException("Error in serialization of (" + getClass().getName() + "): "+ "Incorrect number of bytes written - expected " + recSize + " but got "+ (out.getWriteIndex() - offset));}} catch (IOException ioe) {throw new IllegalStateException(ioe);}return recSize;}