001 // $HeadURL: https://svn.wald.intevation.org/svn/deegree/base/branches/2.3_testing/src/org/deegree/datatypes/parameter/ParameterValueIm.java $ 002 /*---------------------------------------------------------------------------- 003 This file is part of deegree, http://deegree.org/ 004 Copyright (C) 2001-2009 by: 005 Department of Geography, University of Bonn 006 and 007 lat/lon GmbH 008 009 This library is free software; you can redistribute it and/or modify it under 010 the terms of the GNU Lesser General Public License as published by the Free 011 Software Foundation; either version 2.1 of the License, or (at your option) 012 any later version. 013 This library is distributed in the hope that it will be useful, but WITHOUT 014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 015 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 016 details. 017 You should have received a copy of the GNU Lesser General Public License 018 along with this library; if not, write to the Free Software Foundation, Inc., 019 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 020 021 Contact information: 022 023 lat/lon GmbH 024 Aennchenstr. 19, 53177 Bonn 025 Germany 026 http://lat-lon.de/ 027 028 Department of Geography, University of Bonn 029 Prof. Dr. Klaus Greve 030 Postfach 1147, 53001 Bonn 031 Germany 032 http://www.geographie.uni-bonn.de/deegree/ 033 034 e-mail: info@deegree.org 035 ----------------------------------------------------------------------------*/ 036 package org.deegree.datatypes.parameter; 037 038 import java.io.Serializable; 039 import java.net.URL; 040 041 /** 042 * 043 * 044 * @version $Revision: 18195 $ 045 * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a> 046 * @author last edited by: $Author: mschneider $ 047 * 048 * @version $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $ 049 */ 050 public class ParameterValueIm extends GeneralParameterValueIm implements Serializable { 051 052 private static final long serialVersionUID = 1L; 053 054 private Object value = null; 055 056 /** 057 * @param descriptor 058 */ 059 public ParameterValueIm( GeneralOperationParameterIm descriptor ) { 060 super( descriptor ); 061 } 062 063 /** 064 * @param descriptor 065 * @param value 066 */ 067 public ParameterValueIm( GeneralOperationParameterIm descriptor, Object value ) { 068 super( descriptor ); 069 setValue( value ); 070 } 071 072 /** 073 * @param descriptor 074 * @param value 075 */ 076 public ParameterValueIm( GeneralOperationParameterIm descriptor, String value ) { 077 super( descriptor ); 078 setValue( value ); 079 } 080 081 /** 082 * @param descriptor 083 * @param value 084 */ 085 public ParameterValueIm( GeneralOperationParameterIm descriptor, URL value ) { 086 super( descriptor ); 087 setValue( value ); 088 } 089 090 /** 091 * @param descriptor 092 * @param value 093 */ 094 public ParameterValueIm( GeneralOperationParameterIm descriptor, int value ) { 095 super( descriptor ); 096 setValue( value ); 097 } 098 099 /** 100 * @param descriptor 101 * @param value 102 */ 103 public ParameterValueIm( GeneralOperationParameterIm descriptor, double value ) { 104 super( descriptor ); 105 setValue( value ); 106 } 107 108 /** 109 * @param descriptor 110 * @param value 111 */ 112 public ParameterValueIm( GeneralOperationParameterIm descriptor, boolean value ) { 113 super( descriptor ); 114 setValue( value ); 115 } 116 117 /** 118 * @return the value as a boolean. 119 * @throws InvalidParameterTypeException 120 */ 121 public boolean booleanValue() 122 throws InvalidParameterTypeException { 123 return ( (Boolean) value ).booleanValue(); 124 } 125 126 /** 127 * @return the value as a double. 128 * @throws InvalidParameterTypeException 129 */ 130 public double doubleValue() 131 throws InvalidParameterTypeException { 132 return ( (Double) value ).doubleValue(); 133 } 134 135 /** 136 * @return the value list as an array of doubles.. 137 * @throws InvalidParameterTypeException 138 */ 139 public double[] doubleValueList() 140 throws InvalidParameterTypeException { 141 return (double[]) value; 142 } 143 144 /** 145 * @return the value. 146 */ 147 public String getUnit() { 148 return (String) value; 149 } 150 151 /** 152 * @return the value as an object. 153 * 154 */ 155 public Object getValue() { 156 return value; 157 } 158 159 /** 160 * @return the value as an int 161 * @throws InvalidParameterTypeException 162 */ 163 public int intValue() 164 throws InvalidParameterTypeException { 165 return ( (Integer) value ).intValue(); 166 } 167 168 /** 169 * @return the value as an array of integers 170 * @throws InvalidParameterTypeException 171 */ 172 public int[] intValueList() 173 throws InvalidParameterTypeException { 174 return (int[]) value; 175 } 176 177 /** 178 * @param unit to set 179 * @throws InvalidParameterTypeException 180 */ 181 public void setUnit( String unit ) 182 throws InvalidParameterTypeException { 183 value = unit; 184 } 185 186 /** 187 * @param value to set 188 * @throws InvalidParameterValueException 189 */ 190 public void setValue( boolean value ) 191 throws InvalidParameterValueException { 192 this.value = Boolean.valueOf( value ); 193 } 194 195 /** 196 * @param value to set 197 * @throws InvalidParameterValueException 198 */ 199 public void setValue( double value ) 200 throws InvalidParameterValueException { 201 this.value = new Double( value ); 202 } 203 204 /** 205 * @param value to set 206 * @throws InvalidParameterValueException 207 */ 208 public void setValue( int value ) 209 throws InvalidParameterValueException { 210 this.value = new Integer( value ); 211 } 212 213 /** 214 * @param value to set 215 * @throws InvalidParameterValueException 216 * 217 */ 218 public void setValue( Object value ) 219 throws InvalidParameterValueException { 220 this.value = value; 221 } 222 223 /** 224 * @return the value as a String 225 * @throws InvalidParameterTypeException 226 */ 227 public String stringValue() 228 throws InvalidParameterTypeException { 229 return (String) value; 230 } 231 232 /** 233 * @param value 234 */ 235 public void setValue( String value ) { 236 this.value = value; 237 } 238 239 /** 240 * @return the location of the value file. 241 * @throws InvalidParameterTypeException 242 */ 243 public URL valueFile() 244 throws InvalidParameterTypeException { 245 return (URL) value; 246 } 247 248 /** 249 * @param value 250 */ 251 public void setValue( URL value ) { 252 this.value = value; 253 } 254 255 }