1 23 24 29 30 package com.sun.jdo.spi.persistence.support.sqlstore.utility; 31 32 import java.math.BigDecimal ; 33 import java.math.BigInteger ; 34 35 42 public class NumericConverterImpl implements NumericConverter { 43 47 public NumericConverterImpl() { 48 } 49 50 55 public BigDecimal toBigDecimal(BigInteger bInteger) { 56 return (bInteger == null) ? null : new BigDecimal (bInteger); 57 } 58 59 64 public BigDecimal toBigDecimal(Double d) { 65 return (d == null) ? null : new BigDecimal (d.toString()); 66 } 67 68 73 public BigDecimal toBigDecimal(Float f) { 74 return (f == null) ? null : new BigDecimal (f.toString()); 75 } 76 77 82 public BigDecimal toBigDecimal(Number n) { 83 return (n == null) ? null : new BigDecimal (n.toString()); 84 } 85 86 91 public BigInteger toBigInteger(BigDecimal bDecimal) { 92 return (bDecimal == null) ? null : bDecimal.toBigInteger(); 93 } 94 95 100 public BigInteger toBigInteger(Double d) { 101 return (d == null) ? null : (new BigDecimal (d.toString())).toBigInteger(); 102 } 103 104 109 public BigInteger toBigInteger(Float f) { 110 return (f == null) ? null : (new BigDecimal (f.toString())).toBigInteger(); 111 } 112 113 118 public BigInteger toBigInteger(Number n) { 119 return (n == null) ? null : BigInteger.valueOf(n.longValue()); 120 } 121 } 122 | Popular Tags |