Example usage for java.lang Double valueOf

List of usage examples for java.lang Double valueOf

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static Double valueOf(double d) 

Source Link

Document

Returns a Double instance representing the specified double value.

Usage

From source file:com.epam.ta.reportportal.core.widget.content.LaunchesComparisonContentLoader.java

private Map<String, List<ChartObject>> convertResult(List<ChartObject> objects) {
    Map<String, List<ChartObject>> result = new HashMap<>();
    DecimalFormat formatter = new DecimalFormat("###.##");

    for (ChartObject object : objects) {
        Map<String, String> values = new HashMap<>();
        /* Total */
        Double totalValue = Double.valueOf(object.getValues().get(getTotalFieldName()));
        values.put(getTotalFieldName(), formatter.format(totalValue));

        /* Failed */
        Double failedItems = totalValue.intValue() == 0 ? 0.0
                : Double.valueOf(object.getValues().get(getFailedFieldName())) / totalValue * 100;
        values.put(getFailedFieldName(), formatter.format(failedItems));

        /* Skipped */
        Double skippedItems = totalValue.intValue() == 0 ? 0.0
                : Double.valueOf(object.getValues().get(getSkippedFieldName())) / totalValue * 100;
        values.put(getSkippedFieldName(), formatter.format(skippedItems));

        /* Passed */
        values.put(getPassedFieldName(),
                formatter.format((totalValue.intValue() == 0) ? 0.0 : 100 - failedItems - skippedItems));

        /* To Investigate */
        int toInvestigateQuantity = Integer.parseInt(object.getValues().get(getToInvestigateFieldName()));

        /* Product Bugs */
        int productBugsQuantity = Integer.parseInt(object.getValues().get(getProductBugFieldName()));

        /* System Issues */
        int systemIssuesQuantity = Integer.parseInt(object.getValues().get(getSystemIssueFieldName()));

        /* Automation Bugs */
        int testBugsQuantity = Integer.parseInt(object.getValues().get(getAutomationBugFieldName()));

        String noDefectValue = object.getValues().get(getNoDefectFieldName());
        int noDefectQuantity = noDefectValue == null ? 0 : Integer.parseInt(noDefectValue);

        int failedQuantity = toInvestigateQuantity + productBugsQuantity + systemIssuesQuantity
                + testBugsQuantity + noDefectQuantity;
        if (failedQuantity != 0) {
            Double investigatedItems = (double) toInvestigateQuantity / failedQuantity * 100;
            values.put(getToInvestigateFieldName(), formatter.format(investigatedItems));

            Double productBugItems = (double) productBugsQuantity / failedQuantity * 100;
            values.put(getProductBugFieldName(), formatter.format(productBugItems));

            Double systemIssueItems = (double) systemIssuesQuantity / failedQuantity * 100;
            values.put(getSystemIssueFieldName(), formatter.format(systemIssueItems));

            Double noDefectItems = (double) noDefectQuantity / failedQuantity * 100;
            values.put(getNoDefectFieldName(), formatter.format(noDefectItems));

            values.put(getAutomationBugFieldName(), formatter
                    .format(100 - investigatedItems - productBugItems - systemIssueItems - noDefectItems));
        } else {//from   w w  w  .j  a  v a 2s. c om
            String formatted = formatter.format(0.0);
            values.put(getToInvestigateFieldName(), formatted);
            values.put(getProductBugFieldName(), formatted);
            values.put(getSystemIssueFieldName(), formatted);
            values.put(getAutomationBugFieldName(), formatted);
            values.put(getNoDefectFieldName(), formatted);
        }
        object.setValues(values);
    }
    result.put(RESULT, objects);
    return result;
}

From source file:com.insightml.nlp.analysis.LanguageAnalysisProducer.java

public final List<Triple<R, Double, Integer>> correlation(final ISamples<? extends ITextSample, ?> instances,
        final LanguagePipeline pipeline, final int minOccurrences, final double minAbsCorrelation,
        final double minCorrelation, final double maxCorrelation, final int maxResults, final int labelIndex) {
    final List<Triple<R, Double, Integer>> tokens = bla(instances, pipeline, minOccurrences, minAbsCorrelation,
            minCorrelation, maxCorrelation, labelIndex);
    Collections.sort(tokens,/*from  www  .  j  a v  a2 s .c  om*/
            (o1, o2) -> Double.valueOf(Math.abs(o2.getSecond())).compareTo(Math.abs(o1.getSecond())));
    return tokens.subList(0, Math.min(maxResults, tokens.size()));
}

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

public double getDouble(String key, Double defaultValue) {
    String rawValue = get(key);//from  ww w.  j av  a2s. c  om
    defaultValue = (defaultValue == null) ? 0 : defaultValue;
    return StringUtils.isEmpty(rawValue) ? defaultValue : Double.valueOf(rawValue);
}

From source file:com.soomla.store.domain.MarketItem.java

/**
 * Converts the current <code>MarketItem</code> to a <code>JSONObject</code>.
 *
 * @return A <code>JSONObject</code> representation of the current <code>MarketItem</code>.
 *//*ww w  .jav  a2  s. c  om*/
