01: // $Id: TunnelHeader.java,v 1.6 2006/01/24 16:01:08 belaban Exp $
02:
03: package org.jgroups.protocols;
04:
05: import org.jgroups.Header;
06: import org.jgroups.util.Streamable;
07: import org.jgroups.util.Util;
08:
09: import java.io.*;
10:
11: public class TunnelHeader extends Header implements Streamable {
12: public String channel_name = null;
13:
14: public TunnelHeader() {
15: } // used for externalization
16:
17: public TunnelHeader(String n) {
18: channel_name = n;
19: }
20:
21: public long size() {
22: return channel_name == null ? 1 : channel_name.length() + 3;
23: }
24:
25: public String toString() {
26: return "[TUNNEL:channel_name=" + channel_name + ']';
27: }
28:
29: public void writeExternal(ObjectOutput out) throws IOException {
30: out.writeObject(channel_name);
31: }
32:
33: public void readExternal(ObjectInput in) throws IOException,
34: ClassNotFoundException {
35: channel_name = (String) in.readObject();
36: }
37:
38: public void writeTo(DataOutputStream out) throws IOException {
39: Util.writeString(channel_name, out);
40: }
41:
42: public void readFrom(DataInputStream in) throws IOException,
43: IllegalAccessException, InstantiationException {
44: channel_name = Util.readString(in);
45: }
46:
47: }
|