1 48 49 package org.exolab.jms.message; 50 51 52 import java.io.Externalizable ; 53 import java.io.IOException ; 54 import java.io.ObjectInput ; 55 import java.io.ObjectOutput ; 56 57 import javax.jms.Destination ; 58 59 60 67 public class DestinationImpl 68 implements Cloneable , Destination , Externalizable { 69 70 static final long serialVersionUID = 1; 72 73 76 private String address_ = null; 77 78 public DestinationImpl() { 79 } 80 81 public DestinationImpl(String destination) { 82 address_ = destination; 83 } 84 85 public void writeExternal(ObjectOutput out) throws IOException { 87 out.writeLong(serialVersionUID); 88 out.writeInt(address_.length()); 89 out.writeChars(address_); 90 } 91 92 93 public void readExternal(ObjectInput in) 95 throws IOException , ClassNotFoundException { 96 long version = in.readLong(); 97 if (version == serialVersionUID) { 98 int len = in.readInt(); 99 int i; 100 StringBuffer buf = new StringBuffer (len); 101 for (i = 0; i < len; i++) { 102 buf.append(in.readChar()); 103 } 104 address_ = buf.toString(); 105 } else { 106 throw new IOException ("Incorrect version enountered: " + 107 version + " This version = " + 108 serialVersionUID); 109 } 110 } 111 112 public String getDestination() { 113 return address_; 114 } 115 116 117 121 public String toString() { 122 return "Topic name: " + (address_ == null ? "NONE" : address_); 123 } 124 125 public boolean isEqual(DestinationImpl toCompare) { 127 return (address_.equals(toCompare.address_)); 128 } 129 130 public Object clone() 132 throws CloneNotSupportedException { 133 return super.clone(); 134 } 135 } 136 137 | Popular Tags |