Save This Page
Home » activemq-parent-5.3.1-source-release » org.apache » activemq » kaha » [javadoc | source]
    1   /**
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   package org.apache.activemq.kaha;
   18   
   19   import java.io.Externalizable;
   20   import java.io.IOException;
   21   import java.io.ObjectInput;
   22   import java.io.ObjectOutput;
   23   
   24   import org.apache.activemq.util.IOHelper;
   25   
   26   /**
   27    * Used by RootContainers
   28    * 
   29    * @version $Revision: 1.1.1.1 $
   30    */
   31   public class ContainerId implements Externalizable {
   32       private static final long serialVersionUID = -8883779541021821943L;
   33       private Object key;
   34       private String dataContainerName;
   35   
   36       public ContainerId() {
   37       }
   38   
   39       public ContainerId(Object key, String dataContainerName) {
   40           this.key = key;
   41           this.dataContainerName = dataContainerName;
   42       }
   43   
   44       /**
   45        * @return Returns the dataContainerPrefix.
   46        */
   47       public String getDataContainerName() {
   48           return dataContainerName;
   49       }
   50   
   51       /**
   52        * @return Returns the key.
   53        */
   54       public Object getKey() {
   55           return key;
   56       }
   57   
   58       public int hashCode() {
   59           return key.hashCode() ^ dataContainerName.hashCode();
   60       }
   61   
   62       public boolean equals(Object obj) {
   63           if (obj == null || obj.getClass() != ContainerId.class) {
   64               return false;
   65           }
   66           ContainerId other = (ContainerId)obj;
   67           return other.key.equals(this.key) && other.dataContainerName.equals(this.dataContainerName);
   68       }
   69   
   70       public void writeExternal(ObjectOutput out) throws IOException {
   71           out.writeUTF(getDataContainerName());
   72           out.writeObject(key);
   73       }
   74   
   75       public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   76           dataContainerName = in.readUTF();
   77           key = in.readObject();
   78       }
   79   
   80       public String toString() {
   81           return "CID{" + dataContainerName + ":" + key + "}";
   82       }
   83   }

Save This Page
Home » activemq-parent-5.3.1-source-release » org.apache » activemq » kaha » [javadoc | source]