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:de.hybris.platform.acceleratorservices.dataimport.batch.converter.PriceTranslator.java

@Override
public Object importValue(final String valueExpr, final Item toItem) throws JaloInvalidParameterException {
    clearStatus();//from   w w w  .j a  v  a2  s .co m
    Double result = null;
    if (!StringUtils.isBlank(valueExpr)) {
        try {
            result = Double.valueOf(valueExpr);
        } catch (final NumberFormatException exc) {
            setError();
        }
        if (result != null && result.doubleValue() < 0.0) {
            setError();
        }
    }
    return result;
}

From source file:com.nec.harvest.service.impl.ConsumptionTaxRateServiceImpl.java

/** {@inheritDoc} */
@Override// ww w.j a  v  a 2 s . c  o  m
public Double findTaxRateByDate(Date month) throws ServiceException {
    if (month == null) {
        throw new IllegalArgumentException("Can not find tax rate with given processing month null");
    }

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(month);
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    Double taxRate = null;
    try {
        taxRate = findRateDefByDate(calendar);
        return (new Double(taxRate.doubleValue() * 0.01));
    } catch (IllegalArgumentException | ObjectNotFoundException ex) {
        throw ex;
    }
}

From source file:edu.umn.msi.tropix.proteomics.sequest.SequestBeanParameterTranslator.java

private String getDiffSearchString(final Double value, final String residues) {
    if (value == null || value.doubleValue() == 0.00d || residues == null || residues.equals("")) {
        return "0.0 X ";
    } else {//from  w  w w.j  a va  2 s. c o  m
        return value.toString() + " " + residues + " ";
    }
}

From source file:org.cimmyt.corehunter.textui.CoreanalyserTextRunner.java

public void run(String[] args) {
    setupOptions();/*from   w w  w. j a  v  a2  s .c  o m*/
    if (!parseOptions(args)) {
        showUsage();
    }

    System.out.print("\n                ");

    double total[] = new double[measureNames.length];
    double min[] = new double[measureNames.length];
    double max[] = new double[measureNames.length];

    for (int i = 0; i < measureNames.length; ++i) {
        total[i] = 0.0;
        min[i] = Double.MAX_VALUE;
        max[i] = 0.0;
        System.out.format("%" + (precision + 4) + "s ", measureNames[i]);
    }
    System.out.println("");

    for (int i = 0; i < collectionFiles.length; i++) {

        // try to create dataset
        SSRDataset ds = SSRDataset.createFromFile(collectionFiles[i]);
        if (ds == null) {
            System.err.println("");
            System.err.println("Problem parsing dataset file.  Aborting.");
            System.exit(0);
        }

        System.out.format("%15s:", collectionFiles[i]);

        // create an accession collection
        AccessionCollection ac = new AccessionCollection();
        ac.addDataset(ds);

        // create a pseudo-index and add user specified measure to it, with respective weights
        PseudoMeasure pm = new PseudoMeasure();
        for (int j = 0; j < measureNames.length; j++) {
            String measure = measureNames[j];
            try {
                pm.addMeasure(MeasureFactory.createMeasure(measure, ac.size()), 1.0);
            } catch (DuplicateMeasureException dme) {
                System.err.println("");
                System.err.println(dme.getMessage());
                System.exit(0);
            } catch (UnknownMeasureException ume) {
                System.err.println("");
                System.err.println(ume.getMessage());
                System.exit(0);
            }
        }

        Map<String, Double> scores = pm.componentScores(ac.getAccessions());

        for (int j = 0; j < measureNames.length; j++) {
            Double score = scores.get(measureNames[j]);
            double val = score.doubleValue();
            total[j] += val;

            if (val > max[j]) {
                max[j] = val;
            }

            if (val < min[j]) {
                min[j] = val;
            }

            System.out.format("%" + (precision + 4) + "." + precision + "f ", val);
        }
        System.out.println("");
        Accession.reset();
    }

    System.out.print("\n            min:");
    for (int j = 0; j < measureNames.length; j++) {
        System.out.format("%" + (precision + 4) + "." + precision + "f ", min[j]);
    }
    System.out.print("\n            max:");
    for (int j = 0; j < measureNames.length; j++) {
        System.out.format("%" + (precision + 4) + "." + precision + "f ", max[j]);
    }
    System.out.print("\n           mean:");
    for (int j = 0; j < measureNames.length; j++) {
        System.out.format("%" + (precision + 4) + "." + precision + "f ", total[j] / collectionFiles.length);
    }
    System.out.println("");

}

