001: //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/model/coverage/grid/Format.java $
002: /*---------------- FILE HEADER ------------------------------------------
003:
004: This file is part of deegree.
005: Copyright (C) 2001-2008 by:
006: EXSE, Department of Geography, University of Bonn
007: http://www.giub.uni-bonn.de/deegree/
008: lat/lon GmbH
009: http://www.lat-lon.de
010:
011: This library is free software; you can redistribute it and/or
012: modify it under the terms of the GNU Lesser General Public
013: License as published by the Free Software Foundation; either
014: version 2.1 of the License, or (at your option) any later version.
015:
016: This library is distributed in the hope that it will be useful,
017: but WITHOUT ANY WARRANTY; without even the implied warranty of
018: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: Lesser General Public License for more details.
020:
021: You should have received a copy of the GNU Lesser General Public
022: License along with this library; if not, write to the Free Software
023: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024:
025: Contact:
026:
027: Andreas Poth
028: lat/lon GmbH
029: Aennchenstr. 19
030: 53115 Bonn
031: Germany
032: E-Mail: poth@lat-lon.de
033:
034: Prof. Dr. Klaus Greve
035: Department of Geography
036: University of Bonn
037: Meckenheimer Allee 166
038: 53115 Bonn
039: Germany
040: E-Mail: greve@giub.uni-bonn.de
041:
042:
043: ---------------------------------------------------------------------------*/
044: package org.deegree.model.coverage.grid;
045:
046: import java.io.Serializable;
047: import java.util.Arrays;
048: import java.util.List;
049:
050: import org.deegree.datatypes.Code;
051: import org.deegree.datatypes.parameter.GeneralOperationParameterIm;
052:
053: /**
054: * This interface is a discovery mechanism to determine the formats supported by a
055: * {@link "org.opengis.coverage.grid.GridCoverageExchange"} implementation. A
056: * <code>GC_GridCoverageExchange</code> implementation can support a number of file format or
057: * resources.
058: *
059: * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
060: * @author last edited by: $Author: apoth $
061: *
062: * @version $Revision: 9343 $, $Date: 2007-12-27 05:30:32 -0800 (Thu, 27 Dec 2007) $
063: */
064: public class Format implements Serializable {
065:
066: private static final long serialVersionUID = 3847909077719638612L;
067:
068: private String name = null;
069:
070: private String description = null;
071:
072: private String docURL = null;
073:
074: private String vendor = null;
075:
076: private String version = null;
077:
078: private List<GeneralOperationParameterIm> readParameters = null;
079:
080: private List<GeneralOperationParameterIm> writeParameters = null;
081:
082: /**
083: * Initializes a format with a Code containing a code that will be used as format name and a
084: * code space (optional) that will be interpreted as format vendor.
085: *
086: * @param code
087: */
088: public Format(Code code) {
089: this .name = code.getCode();
090: if (code.getCodeSpace() != null) {
091: vendor = code.getCodeSpace().toString();
092: }
093: }
094:
095: /**
096: * @param description
097: * @param docURL
098: * @param name
099: * @param vendor
100: * @param version
101: */
102: public Format(String name, String description, String docURL,
103: String vendor, String version) {
104: this .description = description;
105: this .docURL = docURL;
106: this .name = name;
107: this .vendor = vendor;
108: this .version = version;
109: }
110:
111: /**
112: * @param description
113: * @param docURL
114: * @param name
115: * @param vendor
116: * @param version
117: * @param readParameters
118: * @param writeParameters
119: */
120: public Format(String name, String description, String docURL,
121: String vendor, String version,
122: GeneralOperationParameterIm[] readParameters,
123: GeneralOperationParameterIm[] writeParameters) {
124: this .description = description;
125: this .docURL = docURL;
126: this .name = name;
127: this .vendor = vendor;
128: this .version = version;
129: setReadParameters(readParameters);
130: setWriteParameters(writeParameters);
131: }
132:
133: /**
134: * @param description
135: * The description to set.
136: *
137: */
138: public void setDescription(String description) {
139: this .description = description;
140: }
141:
142: /**
143: * @param docURL
144: * The docURL to set.
145: *
146: */
147: public void setDocURL(String docURL) {
148: this .docURL = docURL;
149: }
150:
151: /**
152: * @param name
153: * The name to set.
154: *
155: */
156: public void setName(String name) {
157: this .name = name;
158: }
159:
160: /**
161: * @param readParameters
162: * The readParameters to set.
163: */
164: public void setReadParameters(
165: GeneralOperationParameterIm[] readParameters) {
166: if (readParameters == null)
167: readParameters = new GeneralOperationParameterIm[0];
168: this .readParameters = Arrays.asList(readParameters);
169: }
170:
171: /**
172: * @param readParameter
173: */
174: public void addReadParameter(
175: GeneralOperationParameterIm readParameter) {
176: this .readParameters.add(readParameter);
177: }
178:
179: /**
180: * @param vendor
181: * The vendor to set.
182: *
183: */
184: public void setVendor(String vendor) {
185: this .vendor = vendor;
186: }
187:
188: /**
189: * @param version
190: * The version to set.
191: *
192: */
193: public void setVersion(String version) {
194: this .version = version;
195: }
196:
197: /**
198: * @param writeParameters
199: * The writeParameters to set.
200: */
201: public void setWriteParameters(
202: GeneralOperationParameterIm[] writeParameters) {
203: if (writeParameters == null)
204: writeParameters = new GeneralOperationParameterIm[0];
205: this .writeParameters = Arrays.asList(writeParameters);
206: }
207:
208: /**
209: * @param writeParameter
210: */
211: public void addWriteParameter(
212: GeneralOperationParameterIm writeParameter) {
213: this .readParameters.add(writeParameter);
214: }
215:
216: /**
217: * Name of the file format.
218: *
219: * @return the name of the file format.
220: *
221: */
222: public String getName() {
223: return name;
224: }
225:
226: /**
227: * Description of the file format. If no description, the value will be <code>null</code>.
228: *
229: * @return the description of the file format.
230: */
231: public String getDescription() {
232: return description;
233: }
234:
235: /**
236: * Vendor or agency for the format.
237: *
238: * @return the vendor or agency for the format.
239: */
240: public String getVendor() {
241: return vendor;
242: }
243:
244: /**
245: * Documentation URL for the format.
246: *
247: * @return the documentation URL for the format.
248: */
249: public String getDocURL() {
250: return docURL;
251: }
252:
253: /**
254: * Version number of the format.
255: *
256: * @return the version number of the format.
257: */
258: public String getVersion() {
259: return version;
260: }
261:
262: /**
263: * Retrieve the parameter information for a
264: * {@link "org.opengis.coverage.grid.GridCoverageReader#read" read} operation.
265: */
266: public GeneralOperationParameterIm[] getReadParameters() {
267: GeneralOperationParameterIm[] rp = new GeneralOperationParameterIm[readParameters
268: .size()];
269: return readParameters.toArray(rp);
270: }
271:
272: /**
273: * Retrieve the parameter information for a org.opengis.coverage.grid.GridCoverageWriter#write
274: * operation.
275: *
276: * @return
277: *
278: */
279: public GeneralOperationParameterIm[] getWriteParameters() {
280: GeneralOperationParameterIm[] rp = new GeneralOperationParameterIm[writeParameters
281: .size()];
282: return writeParameters.toArray(rp);
283: }
284:
285: /**
286: * performs a test if the passed Object is equal to this Format. Two Formats are equal if their
287: * names ar equal and (if not null) their vendors and versions are equal.
288: *
289: * @see java.lang.Object#equals(java.lang.Object)
290: * @param obj
291: * object to compare
292: */
293: public boolean equals(Object obj) {
294: if (obj == null || !(obj instanceof Format)) {
295: return false;
296: }
297: Format other = (Format) obj;
298: boolean eq = this .getName().equals(other.getName());
299: if (getVendor() != null && other.getVendor() != null) {
300: eq = eq && getVendor().equals(other.getVendor());
301: } else if (getVendor() == null && other.getVendor() != null) {
302: return false;
303: } else if (getVendor() != null && other.getVendor() == null) {
304: return false;
305: }
306: if (getVersion() != null && other.getVersion() != null) {
307: eq = eq && getVersion().equals(other.getVersion());
308: } else if (getVersion() == null && other.getVersion() != null) {
309: return false;
310: } else if (getVersion() != null && other.getVersion() == null) {
311: return false;
312: }
313: return eq;
314: }
315:
316: }
|