001: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
002: * This code is licensed under the GPL 2.0 license, availible at the root
003: * application directory.
004: */
005: package org.vfny.geoserver.global.dto;
006:
007: import java.util.HashMap;
008: import java.util.Map;
009:
010: /**
011: * Data Transfer Object for GeoServer Format information.
012: *
013: * <p>
014: * Used to describe a Format, typically one specified in the catalog.xml
015: * config file.
016: * </p>
017: *
018: * <p>
019: * Data Transfer object are used to communicate between the GeoServer
020: * application and its configuration and persistent layers. As such the class
021: * is final - to allow for its future use as an on-the-wire message.
022: * </p>
023: * Example:<code> CoverageStoreInfoDTO dsiDto = new CoverageStoreInfoDTO();
024: * dsiDto.setIde("myFormat"); dsiDto.setEnabled(true); dsiDto.setTile("My
025: * Data Store"); Map m = new HashMap(); m.put("key","param");
026: * dsiDto.setConnectionParams(m); </code>
027: *
028: * @author dzwiers, Refractions Research, Inc.
029: * @author $Author: Alessio Fabiani (alessio.fabiani@gmail.com) $ (last modification)
030: * @author $Author: Simone Giannecchini (simboss1@gmail.com) $ (last modification)
031: * @version $Id: CoverageStoreInfoDTO.java 6326 2007-03-15 18:36:40Z jdeolive $
032: */
033: public final class CoverageStoreInfoDTO implements DataTransferObject {
034: /**
035: * unique Format identifier
036: *
037: * @uml.property name="id" multiplicity="(0 1)"
038: */
039: private String id;
040:
041: /**
042: * unique namespace to refer to this format
043: *
044: * @uml.property name="nameSpaceId" multiplicity="(0 1)"
045: */
046: private String nameSpaceId;
047:
048: /**
049: *
050: * @uml.property name="type" multiplicity="(0 1)"
051: */
052: private String type;
053:
054: /**
055: *
056: * @uml.property name="url" multiplicity="(0 1)"
057: */
058: private String url;
059:
060: /**
061: * true if this Format is enabled
062: *
063: * @uml.property name="enabled" multiplicity="(0 1)"
064: */
065: private boolean enabled;
066:
067: /**
068: * The title of this Format
069: *
070: * @uml.property name="title" multiplicity="(0 1)"
071: */
072: private String title;
073:
074: /** a short description about this Format */
075: private String _abstract;
076:
077: /**
078: * CoverageStoreInfo constructor.
079: *
080: * <p>
081: * does nothing
082: * </p>
083: */
084: public CoverageStoreInfoDTO() {
085: }
086:
087: /**
088: * CoverageStoreInfo constructor.
089: *
090: * <p>
091: * Creates a copy of the CoverageStoreInfo provided. If the CoverageStoreInfo
092: * provided is null then default values are used. All the datastructures
093: * are cloned.
094: * </p>
095: *
096: * @param dto The format to copy.
097: *
098: * @throws NullPointerException DOCUMENT ME!
099: */
100: public CoverageStoreInfoDTO(CoverageStoreInfoDTO dto) {
101: if (dto == null) {
102: throw new NullPointerException(
103: "Non-Null FormatDTO is requried");
104: }
105:
106: id = dto.getId();
107: nameSpaceId = dto.getNameSpaceId();
108: type = dto.getType();
109: url = dto.getUrl();
110: enabled = dto.isEnabled();
111: _abstract = dto.getAbstract();
112: }
113:
114: /**
115: * Implement clone.
116: *
117: * <p>
118: * creates a clone of this object
119: * </p>
120: *
121: * @return A copy of this CoverageStoreInfo
122: *
123: * @see java.lang.Object#clone()
124: */
125: public Object clone() {
126: return new CoverageStoreInfoDTO(this );
127: }
128:
129: /**
130: * Implement equals.
131: *
132: * <p>
133: * recursively tests to determine if the object passed in is a copy of this
134: * object.
135: * </p>
136: *
137: * @param obj The CoverageStoreInfo object to test.
138: *
139: * @return true when the object passed is the same as this object.
140: *
141: * @see java.lang.Object#equals(java.lang.Object)
142: */
143: public boolean equals(Object obj) {
144: if ((obj == null) || !(obj instanceof CoverageStoreInfoDTO)) {
145: return false;
146: }
147:
148: CoverageStoreInfoDTO ds = (CoverageStoreInfoDTO) obj;
149: boolean r = true;
150: r = r && (id == ds.getId());
151: r = r && (nameSpaceId == ds.getNameSpaceId());
152: r = r && (type == ds.getType());
153: r = r && (url == ds.getUrl());
154: r = r && (enabled == ds.isEnabled());
155: r = r && (_abstract == ds.getAbstract());
156:
157: return r;
158: }
159:
160: /**
161: * Implement hashCode.
162: *
163: * @return Service hashcode or 0
164: *
165: * @see java.lang.Object#hashCode()
166: */
167: public int hashCode() {
168: int r = 1;
169:
170: if (id != null) {
171: r *= id.hashCode();
172: }
173:
174: if (nameSpaceId != null) {
175: r *= nameSpaceId.hashCode();
176: }
177:
178: if (type != null) {
179: r *= type.hashCode();
180: }
181:
182: if (url != null) {
183: r *= url.hashCode();
184: }
185:
186: if (_abstract != null) {
187: r *= _abstract.hashCode();
188: }
189:
190: return r;
191: }
192:
193: /**
194: * Short description of Format
195: *
196: * @return Short description
197: */
198: public String getAbstract() {
199: return _abstract;
200: }
201:
202: /**
203: * Value is <code>true</code> if the Format should be enabled.
204: *
205: * @return ture if Format shoudl be enabled
206: */
207: public boolean isEnabled() {
208: return enabled;
209: }
210:
211: /**
212: * Unique identifier representing this Format.
213: *
214: * <p>
215: * This value is used to refer to this Format by CoverageInfoDTO.
216: * </p>
217: *
218: * @return an identifier, non null
219: *
220: * @uml.property name="id"
221: */
222: public String getId() {
223: return id;
224: }
225:
226: /**
227: * Title for Format, used in error messages & configuration.
228: *
229: * @return Title dor the Format
230: *
231: * @uml.property name="title"
232: */
233: public String getTitle() {
234: return title;
235: }
236:
237: /**
238: * Updates the Format abstract.
239: *
240: * @param description
241: */
242: public void setAbstract(String description) {
243: _abstract = description;
244: }
245:
246: /**
247: * setEnabled purpose.
248: *
249: * <p>
250: * Description ...
251: * </p>
252: *
253: * @param b
254: *
255: * @uml.property name="enabled"
256: */
257: public void setEnabled(boolean b) {
258: enabled = b;
259: }
260:
261: /**
262: * Sets the unique identifier for this CoverageStoreInfoDTO.
263: *
264: * @param identifier non<code>null</code> identifier for Format
265: *
266: * @uml.property name="id"
267: */
268: public void setId(String identifier) {
269: id = identifier;
270: }
271:
272: /**
273: * Set title used to identify this Format to the user.
274: *
275: * @param formatTitle Title used to identify Format to user
276: *
277: * @uml.property name="title"
278: */
279: public void setTitle(String formatTitle) {
280: title = formatTitle;
281: }
282:
283: /**
284: * @return Returns the type.
285: *
286: * @uml.property name="type"
287: */
288: public String getType() {
289: return type;
290: }
291:
292: /**
293: * @param type The type to set.
294: *
295: * @uml.property name="type"
296: */
297: public void setType(String type) {
298: this .type = type;
299: }
300:
301: /**
302: * @return Returns the url.
303: *
304: * @uml.property name="url"
305: */
306: public String getUrl() {
307: return url;
308: }
309:
310: /**
311: * @param url The url to set.
312: *
313: * @uml.property name="url"
314: */
315: public void setUrl(String url) {
316: this .url = url;
317: }
318:
319: public String getNameSpaceId() {
320: return nameSpaceId;
321: }
322:
323: public void setNameSpaceId(String nameSpaceId) {
324: this.nameSpaceId = nameSpaceId;
325: }
326: }
|