Esempio n. 1
0
 public OverflowException(Number n, Class<?> expectedClass) {
   super(
       "Overflow exception, "
           + n.toString()
           + " cannot be converted to: "
           + expectedClass.getSimpleName());
 }
Esempio n. 2
0
 private long getLong(Object value) {
   if (value instanceof Long) {
     // Case "value instanceof Number" below is not sufficient for Long:
     // conversion via double loses precision for values > 2^48. OK for
     // other types, including int and float.
     return ((Long) value).longValue();
   } else if (value instanceof Number) {
     Number n = (Number) value;
     return NumberUtil.round(n.doubleValue());
   } else if (value instanceof Boolean) {
     return (((Boolean) value).booleanValue() ? 1 : 0);
   } else if (value instanceof String) {
     try {
       BigDecimal bd = new BigDecimal(value.toString().trim());
       return getLong(bd);
     } catch (NumberFormatException ex) {
       throw newInvalidFormat(value);
     }
   } else {
     throw newInvalidType(value);
   }
 }