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.sastix.cms.common.client.impl.ApiVersionClientImpl.java

/**
 * For testing/mocking only usage//from ww  w  . j  a v a 2s .c  o m
 */
public ApiVersionClientImpl(final String host, final String port, final String apiVersion,
        final VersionDTO versionDTO, final RetryRestTemplate retryRestTemplate) {
    //disable lazyness when mocking
    lazyUpdate = false;
    this.host = host;
    this.port = port;
    this.retryRestTemplate = retryRestTemplate;
    this.apiVersion = apiVersion;
    if (!versionDTO.getVersionContexts().containsKey(apiVersion)) {
        if (versionDTO.getMinVersion() > Double.valueOf(apiVersion)) {
            throw new VersionNotSupportedException("API Version " + apiVersion
                    + " is outdated. Supported Versions are " + versionDTO.toString());
        } else {
            throw new VersionNotSupportedException("API Version " + apiVersion
                    + " is not supported. Supported Versions are " + versionDTO.toString());
        }
    } else {
        context = versionDTO.getVersionContexts().get(apiVersion);
    }
}

From source file:com.asprise.imaging.core.util.JsonUtils.java

public static Integer toInteger(Object object, Integer defaultValue) {
    if (object == null) {
        return defaultValue;
    }//from   www  . j  av a2s  .  c om
    if (object instanceof Number) {
        return ((Number) object).intValue();
    }

    try {
        Double value = Double.valueOf(object.toString().trim());
        return value.intValue();
    } catch (NumberFormatException e) {
        return defaultValue;
    }
}

From source file:com.wabacus.system.datatype.DoubleType.java

public Object label2value(String label) {
    if (label == null || label.trim().equals(""))
        return null;
    if (this.numberformat != null && !this.numberformat.trim().equals("")) {
        return Double.valueOf(this.getNumber(label.trim()).doubleValue());
    } else {/*from  w  w w .ja va2 s  .com*/
        return Double.valueOf(label.trim());
    }
}

From source file:ml.shifu.shifu.udf.CalculateBinAvgScoreUDF.java

public Tuple exec(Tuple input) throws IOException {
    TupleFactory tupleFactory = TupleFactory.getInstance();

    if (input == null || input.size() == 0) {
        return null;
    }/*from   ww  w . j  a v  a  2 s .  com*/

    Integer columnNum = (Integer) input.get(0);
    DataBag bag = (DataBag) input.get(1);

    ColumnConfig config = columnConfigList.get(columnNum);

    Double[] binScore = new Double[config.getBinLength()];
    Integer[] binCount = new Integer[config.getBinLength()];

    for (int i = 0; i < binScore.length; i++) {
        binScore[i] = 0.0;
        binCount[i] = 0;
    }

    for (Tuple t : bag) {
        if (t.get(1) == null || StringUtils.isBlank(t.get(1).toString())) {
            continue;
        }

        int binNum = BinUtils.getBinNum(config, t.get(1).toString());
        // int binNum = CommonUtils.getBinNum(config.getBinBoundary(), Double.valueOf(t.get(1).toString()));
        Object scoreStr = t.get(2);
        if (scoreStr == null) {
            log.error(t.get(1).toString() + " has null value!");
            continue;
        }

        binScore[binNum] += Double.valueOf(t.get(2).toString());
        binCount[binNum]++;
    }

    for (int i = 0; i < binScore.length; i++) {
        binScore[i] /= binCount[i];
    }

    Tuple tuple = tupleFactory.newTuple();
    tuple.append(columnNum);
    for (Double score : binScore) {
        tuple.append((int) Math.round(score));
    }
    return tuple;
}

From source file:com.stratio.cassandra.index.schema.ColumnMapperLong.java

/** {@inheritDoc} */
@Override/*from   w w  w . ja  v a2  s. com*/
public Long indexValue(String name, Object value) {
    if (value == null) {
        return null;
    } else if (value instanceof Number) {
        return ((Number) value).longValue();
    } else if (value instanceof String) {
        String svalue = (String) value;
        try {
            return Double.valueOf(svalue).longValue();
        } catch (NumberFormatException e) {
            String message = String.format("Field %s requires a base 10 long, but found \"%s\"", name, svalue);
            throw new IllegalArgumentException(message);
        }
    } else {
        String message = String.format("Field %s requires a base 10 long, but found \"%s\"", name, value);
        throw new IllegalArgumentException(message);
    }
}

From source file:com.stratio.cassandra.index.schema.ColumnMapperFloat.java

/** {@inheritDoc} */
@Override// w w  w .  j a v a 2  s . com
public Float indexValue(String name, Object value) {
    if (value == null) {
        return null;
    } else if (value instanceof Number) {
        return ((Number) value).floatValue();
    } else if (value instanceof String) {
        String svalue = (String) value;
        try {
            return Double.valueOf(svalue).floatValue();
        } catch (NumberFormatException e) {
            String message = String.format("Field %s requires a base 10 float, but found \"%s\"", name, svalue);
            throw new IllegalArgumentException(message);
        }
    } else {
        String message = String.format("Field %s requires a base 10 float, but found \"%s\"", name, value);
        throw new IllegalArgumentException(message);
    }
}

From source file:com.yahoo.platform.yui.coverage.report.FileReport.java

/**
 * Returns the percentage of lines called.
 * @return The percentage of lines called.
 * @throws org.json.JSONException/*from   ww  w .  j  a  va2 s . c o  m*/
 */
public double getCalledLinePercentage() throws JSONException {
    DecimalFormat twoDForm = new DecimalFormat("#.##");
    return Double
            .valueOf(twoDForm.format(((double) getCalledLineCount() / (double) getTotalLineCount()) * 100));
}

From source file:com.stratio.cassandra.index.schema.ColumnMapperDouble.java

/** {@inheritDoc} */
@Override// w  w w.j a  va  2s. c o m
public Double indexValue(String name, Object value) {
    if (value == null) {
        return null;
    } else if (value instanceof Number) {
        return ((Number) value).doubleValue();
    } else if (value instanceof String) {
        String svalue = (String) value;
        try {
            return Double.valueOf(svalue);
        } catch (NumberFormatException e) {
            String message = String.format("Field %s requires a base 10 double, but found \"%s\"", name,
                    svalue);
            throw new IllegalArgumentException(message);
        }
    } else {
        String message = String.format("Field %s requires a base 10 double, but found \"%s\"", name, value);
        throw new IllegalArgumentException(message);
    }
}

From source file:com.stratio.cassandra.index.schema.ColumnMapperInteger.java

/** {@inheritDoc} */
@Override/*from   w w w.  j  av  a  2 s . co m*/
public Integer indexValue(String name, Object value) {
    if (value == null) {
        return null;
    } else if (value instanceof Number) {
        return ((Number) value).intValue();
    } else if (value instanceof String) {
        String svalue = (String) value;
        try {
            return Double.valueOf(svalue).intValue();
        } catch (NumberFormatException e) {
            String message = String.format("Field %s requires a base 10 integer, but found \"%s\"", name,
                    svalue);
            throw new IllegalArgumentException(message);
        }
    } else {
        String message = String.format("Field %s requires a base 10 integer, but found \"%s\"", name, value);
        throw new IllegalArgumentException(message);
    }
}

From source file:org.sonar.plugins.ral.GaugeChart.java

private ValueDataset createDataset(ChartParameters params) {
    String value = params.getValue(PARAM_VALUES);
    DefaultValueDataset set = new DefaultValueDataset(Double.valueOf(value) / 100);
    return set;/*w  w  w. j av a 2s.  c o  m*/
}