KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > kaha > ContainerId


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.kaha;
19
20 import java.io.Externalizable JavaDoc;
21 import java.io.IOException JavaDoc;
22 import java.io.ObjectInput JavaDoc;
23 import java.io.ObjectOutput JavaDoc;
24 /**
25  * Used by RootContainers
26  *
27  * @version $Revision: 1.1.1.1 $
28  */

29 public class ContainerId implements Externalizable JavaDoc{
30     private static final long serialVersionUID=-8883779541021821943L;
31     private Object JavaDoc key;
32     private String JavaDoc dataContainerName;
33
34     public ContainerId() {
35     }
36     
37     public ContainerId(Object JavaDoc key,String JavaDoc dataContainerName) {
38         this.key=key;
39         this.dataContainerName=dataContainerName;
40     }
41     
42     
43     /**
44      * @return Returns the dataContainerPrefix.
45      */

46     public String JavaDoc getDataContainerName(){
47         return dataContainerName;
48     }
49
50     /**
51      * @param dataContainerName The dataContainerPrefix to set.
52      */

53     public void setDataContainerName(String JavaDoc dataContainerName){
54         this.dataContainerName=dataContainerName;
55     }
56
57     /**
58      * @return Returns the key.
59      */

60     public Object JavaDoc getKey(){
61         return key;
62     }
63
64     /**
65      * @param key The key to set.
66      */

67     public void setKey(Object JavaDoc key){
68         this.key=key;
69     }
70     
71     public int hashCode(){
72         return key.hashCode();
73     }
74     
75     public boolean equals(Object JavaDoc 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 JavaDoc out) throws IOException JavaDoc{
85         out.writeUTF(getDataContainerName());
86         out.writeObject(key);
87     }
88
89     public void readExternal(ObjectInput JavaDoc in) throws IOException JavaDoc,ClassNotFoundException JavaDoc{
90         dataContainerName=in.readUTF();
91         key=in.readObject();
92     }
93     
94     public String JavaDoc toString(){
95         return "CID{"+dataContainerName + ":" + key + "}";
96     }
97 }
98
Popular Tags