1 3 package org.jgroups.protocols; 4 5 6 import org.jgroups.Header; 7 import org.jgroups.util.Streamable; 8 9 import java.io.*; 10 11 12 13 14 public class UdpHeader extends Header implements Streamable { 15 public String channel_name=null; 16 int size=0; 17 18 public UdpHeader() { 19 } 21 public UdpHeader(String n) { 22 channel_name=n; 23 if(channel_name != null) 24 size=channel_name.length()+2; } 26 27 public String toString() { 28 return "[UDP:channel_name=" + channel_name + ']'; 29 } 30 31 32 public long size() { 33 return size; 34 } 35 36 public void writeExternal(ObjectOutput out) throws IOException { 37 out.writeUTF(channel_name); 38 } 39 40 41 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { 42 channel_name=in.readUTF(); 43 } 44 45 46 public void writeTo(DataOutputStream out) throws IOException { 47 out.writeUTF(channel_name); 48 } 49 50 public void readFrom(DataInputStream in) throws IOException, IllegalAccessException , InstantiationException { 51 channel_name=in.readUTF(); 52 if(channel_name != null) 53 size=channel_name.length()+2; } 55 } 56 | Popular Tags |