1 /* 2 * GeoAPI - Java interfaces for OGC/ISO standards 3 * http://www.geoapi.org 4 * 5 * Copyright (C) 2004-2011 Open Geospatial Consortium, Inc. 6 * All Rights Reserved. http://www.opengeospatial.org/ogc/legal 7 * 8 * Permission to use, copy, and modify this software and its documentation, with 9 * or without modification, for any purpose and without fee or royalty is hereby 10 * granted, provided that you include the following on ALL copies of the software 11 * and documentation or portions thereof, including modifications, that you make: 12 * 13 * 1. The full text of this NOTICE in a location viewable to users of the 14 * redistributed or derivative work. 15 * 2. Notice of any changes or modifications to the OGC files, including the 16 * date changes were made. 17 * 18 * THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE 19 * NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 20 * TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT 21 * THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY 22 * PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. 23 * 24 * COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR 25 * CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION. 26 * 27 * The name and trademarks of copyright holders may NOT be used in advertising or 28 * publicity pertaining to the software without specific, written prior permission. 29 * Title to copyright in this software and any associated documentation will at all 30 * times remain with copyright holders. 31 */ 32 package org.opengis.parameter; 33 34 35 /** 36 * Thrown by {@link ParameterValue} getter methods when a value can not be casted to the 37 * requested type. For example this exception is thrown when {@link ParameterValue#doubleValue()} 38 * is invoked but the value is not convertible to a {@code double}. 39 * 40 * {@note This exception is of kind <code>IllegalStateException</code> instead than 41 * <code>IllegalArgumentException</code> because it is not caused by a bad argument. 42 * It is rather a consequence of a zero-argument method invoked in a context where 43 * is it not allowed.} 44 * 45 * @departure extension 46 * This exception is not part of the OGC specification. 47 * 48 * @author Martin Desruisseaux (IRD) 49 * @version 3.0 50 * @since 1.0 51 * 52 * @see ParameterValue#intValue() 53 * @see ParameterValue#doubleValue() 54 * @see ParameterValue#booleanValue() 55 * @see ParameterValue#stringValue() 56 * @see ParameterValue#valueFile() 57 */ 58 public class InvalidParameterTypeException extends IllegalStateException { 59 /** 60 * Serial number for inter-operability with different versions. 61 */ 62 private static final long serialVersionUID = 2740762597003093176L; 63 64 /** 65 * The invalid parameter name. 66 */ 67 private final String parameterName; 68 69 /** 70 * Creates an exception with the specified message and parameter name. 71 * 72 * @param message The detail message. The detail message is saved for 73 * later retrieval by the {@link #getMessage()} method. 74 * @param parameterName The parameter name. 75 */ InvalidParameterTypeException(String message, String parameterName)76 public InvalidParameterTypeException(String message, String parameterName) { 77 super(message); 78 this.parameterName = parameterName; 79 } 80 81 /** 82 * Returns the parameter name. 83 * 84 * @return The parameter name. 85 */ getParameterName()86 public String getParameterName() { 87 return parameterName; 88 } 89 } 90