1 /**
2 *
3 * Copyright 2003-2004 The Apache Software Foundation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * 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;
21 import javax.enterprise.deploy.spi.Target;
22 import javax.enterprise.deploy.shared.ModuleType;
23 import java.io.Serializable;
24
25 /**
26 *
27 *
28 * @version $Rev: 355877 $ $Date: 2005-12-10 18:48:27 -0800 (Sat, 10 Dec 2005) $
29 */
30 public class TargetModuleIDImpl implements TargetModuleID, Serializable {
31 private String webURL;
32 private ModuleType type;
33 private final Target target;
34 private final String moduleID;
35 private final TargetModuleID parentTargetModuleID;
36 private final TargetModuleID[] childTargetModuleID;
37
38 public TargetModuleIDImpl(Target target, String moduleID) {
39 this.target = target;
40 this.moduleID = moduleID;
41 parentTargetModuleID = null;
42 childTargetModuleID = null;
43 }
44
45 public TargetModuleIDImpl(Target target, String moduleID, String[] 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[childIDs.length];
53 for (int i = 0; i < childIDs.length; i++) {
54 String childID = childIDs[i];
55 childTargetModuleID[i] = new TargetModuleIDImpl(target, childID, this);
56 }
57 }
58 }
59
60 private TargetModuleIDImpl(Target target, String moduleID, TargetModuleID parent) {
61 this.target = target;
62 this.moduleID = moduleID;
63 this.parentTargetModuleID = parent;
64 childTargetModuleID = null;
65 }
66
67 public Target getTarget() {
68 return target;
69 }
70
71 public String getModuleID() {
72 return moduleID;
73 }
74
75 public TargetModuleID getParentTargetModuleID() {
76 return parentTargetModuleID;
77 }
78
79 public TargetModuleID[] getChildTargetModuleID() {
80 return childTargetModuleID;
81 }
82
83 public String getWebURL() {
84 return webURL;
85 }
86
87 public void setWebURL(String webURL) {
88 this.webURL = webURL;
89 }
90
91 public ModuleType getType() {
92 return type;
93 }
94
95 public void setType(ModuleType type) {
96 this.type = type;
97 }
98
99 public String toString() {
100 return "[" + target + ", " + moduleID + "]";
101 }
102
103 public boolean equals(Object 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 }