01: package org.jgroups.protocols;
02:
03: import org.jgroups.Header;
04: import org.jgroups.Global;
05: import org.jgroups.util.Streamable;
06:
07: import java.io.*;
08:
09: /**
10: * @author Bela Ban
11: * @version $Id: FragHeader.java,v 1.2 2005/04/15 13:17:02 belaban Exp $
12: */
13: public class FragHeader extends Header implements Streamable {
14: public long id = 0;
15: public int frag_id = 0;
16: public int num_frags = 0;
17:
18: public FragHeader() {
19: } // used for externalization
20:
21: public FragHeader(long id, int frag_id, int num_frags) {
22: this .id = id;
23: this .frag_id = frag_id;
24: this .num_frags = num_frags;
25: }
26:
27: public String toString() {
28: return "[id=" + id + ", frag_id=" + frag_id + ", num_frags="
29: + num_frags + ']';
30: }
31:
32: public void writeExternal(ObjectOutput out) throws IOException {
33: out.writeLong(id);
34: out.writeInt(frag_id);
35: out.writeInt(num_frags);
36: }
37:
38: public void readExternal(ObjectInput in) throws IOException,
39: ClassNotFoundException {
40: id = in.readLong();
41: frag_id = in.readInt();
42: num_frags = in.readInt();
43: }
44:
45: public void writeTo(DataOutputStream out) throws IOException {
46: out.writeLong(id);
47: out.writeInt(frag_id);
48: out.writeInt(num_frags);
49: }
50:
51: public long size() {
52: return Global.LONG_SIZE + 2 * Global.INT_SIZE;
53: }
54:
55: public void readFrom(DataInputStream in) throws IOException,
56: IllegalAccessException, InstantiationException {
57: id = in.readLong();
58: frag_id = in.readInt();
59: num_frags = in.readInt();
60: }
61:
62: }
|