1 18 package org.apache.activemq.kaha; 19 20 import java.io.Externalizable ; 21 import java.io.IOException ; 22 import java.io.ObjectInput ; 23 import java.io.ObjectOutput ; 24 29 public class ContainerId implements Externalizable { 30 private static final long serialVersionUID=-8883779541021821943L; 31 private Object key; 32 private String dataContainerName; 33 34 public ContainerId() { 35 } 36 37 public ContainerId(Object key,String dataContainerName) { 38 this.key=key; 39 this.dataContainerName=dataContainerName; 40 } 41 42 43 46 public String getDataContainerName(){ 47 return dataContainerName; 48 } 49 50 53 public void setDataContainerName(String dataContainerName){ 54 this.dataContainerName=dataContainerName; 55 } 56 57 60 public Object getKey(){ 61 return key; 62 } 63 64 67 public void setKey(Object key){ 68 this.key=key; 69 } 70 71 public int hashCode(){ 72 return key.hashCode(); 73 } 74 75 public boolean equals(Object obj){ 76 boolean result = false; 77 if (obj != null && obj instanceof ContainerId){ 78 ContainerId other = (ContainerId) obj; 79 result = other.key.equals(this.key); 80 } 81 return result; 82 } 83 84 public void writeExternal(ObjectOutput out) throws IOException { 85 out.writeUTF(getDataContainerName()); 86 out.writeObject(key); 87 } 88 89 public void readExternal(ObjectInput in) throws IOException ,ClassNotFoundException { 90 dataContainerName=in.readUTF(); 91 key=in.readObject(); 92 } 93 94 public String toString(){ 95 return "CID{"+dataContainerName + ":" + key + "}"; 96 } 97 } 98 | Popular Tags |