KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jgroups.protocols;
2
3
4 import org.jgroups.Header;
5 import org.jgroups.util.Streamable;
6
7 import java.io.*;
8
9
10
11 /**
12  * Generic transport header, used by TP.
13  * @author Bela Ban
14  * @version $Id: TpHeader.java,v 1.4 2007/05/01 10:55:10 belaban Exp $
15  */

16 public class TpHeader extends Header implements Streamable {
17     public String JavaDoc channel_name=null;
18     int size=0;
19
20     public TpHeader() {
21     } // used for externalization
22

23     public TpHeader(String JavaDoc n) {
24         channel_name=n;
25         if(channel_name != null)
26             size=channel_name.length()+2; // +2 for writeUTF()
27
}
28
29     public String JavaDoc toString() {
30         return "[channel_name=" + channel_name + ']';
31     }
32
33
34     public int size() {
35         return size;
36     }
37
38     public void writeExternal(ObjectOutput out) throws IOException {
39         out.writeUTF(channel_name);
40     }
41
42
43     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException JavaDoc {
44         channel_name=in.readUTF();
45     }
46
47
48     public void writeTo(DataOutputStream out) throws IOException {
49         out.writeUTF(channel_name);
50     }
51
52     public void readFrom(DataInputStream in) throws IOException, IllegalAccessException JavaDoc, InstantiationException JavaDoc {
53         channel_name=in.readUTF();
54         if(channel_name != null)
55             size=channel_name.length()+2; // +2 for writeUTF()
56
}
57 }
58
Popular Tags