01: package org.jgroups.protocols;
02:
03: import org.jgroups.Header;
04: import org.jgroups.util.Streamable;
05:
06: import java.io.*;
07:
08: /**
09: * Generic transport header, used by TP.
10: * @author Bela Ban
11: * @version $Id: TpHeader.java,v 1.3 2005/07/17 11:36:15 chrislott Exp $
12: */
13: public class TpHeader extends Header implements Streamable {
14: public String channel_name = null;
15: int size = 0;
16:
17: public TpHeader() {
18: } // used for externalization
19:
20: public TpHeader(String n) {
21: channel_name = n;
22: if (channel_name != null)
23: size = channel_name.length() + 2; // +2 for writeUTF()
24: }
25:
26: public String toString() {
27: return "[channel_name=" + channel_name + ']';
28: }
29:
30: public long size() {
31: return size;
32: }
33:
34: public void writeExternal(ObjectOutput out) throws IOException {
35: out.writeUTF(channel_name);
36: }
37:
38: public void readExternal(ObjectInput in) throws IOException,
39: ClassNotFoundException {
40: channel_name = in.readUTF();
41: }
42:
43: public void writeTo(DataOutputStream out) throws IOException {
44: out.writeUTF(channel_name);
45: }
46:
47: public void readFrom(DataInputStream in) throws IOException,
48: IllegalAccessException, InstantiationException {
49: channel_name = in.readUTF();
50: if (channel_name != null)
51: size = channel_name.length() + 2; // +2 for writeUTF()
52: }
53: }
|