KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgroups > protocols > FragHeader


1 package org.jgroups.protocols;
2
3 import org.jgroups.Header;
4 import org.jgroups.Global;
5 import org.jgroups.util.Streamable;
6
7 import java.io.*;
8
9 /**
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
19     public FragHeader() {
20     } // used for externalization
21

22     public FragHeader(long id, int frag_id, int num_frags) {
23         this.id=id;
24         this.frag_id=frag_id;
25         this.num_frags=num_frags;
26     }
27
28     public String JavaDoc toString() {
29         return "[id=" + id + ", frag_id=" + frag_id + ", num_frags=" + 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
39     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException JavaDoc {
40         id=in.readLong();
41         frag_id=in.readInt();
42         num_frags=in.readInt();
43     }
44
45
46     public void writeTo(DataOutputStream out) throws IOException {
47         out.writeLong(id);
48         out.writeInt(frag_id);
49         out.writeInt(num_frags);
50     }
51
52     public long size() {
53         return Global.LONG_SIZE + 2*Global.INT_SIZE;
54     }
55
56     public void readFrom(DataInputStream in) throws IOException, IllegalAccessException JavaDoc, InstantiationException JavaDoc {
57         id=in.readLong();
58         frag_id=in.readInt();
59         num_frags=in.readInt();
60     }
61
62 }
63
Popular Tags