-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathData.java
70 lines (59 loc) · 1.4 KB
/
Data.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import java.io.IOException;
import java.io.DataInput;
import java.io.DataOutput;
import com.gemstone.gemfire.DataSerializable;
import com.gemstone.gemfire.DataSerializer;
public class Data implements DataSerializable {
private int id;
private String value;
private int price;
public Data() {
}
public Data(int i, String s, int p)
{
id = i;
value = s;
price =p;
}
public void setId(int i)
{
id=i;
}
public int getId()
{
return id;
}
public void setValue(String s)
{
value = s;
}
public String getValue()
{
return value;
}
public int getPrice()
{
return price;
}
public void setPrice(int p)
{
price=p;
}
public void fromData(DataInput in) throws IOException, ClassNotFoundException
{
try {
id = DataSerializer.readPrimitiveInt ( in );
value = DataSerializer.readString(in);
price = DataSerializer.readPrimitiveInt(in);
} catch ( Exception e ) {
System.out.println ( "Deserialize Error: " + e );
e.printStackTrace();
}
}
public void toData(DataOutput out) throws IOException
{
DataSerializer.writePrimitiveInt(id, out);
DataSerializer.writeString(value, out);
DataSerializer.writePrimitiveInt(price, out);
}
}