} else {
reference = null;
final String unitCode = result.getString(4);
unit = (unitCode!=null) ? createUnit(unitCode) : null;
}
final ParameterValue param;
try {
param = parameters.parameter(name);
} catch (ParameterNotFoundException exception) {
/*
* Wraps the unchecked ParameterNotFoundException into the checked
* NoSuchIdentifierException, which is a FactoryException subclass.
* Note that in theory, NoSuchIdentifierException is for MathTransforms rather
* than parameters. However, we are close in spirit here since we are setting
* up MathTransform's parameters. Using NoSuchIdentifierException allows users
* (including CoordinateOperationSet) to know that the failure is probably
* caused by a MathTransform not yet supported in Geotools (or only partially
* supported) rather than some more serious failure in the database side.
* CoordinateOperationSet uses this information in order to determine if it
* should try the next coordinate operation or propagate the exception.
*/
final NoSuchIdentifierException e = new NoSuchIdentifierException(
Errors.format(ErrorKeys.CANT_SET_PARAMETER_VALUE_$1, name), name);
e.initCause(exception);
throw e;
}
try {
if (reference != null) {
param.setValue(reference);
} else if (unit != null) {
param.setValue(value, unit);
} else {
param.setValue(value);
}
} catch (InvalidParameterValueException exception) {
throw new FactoryException(
Errors.format(ErrorKeys.CANT_SET_PARAMETER_VALUE_$1, name), exception);
}