returns a number Object, this can be a BigDecimal,BigInteger,Long, Double, depending on the
input.

@param str
@return
@throws PageException
507427
public static Number toNumber(String str, Number defaultValue) {
	try {
	    // float
	    if (str.indexOf('.') != -1) {
		return new BigDecimal(str);
	    }
	    // integer
	    BigInteger bi = new BigInteger(str);
	    int l = bi.bitLength();
	    if (l < 32) return new Integer(bi.intValue());
	    if (l < 64) return new Long(bi.longValue());
	    return bi;
	}
	catch (Throwable t) {
	    ExceptionUtil.rethrowIfNecessary(t);
	    return defaultValue;
	}
    }
1036739
private BigDecimal parseNumber(final NumberBuffer buffer) {
        BigDecimal sum = BigDecimal.ZERO;
        BigDecimal result = parseLargePair(buffer);

        if (result == null) {
            return null;
        }

        while (result != null) {
            sum = sum.add(result);
            result = parseLargePair(buffer);
        }

        return sum;
    }
501313
public static double exponent(Object left, Object right) throws PageException {
	return StrictMath.pow(Caster.toDoubleValue(left), Caster.toDoubleValue(right));
    }
475899
@Override
    public NumberType getNumberType() throws IOException {
        Object n = currentNode();
        if (n instanceof Integer) {
            return NumberType.INT;
        } else if (n instanceof BigInteger) {
            return NumberType.BIG_INTEGER;
        } else if (n instanceof BigDecimal) {
            return NumberType.BIG_DECIMAL;
        } else if (n instanceof Double) {
            return NumberType.DOUBLE;
        } else if (n instanceof Float) {
            return NumberType.FLOAT;
        } else if (n instanceof Long) {
            return NumberType.LONG;
        } else {
            throw _constructError(n + " is not a number");
        }
    }
1079359
public static BigDecimal stringToDecimal(String valueStr) {
        BigInteger bi = new BigInteger(valueStr);
        BigDecimal bd = new BigDecimal(bi);
        bd = VoltDecimalHelper.setDefaultScale(bd);
        return bd;
    }
637734
private boolean isInt(String str) {
        try {
            Integer.parseInt(str);
        } catch (NumberFormatException e) {
            return false;
        }
        return true;
    }
895970
private int getIntValue(String str, int defaultValue) {

        try {
            int intValue = Integer.parseInt(str);
            return (intValue > 0) ? intValue : defaultValue;
        } catch (NumberFormatException e) {
            // intentionally left blank
        }
        return defaultValue;
    }
604369
private static Integer toInt(String str) {

        Integer num = null;
        try {
            num = Integer.parseInt(str);
        } catch (NumberFormatException ex) {
            log.severe(String.format("failed to convert str: %s to integer", str));
        }

        return num;
    }
712631
public static double toDouble(@NotNull String str) {
		// 统一行为，不要有时候抛NPE，有时候抛NumberFormatException
		if (str == null) {
			throw new NumberFormatException("null");
		}
		return Double.parseDouble(str);
	}
452210
public static String call(PageContext pc, Object object) throws PageException {
	return call(pc, object, null, true, 9999, null, null, null, null, 9999, true, true);
    }
1031719
public static Object convert(String str, Class<?> type) throws Exception {
        Object value;
        if (int.class.equals(type) || Integer.class.equals(type))
            value = Integer.parseInt(str);
        else if (boolean.class.equals(type) || Boolean.class.equals(type))
            value = Boolean.parseBoolean(str);
        else if (long.class.equals(type) || Long.class.equals(type))
            value = Long.parseLong(str);
        else if (short.class.equals(type) || Short.class.equals(type))
            value = Short.parseShort(str);
        else if (byte.class.equals(type) || Byte.class.equals(type))
            value = Byte.parseByte(str);
        else if (double.class.equals(type) || Double.class.equals(type))
            value = Double.parseDouble(str);
        else if (float.class.equals(type) || Float.class.equals(type))
            value = Float.parseFloat(str);
        else if (char.class.equals(type) || Character.class.equals(type))
            value = str.charAt(0);
        else
            value = type.getConstructor(String.class).newInstance(str);
        return value;
    }
1240701
public java.math.BigDecimal getBigDecimal(String attr) {
		return (java.math.BigDecimal)attrs.get(attr);
	}
1112575
public static BigDecimal read(String value) {
		if (!StringUtils.hasText(value)) return null;
		
		return new BigDecimal(value);
	}
306450
public static Byte toByte(Object o) throws PageException {
	if (o instanceof Byte) return (Byte) o;
	return new Byte(toByteValue(o));

    }
985044
public Number getNumber(String key) throws NumberFormatException {
        String value = getString(key);
        if (value == null) {
            return null;
        }
        else {
            try {
                return Integer.valueOf(value);
            }
            catch (NumberFormatException e) {
            }
            try {
                return Long.valueOf(value);
            }
            catch (NumberFormatException e) {
            }
            return Double.valueOf(value);
        }
    }
1069269
private Integer toNumber(final Object src) {

		if (src instanceof Number) {

			return ((Number)src).intValue();
		}

		if (src instanceof String) {

			try {

				return Integer.valueOf(src.toString());

			} catch (NumberFormatException nfex) {
				logger.warn("Error in slice(): Cannot parse number {}.", src);
			}
		}

		return null;
	}
154727
public static Integer toIntObject(@Nullable String str, Integer defaultValue) {
		if (StringUtils.isEmpty(str)) {
			return defaultValue;
		}
		try {
			return Integer.valueOf(str);
		} catch (final NumberFormatException nfe) {
			return defaultValue;
		}
	}