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:
006: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
007: * This code is licensed under the GPL 2.0 license, availible at the root
008: * application directory.
009: */
010: package org.vfny.geoserver.global.dto;
011:
012: import java.util.Map;
013:
014: /**
015: * Data Transfer Object for communication GeoServer Web Map Server information.
016: *
017: * <p>
018: * Information required for GeoServer to set up a Web Map Service.
019: * </p>
020: *
021: * <p>
022: * Data Transfer object are used to communicate between the GeoServer
023: * application and its configuration and persistent layers. As such the class
024: * is final - to allow for its future use as an on-the-wire message.
025: * </p>
026: *
027: * @author dzwiers, Refractions Research, Inc.
028: * @version $Id: WMSDTO.java 7128 2007-06-29 15:17:56Z aaime $
029: */
030: public final class WMSDTO implements DataTransferObject {
031: /** For the writer! */
032: private boolean gmlPrefixing;
033:
034: /** The service parameters for this instance. */
035: private ServiceDTO service;
036:
037: /** The current svg renderer **/
038: private String svgRenderer;
039:
040: /** The antialisaing hint for the svg renderer **/
041: private boolean svgAntiAlias;
042:
043: /** The interpolation rendering hint **/
044: private Map baseMapLayers;
045: private Map baseMapStyles;
046: private Map baseMapEnvelopes;
047:
048: /** The interpolation rendering hint */
049: private String allowInterpolation;
050:
051: /**
052: * WMS constructor. does nothing
053: */
054: public WMSDTO() {
055: }
056:
057: /**
058: * WMS constructor.
059: *
060: * <p>
061: * Creates a copy of the WMS provided. If the WMS provided is null then
062: * default values are used. All the data structures are cloned.
063: * </p>
064: *
065: * @param other The WMS to copy.
066: *
067: * @throws NullPointerException DOCUMENT ME!
068: */
069: public WMSDTO(WMSDTO other) {
070: if (other == null) {
071: throw new NullPointerException(
072: "Data Transfer Object required");
073: }
074:
075: service = (ServiceDTO) other.getService().clone();
076: gmlPrefixing = other.isGmlPrefixing();
077: svgRenderer = other.getSvgRenderer();
078: svgAntiAlias = other.getSvgAntiAlias();
079: allowInterpolation = other.getAllowInterpolation();
080: baseMapLayers = other.getBaseMapLayers();
081: baseMapStyles = other.getBaseMapStyles();
082: baseMapEnvelopes = other.getBaseMapEnvelopes();
083: }
084:
085: /**
086: * Implement clone as a DeepCopy.
087: *
088: * @return A Deep Copy of this WMSDTO
089: *
090: * @see java.lang.Object#clone()
091: */
092: public Object clone() {
093: return new WMSDTO(this );
094: }
095:
096: /**
097: * Implement equals.
098: *
099: * <p>
100: * recursively tests to determine if the object passed in is a copy of this
101: * object.
102: * </p>
103: *
104: * @param other The WMS object to test.
105: *
106: * @return true when the object passed is the same as this object.
107: *
108: * @see java.lang.Object#equals(java.lang.Object)
109: */
110: public boolean equals(Object other) {
111: if ((other == null) || !(other instanceof WMSDTO)) {
112: return false;
113: }
114:
115: WMSDTO dto = (WMSDTO) other;
116:
117: boolean equals = (gmlPrefixing == dto.gmlPrefixing)
118: && (svgAntiAlias == dto.svgAntiAlias)
119: && (allowInterpolation == dto.allowInterpolation);
120:
121: if (equals) {
122: if (service == null) {
123: equals = dto.getService() == null;
124: } else {
125: equals = service.equals(dto.getService());
126: }
127: }
128:
129: if (equals) {
130: if (svgRenderer == null) {
131: equals = dto.getSvgRenderer() == null;
132: } else {
133: equals = svgRenderer.equals(dto.getSvgRenderer());
134: }
135: }
136:
137: if (equals) {
138: if (baseMapLayers == null) {
139: equals = dto.getBaseMapLayers() == null;
140: } else {
141: equals = baseMapLayers.equals(dto.getBaseMapLayers());
142: }
143: }
144:
145: if (equals) {
146: if (baseMapStyles == null) {
147: equals = dto.getBaseMapStyles() == null;
148: } else {
149: equals = baseMapStyles.equals(dto.getBaseMapStyles());
150: }
151: }
152:
153: if (equals) {
154: if (baseMapEnvelopes == null) {
155: equals = dto.getBaseMapEnvelopes() == null;
156: } else {
157: equals = baseMapEnvelopes.equals(dto
158: .getBaseMapEnvelopes());
159: }
160: }
161:
162: return equals;
163: }
164:
165: /**
166: * Implement hashCode.
167: *
168: * @return Service hashcode or 0
169: *
170: * @see java.lang.Object#hashCode()
171: */
172: public int hashCode() {
173: return (gmlPrefixing ? 1 : 0)
174: | (svgAntiAlias ? 1 : 0)
175: | ((allowInterpolation != null) ? 0
176: : allowInterpolation.hashCode())
177: | ((service == null) ? 0 : service.hashCode())
178: | ((svgRenderer == null) ? 0 : svgRenderer.hashCode())
179: | ((baseMapLayers == null) ? 0 : baseMapLayers
180: .hashCode())
181: | ((baseMapStyles == null) ? 0 : baseMapStyles
182: .hashCode())
183: | ((baseMapEnvelopes == null) ? 0 : baseMapEnvelopes
184: .hashCode());
185: }
186:
187: /**
188: * getService purpose.
189: *
190: * <p>
191: * Description ...
192: * </p>
193: *
194: * @return
195: */
196: public ServiceDTO getService() {
197: return service;
198: }
199:
200: /**
201: * setService purpose.
202: *
203: * <p>
204: * Description ...
205: * </p>
206: *
207: * @param service
208: *
209: * @throws NullPointerException DOCUMENT ME!
210: */
211: public void setService(ServiceDTO service) {
212: if (service == null) {
213: throw new NullPointerException("ServiceDTO required");
214: }
215:
216: this .service = service;
217: }
218:
219: /**
220: * isGmlPrefixing purpose.
221: *
222: * <p>
223: * Description ...
224: * </p>
225: *
226: * @return
227: */
228: public boolean isGmlPrefixing() {
229: return gmlPrefixing;
230: }
231:
232: /**
233: * setGmlPrefixing purpose.
234: *
235: * <p>
236: * Description ...
237: * </p>
238: *
239: * @param b
240: */
241: public void setGmlPrefixing(boolean b) {
242: gmlPrefixing = b;
243: }
244:
245: /**
246: * @return The constant identifying the current svg renderer.
247: * @see org.vfny.geoserver.config.WMSConfig#SVG_SIMPLE
248: * @see org.vfny.geoserver.config.WMSConfig#SVG_BATIK
249: */
250: public String getSvgRenderer() {
251: return svgRenderer;
252: }
253:
254: /**
255: * @param The constant identifying the current svg renderer.
256: * @see org.vfny.geoserver.config.WMSConfig#SVG_SIMPLE
257: * @see org.vfny.geoserver.config.WMSConfig#SVG_BATIK
258: */
259: public void setSvgRenderer(String svgRenderer) {
260: this .svgRenderer = svgRenderer;
261: }
262:
263: /**
264: * @param svgAntiAlias anti alias hint.
265: */
266: public void setSvgAntiAlias(boolean svgAntiAlias) {
267: this .svgAntiAlias = svgAntiAlias;
268: }
269:
270: /**
271: * @return The value of the anti aliasing rendering hint.
272: */
273: public boolean getSvgAntiAlias() {
274: return svgAntiAlias;
275: }
276:
277: public void setBaseMapLayers(Map layers) {
278: baseMapLayers = layers;
279: }
280:
281: public Map getBaseMapLayers() {
282: return baseMapLayers;
283: }
284:
285: public void setBaseMapStyles(Map styles) {
286: baseMapStyles = styles;
287: }
288:
289: public Map getBaseMapStyles() {
290: return baseMapStyles;
291: }
292:
293: public void setBaseMapEnvelopes(Map envelopes) {
294: baseMapEnvelopes = envelopes;
295: }
296:
297: public Map getBaseMapEnvelopes() {
298: return baseMapEnvelopes;
299: }
300:
301: /**
302: * @param allowInterpolation interpolation hint.
303: */
304: public void setAllowInterpolation(String allowInterpolation) {
305: this .allowInterpolation = allowInterpolation;
306: }
307:
308: /**
309: * @return The value of the interpolation rendering hint.
310: */
311: public String getAllowInterpolation() {
312: return allowInterpolation;
313: }
314: }
|