KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > deployment > plugin > TargetModuleIDImpl


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
18 package org.apache.geronimo.deployment.plugin;
19
20 import javax.enterprise.deploy.spi.TargetModuleID JavaDoc;
21 import javax.enterprise.deploy.spi.Target JavaDoc;
22 import javax.enterprise.deploy.shared.ModuleType JavaDoc;
23 import java.io.Serializable JavaDoc;
24
25 /**
26  *
27  *
28  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
29  */

30 public class TargetModuleIDImpl implements TargetModuleID JavaDoc, Serializable JavaDoc {
31     private String JavaDoc webURL;
32     private ModuleType JavaDoc type;
33     private final Target JavaDoc target;
34     private final String JavaDoc moduleID;
35     private final TargetModuleID JavaDoc parentTargetModuleID;
36     private final TargetModuleID JavaDoc[] childTargetModuleID;
37
38     public TargetModuleIDImpl(Target JavaDoc target, String JavaDoc moduleID) {
39         this.target = target;
40         this.moduleID = moduleID;
41         parentTargetModuleID = null;
42         childTargetModuleID = null;
43     }
44
45     public TargetModuleIDImpl(Target JavaDoc target, String JavaDoc moduleID, String JavaDoc[] childIDs) {
46         this.target = target;
47         this.moduleID = moduleID;
48         parentTargetModuleID = null;
49         if(childIDs == null || childIDs.length == 0) {
50             childTargetModuleID = null;
51         } else {
52             childTargetModuleID = new TargetModuleID JavaDoc[childIDs.length];
53             for (int i = 0; i < childIDs.length; i++) {
54                 String JavaDoc childID = childIDs[i];
55                 childTargetModuleID[i] = new TargetModuleIDImpl(target, childID, this);
56             }
57         }
58     }
59
60     private TargetModuleIDImpl(Target JavaDoc target, String JavaDoc moduleID, TargetModuleID JavaDoc parent) {
61         this.target = target;
62         this.moduleID = moduleID;
63         this.parentTargetModuleID = parent;
64         childTargetModuleID = null;
65     }
66
67     public Target JavaDoc getTarget() {
68         return target;
69     }
70
71     public String JavaDoc getModuleID() {
72         return moduleID;
73     }
74
75     public TargetModuleID JavaDoc getParentTargetModuleID() {
76         return parentTargetModuleID;
77     }
78
79     public TargetModuleID JavaDoc[] getChildTargetModuleID() {
80         return childTargetModuleID;
81     }
82
83     public String JavaDoc getWebURL() {
84         return webURL;
85     }
86
87     public void setWebURL(String JavaDoc webURL) {
88         this.webURL = webURL;
89     }
90
91     public ModuleType JavaDoc getType() {
92         return type;
93     }
94
95     public void setType(ModuleType JavaDoc type) {
96         this.type = type;
97     }
98
99     public String JavaDoc toString() {
100         return "[" + target + ", " + moduleID + "]";
101     }
102
103     public boolean equals(Object JavaDoc o) {
104         if (this == o) return true;
105         if (!(o instanceof TargetModuleIDImpl)) return false;
106
107         final TargetModuleIDImpl targetModuleID = (TargetModuleIDImpl) o;
108
109         if (!moduleID.equals(targetModuleID.moduleID)) return false;
110         if (!target.equals(targetModuleID.target)) return false;
111
112         return true;
113     }
114
115     public int hashCode() {
116         int result;
117         result = target.hashCode();
118         result = 29 * result + moduleID.hashCode();
119         return result;
120     }
121 }
122
Popular Tags