Here you can find the source of tryToStoreAsRealBigDecimal(Object ob)
private static BigDecimal tryToStoreAsRealBigDecimal(Object ob)
//package com.java2s; /**/*from ww w .j a va2 s .com*/ * ***************************************************************************** * Copyright 2007 Amazon Technologies, Inc. Licensed under the Apache License, Version 2.0 (the "License"); * * You may not use this file except in compliance with the License. You may obtain a copy of the License at: http://aws.amazon.com/apache2.0 This file is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. * ***************************************************************************** __ _ _ ___ ( )( \/\/ )/ __) /__\ \ / \__ \ (_)(_) \/\/ (___/ * * Amazon Simple DB Java Library API Version: 2007-11-07 Generated: Fri Jan 18 01:13:17 PST 2008 * */ import java.math.BigDecimal; public class Main { private static BigDecimal tryToStoreAsRealBigDecimal(Object ob) { BigDecimal bigDecimal = null; if (canBeStoredAsRealBigDecimal(ob)) { bigDecimal = new BigDecimal(ob.toString()); } else if (ob instanceof BigDecimal) { bigDecimal = (BigDecimal) ob; } return bigDecimal; } private static boolean canBeStoredAsRealBigDecimal(Object ob) { if (isNaN(ob) || isInfinite(ob)) { return false; } return ob instanceof Double || ob instanceof Float; } public static boolean isNaN(Object ob) { return (ob instanceof Double && ((Double) ob).isNaN()) || (ob instanceof Float && ((Float) ob).isNaN()); } public static boolean isInfinite(Object ob) { return (ob instanceof Double && ((Double) ob).isInfinite()) || (ob instanceof Float && ((Float) ob).isInfinite()); } }