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:fuzzy.util.TestMaxMF.java

@Test
public void testMaxMF() {
    Collection<Double> values = new DoubleRange(-10.0, 30.0, 0.1).toCollection();
    MembershipFunction<Double> mf = new TrapezoidalMembershipFunction(-5.0, -2.0, 10.0, 20.0);
    Map<Double, Double> r = MaxMF.of(values, mf);

    assertTrue(r.containsValue(Double.valueOf(1.0)));
}

From source file:net.opentsdb.contrib.tsquare.support.TsWebUtils.java

public static final Double asDoubleObject(final DataPoint point) {
    final double value;

    if (point.isInteger()) {
        value = (double) point.longValue();
    } else {/*from ww  w.j  a v  a 2s  .  c om*/
        value = point.doubleValue();
    }

    return Double.valueOf(value);
}

From source file:com.glaf.shiro.SecurityConfig.java

public static double getDouble(String key) {
    if (hasObject(key)) {
        String value = filterChainDefinitionMap.get(key);
        return Double.valueOf(value).doubleValue();
    }/*w ww  . j  a  v  a2 s . co  m*/
    return 0;
}

From source file:com.nebhale.cyclinglibrary.web.json.PointJsonSerializerTest.java

@Override
protected void assertResult(String result) throws ParseException {
    assertValue(result, "$.latitude", Double.valueOf(4));
    assertValue(result, "$.longitude", Double.valueOf(5));
    assertValue(result, "$.elevation", Double.valueOf(6));
}

From source file:dk.nodes.webservice.parser.NJSON.java

static Double toDouble(Object value) {
    if (value instanceof Double) {
        return (Double) value;
    } else if (value instanceof Number) {
        return ((Number) value).doubleValue();
    } else if (value instanceof String) {
        try {//from w  ww.  j a  v  a 2s . com
            return Double.valueOf((String) value);
        } catch (NumberFormatException ignored) {
        }
    }
    return null;
}

From source file:Main.java

/**
 * parse a string to an Object of given data type. <br>
 * @param strValue the string value//from   w w w . ja v a  2s.c  o  m
 * @param valueType the full java class name which could be <br>
 * java.util.Date   (default format is yyyy-MM-dd) <br>
 * java.sql.Date   (default format is yyyy-MM-dd) <br>
 * java.sql.Timestamp   (default format is yyyy-MM-dd HH:mm:ss) <br>
 * java.sql.Time   (default format is HH:mm:ss) <br>
 * java.lang.String   <br>
 * java.lang.Boolean   <br>
 * java.lang.Double   <br>
 * java.lang.Long   <br>
 * java.lang.Short   <br>
 * java.lang.Integer   <br>
 * java.lang.Byte   <br>
 * java.lang.Float   <br>
 * java.math.BigInteger   <br>
 * java.math.BigDecimal   <br>
 * 
 * @param format SimpleDateFormat allowed standard formats.
 * @return Object
 * @throws Exception
 */
public static Object parseStringToObject(String strValue, String valueType, String format) throws Exception {
    if ("java.util.Date".equals(valueType)) {
        // default format yyyy-MM-dd
        SimpleDateFormat fmt = new SimpleDateFormat(format != null ? format : "yyyy-MM-dd");
        return (fmt.parse(strValue));
    } else if ("java.sql.Date".equals(valueType)) {
        // default format yyyy-MM-dd
        SimpleDateFormat fmt = new SimpleDateFormat(format != null ? format : "yyyy-MM-dd");
        return (new java.sql.Date(fmt.parse(strValue).getTime()));
    } else if ("java.sql.Timestamp".equals(valueType)) {
        // default format yyyy-MM-dd HH:mm:ss
        SimpleDateFormat fmt = new SimpleDateFormat(format != null ? format : "yyyy-MM-dd HH:mm:ss");
        return (new java.sql.Timestamp(fmt.parse(strValue).getTime()));
    } else if ("java.sql.Time".equals(valueType)) {
        // default format HH:mm:ss
        SimpleDateFormat fmt = new SimpleDateFormat(format != null ? format : "HH:mm:ss");
        return (new java.sql.Time(fmt.parse(strValue).getTime()));
    } else if ("java.lang.Boolean".equals(valueType)) {
        return (Boolean.valueOf(strValue));
    } else if ("java.lang.Double".equals(valueType)) {
        return (Double.valueOf(strValue));
    } else if ("java.lang.Long".equals(valueType)) {
        return (Long.valueOf(strValue));
    } else if ("java.lang.Short".equals(valueType)) {
        return (Short.valueOf(strValue));
    } else if ("java.lang.Integer".equals(valueType)) {
        return (Integer.valueOf(strValue));
    } else if ("java.lang.Byte".equals(valueType)) {
        return (Byte.valueOf(strValue));
    } else if ("java.lang.Float".equals(valueType)) {
        return (Float.valueOf(strValue));
    } else if ("java.math.BigInteger".equals(valueType)) {
        return (new java.math.BigInteger(strValue));
    } else if ("java.math.BigDecimal".equals(valueType)) {
        return (new java.math.BigDecimal(strValue));
    } else {
        return (strValue);
    }
}

From source file:com.epam.training.taranovski.web.project.service.implementation.ValidationServiceImplementation.java

@Override
public boolean salaryIsValid(String salary) {
    boolean valid = true;

    Double d = null;// www  . j  a v  a2s .  c o  m
    try {
        d = Double.valueOf(salary);
        if (d < 0) {
            valid = false;
        }
    } catch (NumberFormatException e) {
        valid = false;
    }

    return valid;
}

From source file:nodeconfig.BarChart_parameters.java

private CategoryDataset createDataset() {

    final DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    for (int i = 0; i < StoringNodes.SetOfAllNodes.size(); i++) {
        Node cur = StoringNodes.SetOfAllNodes.get(i);
        dataset.addValue(Double.valueOf(cur.power) * -1, "RSS", "Node " + cur.Name);
        dataset.addValue(Double.valueOf(cur.Name), "Time", "Node " + cur.Name);
        dataset.addValue(Double.valueOf(cur.SPloss), "Loss", "Node " + cur.Name);
        dataset.addValue(Double.valueOf(cur.SLevel), "Rate", "Node " + cur.Name);
    }/*from  ww  w. java2 s .c om*/
    return dataset;
}

From source file:fuzzy.util.TestCrispFuzzyProduct.java

@Test
public void testCrispFuzzyProduct() {
    Collection<Double> col = new DoubleRange(0.0, 1.0, 0.1).toCollection(); // crisp
    MembershipFunction<Double> mf = new GeneralizedBellShapedMembershipFunction(0.2, 0.5, 0.8); // fuzzy
    Collection<Double> r = CrispFuzzyProduct.of(col, mf);
    assertTrue(r.size() == 11);/*w  w  w  . j  a va 2 s.c  o m*/
    assertEquals(Double.valueOf(0.0), r.iterator().next()); // 0.0 * n = 0.0
}

From source file:com.thoughtworks.studios.journey.jql.conditions.FloatValue.java

public FloatValue(String val) {
    this.val = Double.valueOf(val);
}