List of usage examples for org.apache.commons.collections MapUtils getDoubleValue
public static double getDoubleValue(final Map map, final Object key)
From source file:com.glaf.core.util.ParamUtils.java
public static double getDouble(Map<String, Object> dataMap, String key) { double result = 0.0D; Object value = dataMap.get(key); if (value == null) { value = dataMap.get(key.toLowerCase()); }// ww w .j a v a2 s. c o m if (value == null) { value = dataMap.get(key.toUpperCase()); } if (value != null && StringUtils.isNotEmpty(value.toString())) { if (value instanceof String) { String tmp = (String) value; result = Double.parseDouble(tmp); } else if (value instanceof Integer) { Integer x = (Integer) value; result = x.doubleValue(); } else if (value instanceof Long) { Long x = (Long) value; result = x.doubleValue(); } else if (value instanceof Double) { Double x = (Double) value; result = x.doubleValue(); } else { String tmp = value.toString(); result = Double.parseDouble(tmp); } } else { result = MapUtils.getDoubleValue(dataMap, key); } return result; }