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 import java.util.List; 35 36 37 /** 38 * Thrown by {@link ParameterValueGroup} if adding or removing a {@linkplain ParameterValue 39 * parameter value} would result in more or less parameters than the expected range. The 40 * [{@linkplain ParameterDescriptor#getMinimumOccurs minimum} … 41 * {@linkplain ParameterDescriptor#getMaximumOccurs maximum}] range is defined by 42 * the {@link ParameterDescriptorGroup} instance associated with the {@code ParameterValueGroup}. 43 * <p> 44 * This exception may be thrown directly by the {@link ParameterValueGroup#addGroup(String)} 45 * method, or indirectly during the {@linkplain List#add add} or {@linkplain List#remove remove} 46 * operations on the list returned by {@link ParameterValueGroup#values()}. 47 * 48 * {@note This exception is of kind <code>IllegalStateException</code> instead than 49 * <code>IllegalArgumentException</code> because it is not caused by a bad argument. 50 * It is rather a consequence of an <code>ParameterValueGroup</code> being "full".} 51 * 52 * @departure extension 53 * This exception is not part of the OGC specification. 54 * 55 * @author Martin Desruisseaux (IRD) 56 * @version 3.0 57 * @since 2.0 58 * 59 * @see ParameterValueGroup#values() 60 * @see ParameterValueGroup#addGroup(String) 61 */ 62 public class InvalidParameterCardinalityException extends IllegalStateException { 63 /** 64 * Serial number for inter-operability with different versions. 65 */ 66 private static final long serialVersionUID = 4030549323541812311L; 67 68 /** 69 * The name of the parameter with invalid cardinality. 70 */ 71 private final String parameterName; 72 73 /** 74 * Creates an exception with the specified message and parameter name. 75 * 76 * @param message The detail message. The detail message is saved for 77 * later retrieval by the {@link #getMessage()} method. 78 * @param parameterName The name of the parameter with invalid cardinality. 79 */ InvalidParameterCardinalityException(String message, String parameterName)80 public InvalidParameterCardinalityException(String message, String parameterName) { 81 super(message); 82 this.parameterName = parameterName; 83 } 84 85 /** 86 * Returns the name of the parameter with invalid cardinality. 87 * 88 * @return The name of the parameter with invalid cardinality. 89 */ getParameterName()90 public String getParameterName() { 91 return parameterName; 92 } 93 } 94