View Javadoc

1   package net.sourceforge.simplegamenet.framework.transport;
2   
3   import java.io.Serializable;
4   
5   public class Packet implements Serializable {
6   
7       private int packetCode;
8       private Serializable data;
9   
10      public Packet() {
11          setPacketCode(0);
12          setData(null);
13      }
14  
15      public Packet(int packetCode, Serializable data) {
16          this.setPacketCode(packetCode);
17          this.setData(data);
18      }
19  
20      public String toString() {
21          return "Packet(" + Integer.toString(getPacketCode(), 16) + ", "
22                  + (getData() != null ? getData().toString() : "null") + ")";
23      }
24  
25      public int getPacketCode() {
26          return packetCode;
27      }
28  
29      public void setPacketCode(int packetCode) {
30          this.packetCode = packetCode;
31      }
32  
33      public Serializable getData() {
34          return data;
35      }
36  
37      public void setData(Serializable data) {
38          this.data = data;
39      }
40  
41  }