001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.geronimo.deployment.plugin;
017:
018: import javax.enterprise.deploy.spi.TargetModuleID;
019: import javax.enterprise.deploy.spi.Target;
020: import javax.enterprise.deploy.shared.ModuleType;
021: import java.io.Serializable;
022:
023: /**
024: *
025: *
026: * @version $Rev: 476049 $ $Date: 2006-11-16 20:35:17 -0800 (Thu, 16 Nov 2006) $
027: */
028: public class TargetModuleIDImpl implements TargetModuleID, Serializable {
029: private String webURL;
030: private ModuleType type;
031: private final Target target;
032: private final String moduleID;
033: private final TargetModuleID parentTargetModuleID;
034: private final TargetModuleID[] childTargetModuleID;
035:
036: public TargetModuleIDImpl(Target target, String moduleID) {
037: this .target = target;
038: this .moduleID = moduleID;
039: parentTargetModuleID = null;
040: childTargetModuleID = null;
041: }
042:
043: public TargetModuleIDImpl(Target target, String moduleID,
044: String[] childIDs) {
045: this .target = target;
046: this .moduleID = moduleID;
047: parentTargetModuleID = null;
048: if (childIDs == null || childIDs.length == 0) {
049: childTargetModuleID = null;
050: } else {
051: childTargetModuleID = new TargetModuleID[childIDs.length];
052: for (int i = 0; i < childIDs.length; i++) {
053: String childID = childIDs[i];
054: childTargetModuleID[i] = new TargetModuleIDImpl(target,
055: childID, this );
056: }
057: }
058: }
059:
060: private TargetModuleIDImpl(Target target, String moduleID,
061: TargetModuleID parent) {
062: this .target = target;
063: this .moduleID = moduleID;
064: this .parentTargetModuleID = parent;
065: childTargetModuleID = null;
066: }
067:
068: public Target getTarget() {
069: return target;
070: }
071:
072: public String getModuleID() {
073: return moduleID;
074: }
075:
076: public TargetModuleID getParentTargetModuleID() {
077: return parentTargetModuleID;
078: }
079:
080: public TargetModuleID[] getChildTargetModuleID() {
081: return childTargetModuleID;
082: }
083:
084: public String getWebURL() {
085: return webURL;
086: }
087:
088: public void setWebURL(String webURL) {
089: this .webURL = webURL;
090: }
091:
092: public ModuleType getType() {
093: return type;
094: }
095:
096: public void setType(ModuleType type) {
097: this .type = type;
098: }
099:
100: public String toString() {
101: return "[" + target + ", " + moduleID + "]";
102: }
103:
104: public boolean equals(Object o) {
105: if (this == o)
106: return true;
107: if (!(o instanceof TargetModuleIDImpl))
108: return false;
109:
110: final TargetModuleIDImpl targetModuleID = (TargetModuleIDImpl) o;
111:
112: if (!moduleID.equals(targetModuleID.moduleID))
113: return false;
114: if (!target.equals(targetModuleID.target))
115: return false;
116:
117: return true;
118: }
119:
120: public int hashCode() {
121: int result;
122: result = target.hashCode();
123: result = 29 * result + moduleID.hashCode();
124: return result;
125: }
126: }
|