001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2004-2006, Geotools Project Managment Committee (PMC)
005: * (C) 2004 TOPP - www.openplans.org
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * Created on Jan 14, 2004
018: */
019: package org.geotools.validation.dto;
020:
021: import java.util.HashMap;
022: import java.util.Iterator;
023: import java.util.Map;
024:
025: /**
026: * TestConfig purpose.
027: *
028: * <p>
029: * Description of TestConfig ...
030: * </p>
031: *
032: * @author dzwiers, Refractions Research, Inc.
033: * @author $Author: dmzwiers $ (last modification)
034: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/extension/validation/src/main/java/org/geotools/validation/dto/TestDTO.java $
035: * @version $Id: TestDTO.java 20884 2006-08-07 14:10:46Z jgarnett $
036: */
037: public class TestDTO {
038: /** the test name */
039: private String name;
040:
041: /** the test description */
042: private String description;
043:
044: /**
045: * The plug-in which contains the class definition and default runtime
046: * values
047: */
048: private PlugInDTO plugIn;
049:
050: /**
051: * The set of runtime args for this particular test to override the
052: * defaults in the plug-in
053: */
054: private Map args;
055:
056: /**
057: * TestConfig constructor.
058: *
059: * <p>
060: * Does nothing
061: * </p>
062: */
063: public TestDTO() {
064: }
065:
066: /**
067: * TestConfig constructor.
068: *
069: * <p>
070: * Creates a copy from the TestConfig specified.
071: * </p>
072: *
073: * @param t the data to copy
074: */
075: public TestDTO(TestDTO t) {
076: name = t.getName();
077: description = t.getDescription();
078: plugIn = new PlugInDTO(t.getPlugIn());
079: args = new HashMap();
080:
081: if (t.getArgs() != null) {
082: Iterator i = t.getArgs().keySet().iterator();
083:
084: while (i.hasNext()) {
085: String key = (String) i.next();
086:
087: //TODO clone value.
088: args.put(key, new ArgumentDTO((ArgumentDTO) t.getArgs()
089: .get(key)));
090: }
091: }
092: }
093:
094: /**
095: * Implementation of clone.
096: *
097: * @return A copy of this TestConfig
098: *
099: * @see java.lang.Object#clone()
100: */
101: public Object clone() {
102: return new TestDTO(this );
103: }
104:
105: /**
106: * Implementation of equals.
107: *
108: * @param obj
109: *
110: * @return true when they have the same data.
111: *
112: * @see java.lang.Object#equals(java.lang.Object)
113: */
114: public boolean equals(Object obj) {
115: if ((obj == null) || !(obj instanceof TestDTO)) {
116: return false;
117: }
118:
119: TestDTO t = (TestDTO) obj;
120: boolean r = true;
121:
122: if (name != null) {
123: r = r && (name.equals(t.getName()));
124: }
125:
126: if (description != null) {
127: r = r && (description.equals(t.getDescription()));
128: }
129:
130: if (plugIn == null) {
131: if (t.getPlugIn() != null) {
132: return false;
133: }
134: } else {
135: if (t.getPlugIn() != null) {
136: r = r && plugIn.equals(t.getPlugIn());
137: } else {
138: return false;
139: }
140: }
141:
142: if (args == null) {
143: if (t.getArgs() != null) {
144: return false;
145: }
146: } else {
147: if (t.getArgs() != null) {
148: r = r && args.equals(t.getArgs());
149: } else {
150: return false;
151: }
152: }
153:
154: return r;
155: }
156:
157: /**
158: * Implementation of hashCode.
159: *
160: * @return int hashcode
161: *
162: * @see java.lang.Object#hashCode()
163: */
164: public int hashCode() {
165: int r = 1;
166:
167: if (name != null) {
168: r *= name.hashCode();
169: }
170:
171: if (description != null) {
172: r *= description.hashCode();
173: }
174:
175: if (plugIn != null) {
176: r *= plugIn.hashCode();
177: }
178:
179: if (args != null) {
180: r *= args.hashCode();
181: }
182:
183: return r;
184: }
185:
186: /**
187: * Access args property.
188: *
189: * @return Returns the args.
190: */
191: public Map getArgs() {
192: return args;
193: }
194:
195: /**
196: * Set args to args.
197: *
198: * @param args The args to set.
199: */
200: public void setArgs(Map args) {
201: this .args = args;
202: }
203:
204: /**
205: * Access description property.
206: *
207: * @return Returns the description.
208: */
209: public String getDescription() {
210: return description;
211: }
212:
213: /**
214: * Set description to description.
215: *
216: * @param description The description to set.
217: */
218: public void setDescription(String description) {
219: this .description = description;
220: }
221:
222: /**
223: * Access name property.
224: *
225: * @return Returns the name.
226: */
227: public String getName() {
228: return name;
229: }
230:
231: /**
232: * Set name to name.
233: *
234: * @param name The name to set.
235: */
236: public void setName(String name) {
237: this .name = name;
238: }
239:
240: /**
241: * Access plugIn property.
242: *
243: * @return Returns the plugIn.
244: */
245: public PlugInDTO getPlugIn() {
246: return plugIn;
247: }
248:
249: /**
250: * Set plugIn to plugIn.
251: *
252: * @param plugIn The plugIn to set.
253: */
254: public void setPlugIn(PlugInDTO plugIn) {
255: this.plugIn = plugIn;
256: }
257: }
|