KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > jbi > framework > ComponentNameSpace


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.servicemix.jbi.framework;
18
19 import java.io.Externalizable JavaDoc;
20 import java.io.IOException JavaDoc;
21 import java.io.ObjectInput JavaDoc;
22 import java.io.ObjectOutput JavaDoc;
23
24 /**
25  * Component Name is used internally to identify a Component.
26  *
27  * @version $Revision: 426415 $
28  */

29 public class ComponentNameSpace implements Externalizable JavaDoc {
30    
31     /**
32      * Generated serial version UID
33      */

34     private static final long serialVersionUID = -9130913368962887486L;
35     
36     protected String JavaDoc containerName;
37     protected String JavaDoc name;
38
39     /**
40      * Default Constructor
41      */

42     public ComponentNameSpace() {
43     }
44
45     /**
46      * Construct a ComponentName
47      *
48      * @param containerName
49      * @param componentName
50      * @param componentId
51      */

52     public ComponentNameSpace(String JavaDoc containerName, String JavaDoc componentName) {
53         this.containerName = containerName;
54         this.name = componentName;
55     }
56     
57     /**
58      * @return Returns the componentName.
59      */

60     public String JavaDoc getName() {
61         return name;
62     }
63
64     /**
65      * @param componentName The componentName to set.
66      */

67     public void setName(String JavaDoc componentName) {
68         this.name = componentName;
69     }
70
71     /**
72      * @return Returns the containerName.
73      */

74     public String JavaDoc getContainerName() {
75         return containerName;
76     }
77
78     /**
79      * @param containerName The containerName to set.
80      */

81     public void setContainerName(String JavaDoc containerName) {
82         this.containerName = containerName;
83     }
84     
85     /**
86      * @param obj
87      * @return true if obj is equivalent to 'this'
88      */

89     public boolean equals(Object JavaDoc obj) {
90         boolean result = false;
91         if (obj != null && obj instanceof ComponentNameSpace) {
92             ComponentNameSpace other = (ComponentNameSpace) obj;
93             result = other.containerName.equals(this.containerName)
94                     && other.name.equals(this.name);
95         }
96         return result;
97     }
98     
99     /**
100      * @return the hashCode
101      */

102     public int hashCode() {
103         return containerName.hashCode() ^ name.hashCode();
104     }
105     
106     /**
107      * @return pretty print
108      */

109     public String JavaDoc toString() {
110         return "[container=" + containerName + ",name=" + name + "]";
111     }
112
113     /**
114      * write out to stream
115      * @param out
116      * @throws IOException
117      */

118     public void writeExternal(ObjectOutput JavaDoc out) throws IOException JavaDoc {
119         out.writeUTF(containerName != null ? containerName : "");
120         out.writeUTF(name != null ? name : "");
121     }
122
123     /**
124      * read from Stream
125      * @param in
126      * @throws IOException
127      * @throws ClassNotFoundException
128      */

129     public void readExternal(ObjectInput JavaDoc in) throws IOException JavaDoc, ClassNotFoundException JavaDoc {
130         containerName = in.readUTF();
131         name = in.readUTF();
132     }
133     
134     /**
135      * copy this
136      * @return
137      */

138     public ComponentNameSpace copy() {
139         ComponentNameSpace result = new ComponentNameSpace(containerName, name);
140         return result;
141     }
142     
143 }
144
Popular Tags