1 48 49 50 package org.exolab.jms.message; 51 52 53 import java.io.Externalizable ; 54 import java.io.IOException ; 55 import java.io.ObjectInput ; 56 import java.io.ObjectOutput ; 57 58 59 65 public class Type implements Externalizable { 66 67 static final long serialVersionUID = 1; 69 70 private String type_; 71 72 public Type() { 73 74 } 75 76 public Type(String type) { 77 type_ = type; 78 } 79 80 public void writeExternal(ObjectOutput out) throws IOException { 82 out.writeLong(serialVersionUID); 83 out.writeInt(type_.length()); 84 out.writeChars(type_); 85 } 86 87 88 public void readExternal(ObjectInput in) 90 throws IOException , ClassNotFoundException { 91 long version = in.readLong(); 92 if (version == serialVersionUID) { 93 int len = in.readInt(); 94 int i; 95 StringBuffer buf = new StringBuffer (len); 96 for (i = 0; i < len; i++) { 97 buf.append(in.readChar()); 98 } 99 type_ = buf.toString(); 100 } else { 101 throw new IOException ("Incorrect version enountered: " + 102 version + " This version = " + 103 serialVersionUID); 104 } 105 } 106 107 public String getType() { 108 return type_; 109 } 110 111 public boolean isEqual(Type toCompare) { 113 return (type_.equals(toCompare.type_)); 114 } 115 } 116 117 | Popular Tags |