VersionMessage.java 1.7 KB

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