MessageRecord.java 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. package de.tudarmstadt.informatik.hostage.logging;
  2. import java.io.Serializable;
  3. import android.os.Parcel;
  4. import android.os.Parcelable;
  5. /**
  6. * Holds all necessary information about a single message exchanged during an attack.
  7. */
  8. public class MessageRecord implements Parcelable, Serializable{
  9. private static final long serialVersionUID = -5936572995202342935L;
  10. public static enum TYPE {
  11. SEND, RECEIVE
  12. };
  13. // attack
  14. private int id;
  15. private long attack_id;
  16. private long timestamp;
  17. private TYPE type;
  18. private String packet;
  19. public static final Parcelable.Creator<MessageRecord> CREATOR = new Parcelable.Creator<MessageRecord>() {
  20. @Override
  21. public MessageRecord createFromParcel(Parcel source) {
  22. return new MessageRecord(source);
  23. }
  24. @Override
  25. public MessageRecord[] newArray(int size) {
  26. return new MessageRecord[size];
  27. }
  28. };
  29. public MessageRecord() {
  30. }
  31. public MessageRecord(Parcel source) {
  32. this.id = source.readInt();
  33. this.attack_id = source.readLong();
  34. this.timestamp = source.readLong();
  35. this.type = TYPE.valueOf(source.readString());
  36. this.packet = source.readString();
  37. }
  38. @Override
  39. public int describeContents() {
  40. return 0;
  41. }
  42. @Override
  43. public void writeToParcel(Parcel dest, int flags) {
  44. dest.writeInt(id);
  45. dest.writeLong(attack_id);
  46. dest.writeLong(timestamp);
  47. dest.writeString(type.name());
  48. dest.writeString(packet);
  49. }
  50. /**
  51. * @return the id
  52. */
  53. public int getId() {
  54. return id;
  55. }
  56. /**
  57. * @param id the id to set
  58. */
  59. public void setId(int id) {
  60. this.id = id;
  61. }
  62. /**
  63. * @return the attack_id
  64. */
  65. public long getAttack_id() {
  66. return attack_id;
  67. }
  68. /**
  69. * @param attack_id the attack_id to set
  70. */
  71. public void setAttack_id(long attack_id) {
  72. this.attack_id = attack_id;
  73. }
  74. /**
  75. * @return the timestamp
  76. */
  77. public long getTimestamp() {
  78. return timestamp;
  79. }
  80. /**
  81. * @param timestamp the timestamp to set
  82. */
  83. public void setTimestamp(long timestamp) {
  84. this.timestamp = timestamp;
  85. }
  86. /**
  87. * @return the type
  88. */
  89. public TYPE getType() {
  90. return type;
  91. }
  92. /**
  93. * @param type the type to set
  94. */
  95. public void setType(TYPE type) {
  96. this.type = type;
  97. }
  98. /**
  99. * @return the packet
  100. */
  101. public String getPacket() {
  102. return packet;
  103. }
  104. /**
  105. * @param packet the packet to set
  106. */
  107. public void setPacket(String packet) {
  108. this.packet = packet;
  109. }
  110. }