case StandardNames.XS_NUMERIC:
case StandardNames.XS_ANY_ATOMIC_TYPE:
return this;
case StandardNames.XS_INTEGER:
if (Double.isNaN(value)) {
ValidationFailure err = new ValidationFailure("Cannot convert double NaN to an integer");
err.setErrorCode("FOCA0002");
return err;
}
if (Double.isInfinite(value)) {
ValidationFailure err = new ValidationFailure("Cannot convert double INF to an integer");
err.setErrorCode("FOCA0002");
return err;
}
return IntegerValue.decimalToInteger(new BigDecimal(value));
case StandardNames.XS_DECIMAL:
try {
return new DecimalValue(value);
} catch (XPathException e) {
return new ValidationFailure(e);
}
case StandardNames.XS_FLOAT:
return new FloatValue((float)value);
case StandardNames.XS_STRING:
return new StringValue(getStringValueCS());
case StandardNames.XS_UNTYPED_ATOMIC:
return new UntypedAtomicValue(getStringValueCS());
default:
ValidationFailure err = new ValidationFailure("Cannot convert double to " +
requiredType.getDisplayName());
err.setErrorCode("XPTY0004");
return err;
}
}