001: /* This code is licensed under the GPL 2.0 license, availible at the root
002: * application directory.
003: */
004: package org.vfny.geoserver.global.dto;
005:
006: /**
007: * Data Transfer Object for legend information.
008: *
009: * <p>
010: * Defines the legend icon to be associated with a FeatureType.
011: * </p>
012: *
013: * <p>
014: * <pre>
015: * Example:<code>
016: * LegendDTO legend = new LegendDTO();
017: * legend.setOnlineResource("http://www.myserver.org/legends/legend1.png");
018: * legend.setWidth(72);
019: * legend.setHeight(72);
020: * legend.setFormat("image/png");
021: * </code>
022: * </pre>
023: * </p>
024: *
025: * @author Charles Kolbowicz, Institut de Recherche pour le D�veloppement
026: * (IRD), 2004
027: * @version $Id: LegendURLDTO.java 6177 2007-02-19 10:11:27Z aaime $
028: */
029: public final class LegendURLDTO implements DataTransferObject {
030: /** The legend icon width. */
031: private int width;
032:
033: /** The legend icon height. */
034: private int height;
035:
036: /** The legend icon format; */
037: private String format;
038:
039: /** The legend icon location. */
040: private String onlineResource;
041:
042: /**
043: * LegendConfig constructor.
044: *
045: * <p>
046: * does nothing
047: * </p>
048: */
049: public LegendURLDTO() {
050: }
051:
052: /**
053: * LegendConfig constructor.
054: *
055: * <p>
056: * Creates a copy of the LegendConfig provided. If the LegendConfig
057: * provided is null then default values are used. All the data structures
058: * are cloned.
059: * </p>
060: *
061: * @param legend The legend to copy.
062: *
063: * @throws NullPointerException DOCUMENT ME!
064: */
065: public LegendURLDTO(LegendURLDTO legend) {
066: if (legend == null) {
067: throw new NullPointerException();
068: }
069:
070: format = legend.getFormat();
071: width = legend.getWidth();
072: height = legend.getHeight();
073: onlineResource = legend.getOnlineResource();
074: }
075:
076: /**
077: * Implement clone.
078: *
079: * <p>
080: * creates a clone of this object
081: * </p>
082: *
083: * @return A copy of this LegendURLDTO
084: *
085: * @see java.lang.Object#clone()
086: */
087: public Object clone() {
088: return new LegendURLDTO(this );
089: }
090:
091: /**
092: * Implement equals.
093: *
094: * <p>
095: * recursively tests to determine if the object passed in is a copy of this
096: * object.
097: * </p>
098: *
099: * @param obj The LegendURLDTO object to test.
100: *
101: * @return true when the object passed is the same as this object.
102: *
103: * @see java.lang.Object#equals(java.lang.Object)
104: */
105: public boolean equals(Object obj) {
106: if ((obj == null) || !(obj instanceof LegendURLDTO)) {
107: return false;
108: }
109:
110: LegendURLDTO legend = (LegendURLDTO) obj;
111: boolean r = true;
112: r = r && (width == legend.getWidth());
113:
114: r = r && (height == legend.getHeight());
115:
116: r = r && (format.equals(legend.getFormat()));
117:
118: r = r && (onlineResource.equals(legend.getOnlineResource()));
119:
120: return r;
121: }
122:
123: /**
124: * Implement hashCode.
125: *
126: * @return Service hashcode or 0
127: *
128: * @see java.lang.Object#hashCode()
129: */
130: public int hashCode() {
131: int r = 1;
132:
133: r *= (width * height);
134:
135: if (format != null) {
136: r *= format.hashCode();
137: }
138:
139: if (onlineResource != null) {
140: r *= onlineResource.hashCode();
141: }
142:
143: return r;
144: }
145:
146: public String toString() {
147: return "LegendURL [" + width + ", " + height + "] - Type : "
148: + format + " - Location : " + onlineResource + "\n";
149: }
150:
151: /**
152: * Getter for legend icon width.
153: *
154: * @return Value of legend icon width;
155: */
156: public int getWidth() {
157: return this .width;
158: }
159:
160: /**
161: * Setter for legend icon width.
162: *
163: * @param width New value of legend icon width.
164: */
165: public void setWidth(int width) {
166: this .width = width;
167: }
168:
169: /**
170: * Getter for legend icon height.
171: *
172: * @return Value of legend icon height.
173: */
174: public int getHeight() {
175: return this .height;
176: }
177:
178: /**
179: * Setter for legend icon height.
180: *
181: * @param height New value of legend icon height.
182: */
183: public void setHeight(int height) {
184: this .height = height;
185: }
186:
187: /**
188: * Getter for legend icon format.
189: *
190: * @return Value of legend icon format.
191: */
192: public String getFormat() {
193: return this .format;
194: }
195:
196: /**
197: * Setter for legend icon format.
198: *
199: * @param format New value of legend icon format.
200: */
201: public void setFormat(String format) {
202: this .format = format;
203: }
204:
205: /**
206: * Getter for property onlineResource.
207: *
208: * @return Value of property onlineResource.
209: */
210: public String getOnlineResource() {
211: return this .onlineResource;
212: }
213:
214: /**
215: * Setter for legend icon onlineResource.
216: *
217: * @param onlineResource New value of legend icon onlineResource.
218: */
219: public void setOnlineResource(String onlineResource) {
220: this.onlineResource = onlineResource;
221: }
222: }
|