001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/branches/2.2_testing/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 14:30:32 +0100 (Do, 27 Dez 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, String vendor, String version ) { 103 this.description = description; 104 this.docURL = docURL; 105 this.name = name; 106 this.vendor = vendor; 107 this.version = version; 108 } 109 110 /** 111 * @param description 112 * @param docURL 113 * @param name 114 * @param vendor 115 * @param version 116 * @param readParameters 117 * @param writeParameters 118 */ 119 public Format( String name, String description, String docURL, String vendor, String version, 120 GeneralOperationParameterIm[] readParameters, GeneralOperationParameterIm[] writeParameters ) { 121 this.description = description; 122 this.docURL = docURL; 123 this.name = name; 124 this.vendor = vendor; 125 this.version = version; 126 setReadParameters( readParameters ); 127 setWriteParameters( writeParameters ); 128 } 129 130 /** 131 * @param description 132 * The description to set. 133 * 134 */ 135 public void setDescription( String description ) { 136 this.description = description; 137 } 138 139 /** 140 * @param docURL 141 * The docURL to set. 142 * 143 */ 144 public void setDocURL( String docURL ) { 145 this.docURL = docURL; 146 } 147 148 /** 149 * @param name 150 * The name to set. 151 * 152 */ 153 public void setName( String name ) { 154 this.name = name; 155 } 156 157 /** 158 * @param readParameters 159 * The readParameters to set. 160 */ 161 public void setReadParameters( GeneralOperationParameterIm[] readParameters ) { 162 if ( readParameters == null ) 163 readParameters = new GeneralOperationParameterIm[0]; 164 this.readParameters = Arrays.asList( readParameters ); 165 } 166 167 /** 168 * @param readParameter 169 */ 170 public void addReadParameter( GeneralOperationParameterIm readParameter ) { 171 this.readParameters.add( readParameter ); 172 } 173 174 /** 175 * @param vendor 176 * The vendor to set. 177 * 178 */ 179 public void setVendor( String vendor ) { 180 this.vendor = vendor; 181 } 182 183 /** 184 * @param version 185 * The version to set. 186 * 187 */ 188 public void setVersion( String version ) { 189 this.version = version; 190 } 191 192 /** 193 * @param writeParameters 194 * The writeParameters to set. 195 */ 196 public void setWriteParameters( GeneralOperationParameterIm[] writeParameters ) { 197 if ( writeParameters == null ) 198 writeParameters = new GeneralOperationParameterIm[0]; 199 this.writeParameters = Arrays.asList( writeParameters ); 200 } 201 202 /** 203 * @param writeParameter 204 */ 205 public void addWriteParameter( GeneralOperationParameterIm writeParameter ) { 206 this.readParameters.add( writeParameter ); 207 } 208 209 /** 210 * Name of the file format. 211 * 212 * @return the name of the file format. 213 * 214 */ 215 public String getName() { 216 return name; 217 } 218 219 /** 220 * Description of the file format. If no description, the value will be <code>null</code>. 221 * 222 * @return the description of the file format. 223 */ 224 public String getDescription() { 225 return description; 226 } 227 228 /** 229 * Vendor or agency for the format. 230 * 231 * @return the vendor or agency for the format. 232 */ 233 public String getVendor() { 234 return vendor; 235 } 236 237 /** 238 * Documentation URL for the format. 239 * 240 * @return the documentation URL for the format. 241 */ 242 public String getDocURL() { 243 return docURL; 244 } 245 246 /** 247 * Version number of the format. 248 * 249 * @return the version number of the format. 250 */ 251 public String getVersion() { 252 return version; 253 } 254 255 /** 256 * Retrieve the parameter information for a 257 * {@link "org.opengis.coverage.grid.GridCoverageReader#read" read} operation. 258 */ 259 public GeneralOperationParameterIm[] getReadParameters() { 260 GeneralOperationParameterIm[] rp = new GeneralOperationParameterIm[readParameters.size()]; 261 return readParameters.toArray( rp ); 262 } 263 264 /** 265 * Retrieve the parameter information for a org.opengis.coverage.grid.GridCoverageWriter#write 266 * operation. 267 * 268 * @return 269 * 270 */ 271 public GeneralOperationParameterIm[] getWriteParameters() { 272 GeneralOperationParameterIm[] rp = new GeneralOperationParameterIm[writeParameters.size()]; 273 return writeParameters.toArray( rp ); 274 } 275 276 /** 277 * performs a test if the passed Object is equal to this Format. Two Formats are equal if their 278 * names ar equal and (if not null) their vendors and versions are equal. 279 * 280 * @see java.lang.Object#equals(java.lang.Object) 281 * @param obj 282 * object to compare 283 */ 284 public boolean equals( Object obj ) { 285 if ( obj == null || !( obj instanceof Format ) ) { 286 return false; 287 } 288 Format other = (Format) obj; 289 boolean eq = this.getName().equals( other.getName() ); 290 if ( getVendor() != null && other.getVendor() != null ) { 291 eq = eq && getVendor().equals( other.getVendor() ); 292 } else if ( getVendor() == null && other.getVendor() != null ) { 293 return false; 294 } else if ( getVendor() != null && other.getVendor() == null ) { 295 return false; 296 } 297 if ( getVersion() != null && other.getVersion() != null ) { 298 eq = eq && getVersion().equals( other.getVersion() ); 299 } else if ( getVersion() == null && other.getVersion() != null ) { 300 return false; 301 } else if ( getVersion() != null && other.getVersion() == null ) { 302 return false; 303 } 304 return eq; 305 } 306 307 }