From source file:org.eclipse.ecr.core.storage.sql.coremodel.SQLComplexProperty.java

@Override
public double getDouble(String name) throws DocumentException {
    Double value = (Double) getProperty(name).getValue();
    return value == null ? 0D : value.doubleValue();
}

From source file:org.kuali.kfs.module.cam.util.distribution.AssetPaymentDistributionByTotalCost.java

/**
 * Pre-calculate the asset payments base on AssetPaymentDetail(AccountSouceLines) and AssetPaymentAssetDetails
 * //  ww w  .  j  av a 2s  .  co  m
 * This will iterate by the AssetPaymentDetail as the outer iterator such that payment totals will match up by the AccountingSouceLines
 * in (GL).  The unallocated payment amount will be depleted per each AssetPaymentDetails
 * 
 *  NOTE: reversing the iteration sequence will cause a discrepancy in the AssetPaymentDetail totals 
 * 
 * @param document
 * @param assetPaymentDetailLines
 * @param assetPaymentAssetDetails
 */
private void calculateAssetPaymentDistributions() {

    Map<String, Map<AssetPaymentAssetDetail, KualiDecimal>> assetPaymentAssetDetailMap = new HashMap<String, Map<AssetPaymentAssetDetail, KualiDecimal>>();

    // calculate the asset payment percentage and store into a map
    Map<AssetPaymentAssetDetail, Double> assetPaymentsPercentage = new HashMap<AssetPaymentAssetDetail, Double>(
            doc.getAssetPaymentAssetDetail().size());

    for (AssetPaymentAssetDetail assetPaymentAssetDetail : doc.getAssetPaymentAssetDetail()) {
        // Doing the re-distribution of the cost based on the previous total cost of each asset compared with the total previous cost of the assets.
        // store the result in a temporary map 
        assetPaymentsPercentage.put(assetPaymentAssetDetail,
                getAssetDetailPercentage(doc.getAssetPaymentAssetDetail().size(),
                        new Double(totalHistoricalCost.toString()), assetPaymentAssetDetail));
    }

    // Start the iteration base from the AssetPaymentDetail - accountingSouceLines
    for (AssetPaymentDetail assetPaymentDetail : getAssetPaymentDetailLines()) {

        int paymentCount = doc.getAssetPaymentAssetDetail().size();
        KualiDecimal amount = KualiDecimal.ZERO;

        // Keep unallocated amount so it could be used for last payment amount for the asset (to avoid rounding issue)
        KualiDecimal unallocatedAmount = assetPaymentDetail.getAmount();

        Map<AssetPaymentAssetDetail, KualiDecimal> assetDetailMap = new HashMap<AssetPaymentAssetDetail, KualiDecimal>();
        for (AssetPaymentAssetDetail assetPaymentAssetDetail : doc.getAssetPaymentAssetDetail()) {
            // Doing the re-distribution of the cost based on the previous total cost of each asset compared with the total
            // previous cost of the assets.
            Double percentage = assetPaymentsPercentage.get(assetPaymentAssetDetail);

            if (paymentCount-- == 1) {
                // Deplete the rest of the payment for last payment
                amount = unallocatedAmount;
            } else {
                // Normal payment will be calculated by asset percentage
                Double paymentAmount = new Double(assetPaymentDetail.getAmount().toString());
                amount = new KualiDecimal(paymentAmount.doubleValue() * percentage.doubleValue());
                unallocatedAmount = unallocatedAmount.subtract(amount);
            }
            assetDetailMap.put(assetPaymentAssetDetail, amount);
        }
        assetPaymentAssetDetailMap.put(assetPaymentDetail.getAssetPaymentDetailKey(), assetDetailMap);
    }

    paymentDistributionMap = assetPaymentAssetDetailMap;
}

