Example usage for java.lang Double doubleValue

List of usage examples for java.lang Double doubleValue

Introduction

In this page you can find the example usage for java.lang Double doubleValue.

Prototype

@HotSpotIntrinsicCandidate
public double doubleValue() 

Source Link

Document

Returns the double value of this Double object.

Usage

From source file:net.sourceforge.fenixedu.util.InquiriesUtil.java

public static String getTdClass(final String val, final String[] classes, final String defaultClass,
        final String[] values, final Double repQuota, final Double minRepQuota) {
    return (repQuota.doubleValue() > minRepQuota.doubleValue()) ? getTdClass(val, classes, defaultClass, values)
            : defaultClass;//from   w ww  .jav  a2  s . c  om
}

From source file:org.sigmah.server.endpoint.export.sigmah.spreadsheet.CalcUtils.java

public static Cell createBasicCell(final Table table, int colIndex, int rowIndex, Object value) {
    final Cell cell = table.getCellByPosition(colIndex, rowIndex);
    String strValue;//from w w  w .  j a  va 2  s. co m
    if (value == null) {
        strValue = "";
    } else if (value instanceof String) {
        strValue = (String) value;
    } else if (value instanceof Double) {
        Double d = (Double) value;
        strValue = LogFrameExportData.AGGR_AVG_FORMATTER.format(d.doubleValue());
    } else if (value instanceof Long) {
        Long l = (Long) value;
        strValue = LogFrameExportData.AGGR_SUM_FORMATTER.format(l.longValue());
    } else { //date                     
        strValue = ExportConstants.EXPORT_DATE_FORMAT.format((Date) value);
    }

    cell.setStringValue(strValue);
    cell.setCellStyleName(coreStyleName);
    return cell;
}

From source file:com.openappengine.utility.ObjectConverter.java

/**
 * Converts Double to BigDecimal.//w ww  . j  a v a  2 s. com
 * @param value The Double to be converted.
 * @return The converted BigDecimal value.
 */
public static BigDecimal doubleToBigDecimal(Double value) {
    return new BigDecimal(value.doubleValue());
}

From source file:cern.accsoft.steering.jmad.domain.knob.bean.BeanPropertyKnob.java

/**
 * Gets a double value from a bean-property with the given name.
 * /*w w w  .  j av  a 2 s  . co  m*/
 * @param bean the bean from which to get the value
 * @param propertyName the name of the property
 * @return the actual value of the varied property of the bean
 */
private static final double getBeanValue(Object bean, String propertyName) {
    try {
        Double value = (Double) PropertyUtils.getSimpleProperty(bean, propertyName);
        if (value != null) {
            return value.doubleValue();
        }
    } catch (Exception e) {
        LOGGER.error("Cannot read property '" + propertyName + "' of bean '" + bean + "'.", e);
    }
    return 0.0;
}

From source file:org.sigmah.server.servlet.exporter.utils.CalcUtils.java

public static Cell createBasicCell(final Table table, int colIndex, int rowIndex, Object value) {
    final Cell cell = table.getCellByPosition(colIndex, rowIndex);
    String strValue;//from  ww  w.ja va 2  s  .  c o  m
    if (value == null) {
        strValue = "";
    } else if (value instanceof String) {
        strValue = (String) value;
    } else if (value instanceof Double) {
        Double d = (Double) value;
        strValue = LogFrameExportData.AGGR_AVG_FORMATTER.format(d.doubleValue());
    } else if (value instanceof Long) {
        Long l = (Long) value;
        strValue = LogFrameExportData.AGGR_SUM_FORMATTER.format(l.longValue());
    } else { // date
        strValue = ExportConstants.EXPORT_DATE_FORMAT.format((Date) value);
    }

    cell.setStringValue(strValue);
    cell.setCellStyleName(coreStyleName);
    return cell;
}

From source file:org.apache.pig.impl.util.CastUtils.java

