VersionMessage.java 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package at.acdp.urweb.sclient.data;
  2. import at.acdp.urweb.CountDataInputStream;
  3. import java.io.DataInputStream;
  4. import java.io.IOException;
  5. public class VersionMessage implements IRead {
  6. public int msgType;
  7. public long tstamp;
  8. public int source;
  9. public int robotMsgType;
  10. public String name;
  11. public int majorVersion;
  12. public int minorVersion;
  13. public int bugFixVersion;
  14. public int buildNumber;
  15. public String buildDate;
  16. public void read(CountDataInputStream in, int size) throws IOException {
  17. int before=in.getCount();
  18. int msgSize = in.readInt();
  19. msgType = in.readUnsignedByte();
  20. tstamp = in.readLong();
  21. source = in.readByte();
  22. robotMsgType = in.readByte();
  23. int projectNameSize = in.readUnsignedByte();
  24. byte[] nameBytes = new byte[projectNameSize];
  25. in.readFully(nameBytes);
  26. name = new String(nameBytes);
  27. majorVersion = in.readByte() & 0xff;
  28. minorVersion = in.readByte() & 0xff;
  29. bugFixVersion = in.readInt();
  30. buildNumber = in.readInt();
  31. byte[] buildDateBytes = new byte[msgSize - (16 + projectNameSize + 10)];
  32. in.readFully(buildDateBytes);
  33. buildDate = new String(buildDateBytes);
  34. int diff=in.getCount()-before;
  35. if(diff!=msgSize) {
  36. throw new RuntimeException("Versionmessage length mismatch: "+diff);
  37. }
  38. }
  39. @Override
  40. public String toString() {
  41. return "VersionMessage{" +
  42. "msgType=" + msgType +
  43. ", tstamp=" + tstamp +
  44. ", source=" + source +
  45. ", robotMsgType=" + robotMsgType +
  46. ", name='" + name + '\'' +
  47. ", majorVersion=" + majorVersion +
  48. ", minorVersion=" + minorVersion +
  49. ", bugFixVersion=" + bugFixVersion +
  50. ", buildNumber=" + buildNumber +
  51. ", buildDate='" + buildDate + '\'' +
  52. '}';
  53. }
  54. }