FileDocCategorySizeDatePackage
NumericConverterImpl.javaAPI DocGlassfish v2 API4861Fri May 04 22:35:18 BST 2007com.sun.jdo.spi.persistence.support.sqlstore.utility

NumericConverterImpl

public class NumericConverterImpl extends Object implements NumericConverter
This is a concrete implementation class for numeric conversion to BigDecimal or BigInteger. For conversion to BigInteger, we truncate the fraction part of the number.
author
Shing Wai Chan

Fields Summary
Constructors Summary
public NumericConverterImpl()

param
policy for determine mechanism for conversion to BigDecimal and BigInteger

     
Methods Summary
public java.math.BigDecimaltoBigDecimal(java.math.BigInteger bInteger)
To convert BigInteger to BigDecimal.

param
bInteger the BigInteger to be converted
return
converted BigDecimal

          return (bInteger == null) ? null : new BigDecimal(bInteger);
     
public java.math.BigDecimaltoBigDecimal(java.lang.Double d)
To convert Double to BigDecimal.

param
d the Double to be converted
return
converted BigDecimal

          return (d == null) ? null : new BigDecimal(d.toString());
     
public java.math.BigDecimaltoBigDecimal(java.lang.Float f)
To convert Float to BigDecimal.

param
f the Float to be converted
return
converted BigDecimal

          return (f == null) ? null : new BigDecimal(f.toString());
     
public java.math.BigDecimaltoBigDecimal(java.lang.Number n)
To convert Number other than BigInteger, Double and Float to BigDecimal.

param
n the Number to be converted
return
converted BigDecimal

          return (n == null) ? null : new BigDecimal(n.toString());
     
public java.math.BigIntegertoBigInteger(java.math.BigDecimal bDecimal)
To convert BigDecimal to BigInteger.

param
bDecimal the BigDecimal to be converted
return
converted BigInteger

          return (bDecimal == null) ? null : bDecimal.toBigInteger();
     
public java.math.BigIntegertoBigInteger(java.lang.Double d)
To convert Double to BigInteger.

param
d the Double to be converted
return
converted BigInteger

          return (d == null) ? null : (new BigDecimal(d.toString())).toBigInteger();
     
public java.math.BigIntegertoBigInteger(java.lang.Float f)
To convert Float to BigInteger.

param
f the Float to be converted
return
converted BigInteger

          return (f == null) ? null : (new BigDecimal(f.toString())).toBigInteger();
     
public java.math.BigIntegertoBigInteger(java.lang.Number n)
To convert Number other than BigDecimal, Double and Float to BigInteger.

param
n the Number to be converted
return
converted BigInteger

          return (n == null) ? null : BigInteger.valueOf(n.longValue());