public static Integer stringToInteger(String str) {
    if (str == null) {
        return null;
    } else {/*from   ww  w  .  j  av  a2  s  .  com*/
        try {
            return Integer.parseInt(str);
        } catch (NumberFormatException e) {
            // It's possible that this field can be interpreted as a double.
            // Unfortunately Java doesn't handle this in Integer.valueOf. So
            // we need to try to convert it to a double and if that works
            // then
            // go to an int.
            try {
                Double d = Double.valueOf(str);
                // Need to check for an overflow error
                if (d.doubleValue() > mMaxInt.doubleValue() + 1.0) {
                    LogUtils.warn(CastUtils.class, "Value " + d + " too large for integer",
                            PigWarning.TOO_LARGE_FOR_INT, mLog);
                    return null;
                }
                return Integer.valueOf(d.intValue());
            } catch (NumberFormatException nfe2) {
                LogUtils.warn(CastUtils.class,
                        "Unable to interpret value " + str + " in field being "
                                + "converted to int, caught NumberFormatException <" + e.getMessage()
                                + "> field discarded",
                        PigWarning.FIELD_DISCARDED_TYPE_CONVERSION_FAILED, mLog);
                return null;
            }
        }
    }
}

From source file:org.apache.pig.impl.util.CastUtils.java

public static Long stringToLong(String str) {
    if (str == null) {
        return null;
    } else {/*from w w w .j a v a 2 s.  co  m*/
        try {
            return Long.parseLong(str);
        } catch (NumberFormatException e) {
            // It's possible that this field can be interpreted as a double.
            // Unfortunately Java doesn't handle this in Long.valueOf. So
            // we need to try to convert it to a double and if that works
            // then
            // go to an long.
            try {
                Double d = Double.valueOf(str);
                // Need to check for an overflow error
                if (d.doubleValue() > mMaxLong.doubleValue() + 1.0) {
                    LogUtils.warn(CastUtils.class, "Value " + d + " too large for long",
                            PigWarning.TOO_LARGE_FOR_INT, mLog);
                    return null;
                }
                return Long.valueOf(d.longValue());
            } catch (NumberFormatException nfe2) {
                LogUtils.warn(CastUtils.class,
                        "Unable to interpret value " + str + " in field being "
                                + "converted to long, caught NumberFormatException <" + nfe2.getMessage()
                                + "> field discarded",
                        PigWarning.FIELD_DISCARDED_TYPE_CONVERSION_FAILED, mLog);
                return null;
            }
        }
    }
}

From source file:de.dekarlab.moneybuilder.model.parser.JsonBookSaver.java

/**
 * Is period value empty.//from   w  w w . j a v a2  s .c  om
 * 
 * @return
 */
protected static boolean isEmptyBudget(Map<String, Double> periodBudget) {
    Iterator<String> it = periodBudget.keySet().iterator();
    while (it.hasNext()) {
        String id = it.next();
        Double value = periodBudget.get(id);
        if (value.doubleValue() != 0.0) {
            return false;
        }
    }
    return true;
}

From source file:de.dekarlab.moneybuilder.model.parser.JsonBookSaver.java

/**
 * Save period budget.//from  w ww.jav  a2s .  c  om
 * 
 * @param periodBudget
 * @param jsonWriter
 */
protected static void savePeriodBudget(Map<String, Double> periodBudget, JSONWriter jsonWriter) {
    if (!isEmptyBudget(periodBudget)) {
        jsonWriter.key("periodBudget");
        jsonWriter.array();
        Iterator<String> it = periodBudget.keySet().iterator();
        while (it.hasNext()) {
            String id = it.next();
            Double value = periodBudget.get(id);
            if (value.doubleValue() != 0.0) {
                jsonWriter.object();
                jsonWriter.key("periodId").value(id);
                jsonWriter.key("budget").value(value);
                jsonWriter.endObject();
            }
        }
        jsonWriter.endArray();
    }
}

From source file:AIR.Common.Configuration.AppSettingsHelper.java

private static double getDouble(String key, Double defaultValue) {
    String rawValue = get(key);/*from w w w.j a  v a  2  s  .co m*/

    if (!StringUtils.isEmpty(rawValue)) {
        double value = Double.parseDouble(rawValue);
        return value;

    }

    return defaultValue != null ? defaultValue.doubleValue() : 0;
}