public JSONObject toJSONObject() {
    JSONObject jsonObject = new JSONObject();
    try {
        jsonObject.put(StoreJSONConsts.MARKETITEM_MANAGED, mManaged.ordinal());
        jsonObject.put(StoreJSONConsts.MARKETITEM_ANDROID_ID, mProductId);
        jsonObject.put(StoreJSONConsts.MARKETITEM_PRICE, Double.valueOf(mPrice));
    } catch (JSONException e) {
        SoomlaUtils.LogError(TAG, "An error occurred while generating JSON object.");
    }

    return jsonObject;
}

From source file:com.hmsinc.epicenter.model.geography.util.GeocoderDotUSClient.java

public Geometry geocode(String address, String city, String state, String zipcode) {

    Validate.notNull(address);//  w ww.  j a  v  a  2  s.  c o  m
    Validate.notNull(city);
    Validate.notNull(state);
    Validate.notNull(zipcode);

    Geometry g = null;

    try {

        final GetMethod get = new GetMethod(geoCoderURL);

        final NameValuePair[] query = { new NameValuePair("address", address), new NameValuePair("city", city),
                new NameValuePair("state", state), new NameValuePair("zipcode", zipcode) };

        get.setQueryString(query);
        httpClient.executeMethod(get);

        final String response = get.getResponseBodyAsString();
        get.releaseConnection();

        if (response != null) {
            final StrTokenizer tokenizer = StrTokenizer.getCSVInstance(response);
            if (tokenizer.size() == 5) {

                final Double latitude = Double.valueOf(tokenizer.nextToken());
                final Double longitude = Double.valueOf(tokenizer.nextToken());

                g = factory.createPoint(new Coordinate(longitude, latitude));
                logger.debug("Geometry: " + g.toString());
            }
        }

    } catch (HttpException e) {
        throw new RuntimeException(e);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    return g;
}

From source file:bioLockJ.module.parser.r16s.QiimeParser.java

/**
 * Create OTU nodes based on classifier output.  One file will have info for all sampelIDs,
 * which are indexed within orderedSampleIDs.
 *///from ww  w.  j ava  2s .co m
@Override
protected void createOtuNodes() throws Exception {
    final File file = getInputFiles().get(0);
    Log.out.info("PARSE FILE = " + file.getName());
    final BufferedReader reader = AppController.getFileReader(file);
    try {
        for (String line = reader.readLine(); line != null; line = reader.readLine()) {
            if (!line.startsWith("#")) {
                final StringTokenizer st = new StringTokenizer(line, Constants.TAB_DELIM);
                int index = 0;
                final String taxa = st.nextToken();
                while (st.hasMoreTokens()) {
                    final Integer count = Double.valueOf(st.nextToken()).intValue();
                    final String id = QiimeMappingUtil.getSampleIds().get(index++);
                    if (count > 0) {
                        final QiimeNode node = new QiimeNode(taxa, count);
                        addOtuNode(id, node);
                    }
                }
            }
        }
    } catch (final Exception ex) {
        throw new Exception("Error occurred parsing file: " + file.getName(), ex);
    } finally {
        reader.close();
    }
}

From source file:com.aurel.track.fieldType.runtime.system.text.SystemDurationRT.java

/**
 * Sets the  default values for a field on the workItem from the config settings
 * @param fieldID//from  ww w  . j a  v a2s.c om
 * @param parameterCode
 * @param validConfig
 * @param fieldSettings
 * @param workItemBean
 * @return
 */
@Override
public void setDefaultAttribute(Integer fieldID, Integer parameterCode, Integer validConfig,
        Map<String, Object> fieldSettings, TWorkItemBean workItemBean) {
    if (workItemBean != null) {
        Date startDate = getStartDate(workItemBean);
        Date endDate = getEndDate(workItemBean);
        if (startDate != null && endDate != null) {
            Integer differenceInDay = DateTimeUtils.getDurationBetweenDates(startDate, endDate, true);
            workItemBean.setAttribute(fieldID, Double.valueOf(differenceInDay));
        }
    }
}

From source file:window.view.VueCourbe.java

/**
 * Cree les donnee de la courbe//from w  w w.j  a va2s. c  o  m
 * @return le tableau de donnees de la courbe
 */
protected DefaultXYDataset getData() {

    double[][] yValues = new double[2][this._listeDiff.size()];
    double[][] xValues = new double[2][this._listeDiff.size()];

    // X values
    for (int i = 0; i < this._listeDiff.size(); i++) {
        yValues[0][i] = Double.valueOf(this._listeIterations.get(i));
        xValues[0][i] = Double.valueOf(this._listeIterations.get(i));
    }

    // Y values
    for (int i = 0; i < this._listeDiff.size(); i++) {
        yValues[1][i] = Double.valueOf(this._listeDiff.get(i));
        xValues[1][i] = Double.valueOf(this._listeDiff.get(i));
    }

    DefaultXYDataset dataset = new DefaultXYDataset();
    dataset.addSeries("Dist. euclidienne", yValues);
    dataset.addSeries("Nb itrations", xValues);

    return dataset;

}