package at.acdp.urweb.sclient.data; import at.acdp.urweb.CountDataInputStream; import java.io.IOException; public class VersionMessage implements IRead { public int msgType; public long tstamp; public int source; public int robotMsgType; public String name; public int majorVersion; public int minorVersion; public int bugFixVersion; public int buildNumber; public String buildDate; @Override public String toString() { return "{\"VersionMessage\":{" + " \"msgType\":\"" + msgType + "\"" + ", \"tstamp\":\"" + tstamp + "\"" + ", \"source\":\"" + source + "\"" + ", \"robotMsgType\":\"" + robotMsgType + "\"" + ", \"name\":\"" + name + "\"" + ", \"majorVersion\":\"" + majorVersion + "\"" + ", \"minorVersion\":\"" + minorVersion + "\"" + ", \"bugFixVersion\":\"" + bugFixVersion + "\"" + ", \"buildNumber\":\"" + buildNumber + "\"" + ", \"buildDate\":\"" + buildDate + "\"" + "}}"; } public void read(CountDataInputStream in, int size) throws IOException { int before=in.getCount(); int msgSize = in.readInt(); msgType = in.readUnsignedByte(); tstamp = in.readLong(); source = in.readByte(); robotMsgType = in.readByte(); int projectNameSize = in.readUnsignedByte(); byte[] nameBytes = new byte[projectNameSize]; in.readFully(nameBytes); name = new String(nameBytes); majorVersion = in.readByte() & 0xff; minorVersion = in.readByte() & 0xff; bugFixVersion = in.readInt(); buildNumber = in.readInt(); byte[] buildDateBytes = new byte[msgSize - (16 + projectNameSize + 10)]; in.readFully(buildDateBytes); buildDate = new String(buildDateBytes); int diff=in.getCount()-before; if(diff!=msgSize) { throw new RuntimeException("Versionmessage length mismatch: "+diff); } } }