From source file:com.zte.ums.zenap.itm.agent.plugin.linux.util.Calculator.java

public List fcalculate(Map listMap, String formula, String[] variable) throws MonitorException {
    List retList = new ArrayList();
    Object obj = null;//from w  w w .j a va  2s  .c o m
    try {
        JexlContext jexlContext = new MapContext();
        JexlEngine jexlEngine = new JexlEngine();
        Expression expression = jexlEngine.createExpression(formula);
        int sizej = ((List) (listMap.get(variable[0]))).size();
        // List?
        for (int j = 0; j < sizej; j++) {
            // ???
            for (int i = 0, sizei = variable.length; i < sizei; i++) {
                jexlContext.set(variable[i], ((List) (listMap.get(variable[i]))).get(j));
            }
            obj = expression.evaluate(jexlContext);
            if (obj instanceof Double) {
                Double dd = (Double) obj;
                double dd1 = (dd.doubleValue() * 1000);
                long ld1 = (long) dd1;
                double dd2 = ld1 / 1000.0;
                String sResult = Double.toString(dd2);
                retList.add(sResult);
            } else {
                throw new MonitorException("formular's result is not double type" + formula);
            }
        }

        return retList;
    } catch (Exception e) {
        throw new MonitorException(
                "parsing expression, or expression neither an expression or a reference! or evaluate error"
                        + e.getMessage());
    }
}

From source file:com.ottogroup.bi.streaming.operator.json.aggregate.functions.DoubleContentAggregateFunction.java

/**
 * @see com.ottogroup.bi.streaming.operator.json.aggregate.functions.JsonContentAggregateFunction#sum(java.io.Serializable, java.io.Serializable)
 *///from  ww  w  .ja  v a 2  s.  co  m
public Double sum(Double oldSum, Double value) throws Exception {
    if (oldSum == null && value == null)
        return null;
    if (oldSum != null && value == null)
        return oldSum;
    if (oldSum == null && value != null)
        return Double.valueOf(value.doubleValue());
    return Double.valueOf(oldSum.doubleValue() + value.doubleValue());
}

From source file:com.ottogroup.bi.streaming.operator.json.aggregate.functions.DoubleContentAggregateFunction.java

/**
 * @see com.ottogroup.bi.streaming.operator.json.aggregate.functions.JsonContentAggregateFunction#min(java.io.Serializable, java.io.Serializable)
 *//*w  w w .  ja  v  a2 s .  c  o m*/
public Double min(Double oldMin, Double value) throws Exception {
    if (oldMin == null && value == null)
        return null;
    if (oldMin != null && value == null)
        return oldMin;
    if (oldMin == null && value != null)
        return Double.valueOf(value.doubleValue());
    if (oldMin.doubleValue() <= value.doubleValue())
        return oldMin;
    return Double.valueOf(value.doubleValue());
}

From source file:com.ottogroup.bi.streaming.operator.json.aggregate.functions.DoubleContentAggregateFunction.java

/**
 * @see com.ottogroup.bi.streaming.operator.json.aggregate.functions.JsonContentAggregateFunction#max(java.io.Serializable, java.io.Serializable)
 *///ww  w . j  av  a2 s .  co m
public Double max(Double oldMax, Double value) throws Exception {
    if (oldMax == null && value == null)
        return null;
    if (oldMax != null && value == null)
        return oldMax;
    if (oldMax == null && value != null)
        return Double.valueOf(value.doubleValue());
    if (oldMax.doubleValue() >= value.doubleValue())
        return oldMax;
    return Double.valueOf(value.doubleValue());
}