/** * Returns the string value of an operation parameter. A string value does not have an * associated unit of measure. * * @return The string value represented by this parameter. * @throws InvalidParameterTypeException if the value is not a string. * @see #getValue * @see #setValue(Object) */ public String stringValue() throws InvalidParameterTypeException { if (value instanceof CharSequence) { return value.toString(); } final String name = getName(descriptor); if (value == null) { throw new IllegalStateException(Errors.format(ErrorKeys.MISSING_PARAMETER_$1, name)); } throw new InvalidParameterTypeException(getClassTypeError(), name); }
/** * Returns the boolean value of an operation parameter. A boolean value does not have an * associated unit of measure. * * @return The boolean value represented by this parameter. * @throws InvalidParameterTypeException if the value is not a boolean type. * @see #setValue(boolean) */ public boolean booleanValue() throws InvalidParameterTypeException { if (value instanceof Boolean) { return ((Boolean) value).booleanValue(); } final String name = getName(descriptor); if (value == null) { throw new IllegalStateException(Errors.format(ErrorKeys.MISSING_PARAMETER_$1, name)); } throw new InvalidParameterTypeException(getClassTypeError(), name); }
/** * Returns the positive integer value of an operation parameter, usually used for a count. An * integer value does not have an associated unit of measure. * * @return The numeric value represented by this parameter after conversion to type {@code int}. * @throws InvalidParameterTypeException if the value is not an integer type. * @see #setValue(int) * @see #intValueList */ public int intValue() throws InvalidParameterTypeException { if (value instanceof Number) { return ((Number) value).intValue(); } final String name = getName(descriptor); if (value == null) { throw new IllegalStateException(Errors.format(ErrorKeys.MISSING_PARAMETER_$1, name)); } throw new InvalidParameterTypeException(getClassTypeError(), name); }
/** * Returns the numeric value of the coordinate operation parameter with its associated * {@linkplain #getUnit unit of measure}. * * @return The numeric value represented by this parameter after conversion to type {@code * double}. * @throws InvalidParameterTypeException if the value is not a numeric type. * @see #getUnit * @see #setValue(double) * @see #doubleValueList() */ public double doubleValue() throws InvalidParameterTypeException { if (value instanceof Number) { return ((Number) value).doubleValue(); } final String name = getName(descriptor); if (value == null) { // This is the kind of exception expected by org.geotools.referencing.wkt.Formatter. throw new IllegalStateException(Errors.format(ErrorKeys.MISSING_PARAMETER_$1, name)); } // Reminder: the following is a specialization of IllegalStateException. throw new InvalidParameterTypeException(getClassTypeError(), name); }
/** * Returns an ordered sequence of two or more numeric values of an operation parameter list, * where each value has the same associated {@linkplain Unit unit of measure}. * * @return The sequence of values represented by this parameter. * @throws InvalidParameterTypeException if the value is not an array of {@code double}s. * @see #getUnit * @see #setValue(Object) * @see #doubleValue() */ public double[] doubleValueList() throws InvalidParameterTypeException { if (value instanceof double[]) { return (double[]) value; } final String name = getName(descriptor); if (value == null) { throw new IllegalStateException(Errors.format(ErrorKeys.MISSING_PARAMETER_$1, name)); } throw new InvalidParameterTypeException(getClassTypeError(), name); }
/** * Returns an ordered sequence of two or more integer values of an operation parameter list, * usually used for counts. These integer values do not have an associated unit of measure. * * @return The sequence of values represented by this parameter. * @throws InvalidParameterTypeException if the value is not an array of {@code int}s. * @see #setValue(Object) * @see #intValue */ public int[] intValueList() throws InvalidParameterTypeException { if (value instanceof int[]) { return (int[]) value; } final String name = getName(descriptor); if (value == null) { throw new IllegalStateException(Errors.format(ErrorKeys.MISSING_PARAMETER_$1, name)); } throw new InvalidParameterTypeException(getClassTypeError(), name); }
new InvalidParameterTypeException(getClassTypeError(), name); if (cause != null) { exception.initCause(cause);