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: * PlugInConfig purpose.
027: *
028: * <p>
029: * Description of PlugInConfig ...
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/PlugInDTO.java $
035: * @version $Id: PlugInDTO.java 20884 2006-08-07 14:10:46Z jgarnett $
036: */
037: public class PlugInDTO {
038: /** the plug-in name */
039: private String name;
040:
041: /** the plug-in description */
042: private String description;
043:
044: /** the class name this plug-in represents */
045: private String className;
046:
047: /** the default arguments */
048: private Map args;
049:
050: /**
051: * PlugInDTO constructor.
052: *
053: * <p>
054: * Does nothing.
055: * </p>
056: */
057: public PlugInDTO() {
058: }
059:
060: /**
061: * PlugInDTO constructor.
062: *
063: * <p>
064: * Creates a copy of the DTO passed in in this object.
065: * </p>
066: *
067: * @param pi
068: */
069: public PlugInDTO(PlugInDTO pi) {
070: name = pi.getName();
071: description = pi.getDescription();
072: className = pi.getClassName();
073: args = new HashMap();
074:
075: if (pi.getArgs() != null) {
076: Iterator i = pi.getArgs().keySet().iterator();
077:
078: while (i.hasNext()) {
079: String key = (String) i.next();
080:
081: //TODO clone value.
082: args.put(key, new ArgumentDTO((ArgumentDTO) pi
083: .getArgs().get(key)));
084: }
085: }
086: }
087:
088: /**
089: * Implementation of clone.
090: *
091: * @return a copy of this class.
092: *
093: * @see java.lang.Object#clone()
094: */
095: public Object clone() {
096: return new PlugInDTO(this );
097: }
098:
099: /**
100: * Implementation of equals.
101: *
102: * @param obj
103: *
104: * @return true when the two objects are equal.
105: *
106: * @see java.lang.Object#equals(java.lang.Object)
107: */
108: public boolean equals(Object obj) {
109: if ((obj == null) || !(obj instanceof PlugInDTO)) {
110: return false;
111: }
112:
113: PlugInDTO pi = (PlugInDTO) obj;
114: boolean r = true;
115:
116: if (name != null) {
117: r = r && (name.equals(pi.getName()));
118: }
119:
120: if (description != null) {
121: r = r && (description.equals(pi.getDescription()));
122: }
123:
124: if (className != null) {
125: r = r && (className.equals(pi.getClassName()));
126: }
127:
128: if (args == null) {
129: if (pi.getArgs() != null) {
130: return false;
131: }
132: } else {
133: if (pi.getArgs() != null) {
134: r = r && args.equals(pi.getArgs());
135: } else {
136: return false;
137: }
138: }
139:
140: return r;
141: }
142:
143: /**
144: * Implementation of hashCode.
145: *
146: * @return the hashcode.
147: *
148: * @see java.lang.Object#hashCode()
149: */
150: public int hashCode() {
151: int i = 1;
152:
153: if (name != null) {
154: i *= name.hashCode();
155: }
156:
157: if (description != null) {
158: i *= description.hashCode();
159: }
160:
161: if (className != null) {
162: i *= className.hashCode();
163: }
164:
165: if (args != null) {
166: i *= args.hashCode();
167: }
168:
169: return i;
170: }
171:
172: /**
173: * Access args property.
174: *
175: * @return Returns the args.
176: */
177: public Map getArgs() {
178: return args;
179: }
180:
181: /**
182: * Set args to args.
183: *
184: * @param args The args to set.
185: */
186: public void setArgs(Map args) {
187: this .args = args;
188: }
189:
190: /**
191: * Access className property.
192: *
193: * @return Returns the className.
194: */
195: public String getClassName() {
196: return className;
197: }
198:
199: /**
200: * Set className to className.
201: *
202: * @param className The className to set.
203: */
204: public void setClassName(String className) {
205: this .className = className;
206: }
207:
208: /**
209: * Access description property.
210: *
211: * @return Returns the description.
212: */
213: public String getDescription() {
214: return description;
215: }
216:
217: /**
218: * Set description to description.
219: *
220: * @param description The description to set.
221: */
222: public void setDescription(String description) {
223: this .description = description;
224: }
225:
226: /**
227: * Access name property.
228: *
229: * @return Returns the name.
230: */
231: public String getName() {
232: return name;
233: }
234:
235: /**
236: * Set name to name.
237: *
238: * @param name The name to set.
239: */
240: public void setName(String name) {
241: this.name = name;
242: }
243: }
|