Example usage for java.lang Double Double

List of usage examples for java.lang Double Double

Introduction

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

Prototype

@Deprecated(since = "9")
public Double(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Double object that represents the floating-point value of type double represented by the string.

Usage

From source file:com.cloudmade.api.geometry.Point.java

@Override
public int hashCode() {
    return new Double(lat).hashCode() * 37 + new Double(lng).hashCode();
}

From source file:com.wsn.PieChartDemo.java

/**
 * Creates a sample dataset./*from w w  w  .  j a v  a  2s  . c o  m*/
 * 
 * @return A sample dataset.
 */
private static PieDataset createDataset(double successRate, double lostRate) {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("Fail", new Double(lostRate));
    dataset.setValue("Success", new Double(successRate));
    return dataset;
}

From source file:com.adaptris.core.services.jdbc.types.StringColumnTranslatorTest.java

@Test
public void testAsDoubleTranslator() throws Exception {
    JdbcResultRow row = new JdbcResultRow();
    row.setFieldValue("testField", new Double(111), Types.VARCHAR);

    {//from ww  w . j av a  2s. co m
        String translated = translator.translate(row, 0);
        assertEquals("111.0", translated);
    }
    {
        String translated = translator.translate(row, "testField");
        assertEquals("111.0", translated);
    }
}

From source file:nz.net.orcon.kanban.automation.plugin.ScriptPluginTest.java

@Test
public void TestPlugin() throws Exception {
    final Action action = createAction();
    action.setResource("answer=x+y;");

    Map<String, Object> context = new HashMap<String, Object>();
    context.put("boardid", "test-board");
    context.put("x", 10);
    context.put("y", 15);

    Map<String, Object> process = getPlugin().process(action, context);
    Object result = process.get("answer");
    assertNotNull(result);//from ww w. java 2s  .c  o  m
    assertTrue(result.equals(new Double(25)));
}

From source file:edu.ucla.stat.SOCR.chart.demo.CompassDemo1.java

protected ValueDataset createDateset(boolean isDemo) {
    if (isDemo) {
        ValueDataset dataset = new DefaultValueDataset(new Double(45.0));
        return dataset;
    } else//from   w  w w  .  j  a  v a  2 s  .co m
        return super.createDataset(false);

}

From source file:com.hihframework.core.utils.CurrencyConverter.java

/**
 * Convert a String to a Double and a Double to a String
 *
 * @param type the class type to output/*from   w  w w .  j  a va 2s .  c  o  m*/
 * @param value the object to convert
 * @return object the converted object (Double or String)
 */
public final Object convert(final Class<?> type, final Object value) {
    // for a null value, return null
    if (value == null) {
        return null;
    } else {
        if (value instanceof String) {
            if (log.isDebugEnabled()) {
                log.debug("value (" + value + ") instance of String");
            }

            try {
                if (StringUtils.isNotEmpty(String.valueOf(value))) {
                    return null;
                }

                if (log.isDebugEnabled()) {
                    log.debug("converting '" + value + "' to a decimal");
                }

                //formatter.setDecimalSeparatorAlwaysShown(true);
                Number num = formatter.parse(String.valueOf(value));

                return new Double(num.doubleValue());
            } catch (ParseException pe) {
                pe.printStackTrace();
            }
        } else if (value instanceof Double) {
            if (log.isDebugEnabled()) {
                log.debug("value (" + value + ") instance of Double");
                log.debug("returning double: " + formatter.format(value));
            }

            return formatter.format(value);
        }
    }

    throw new ConversionException("Could not convert " + value + " to " + type.getName() + "!");
}

From source file:org.springmodules.util.ObjectsTests.java

public void testHashCodeWithDouble() {
    double dbl = 9830.43;
    int expected = (new Double(dbl)).hashCode();
    assertEquals(expected, Objects.hashCode(dbl));
}

From source file:com.angstoverseer.service.command.handler.impl.WeightWatchCommand.java

@Override
public String execute(CommandParameters commandParameters) {
    final ParsedCommand parsedCommand = commandParser.parse(commandParameters);

    String value = parsedCommand.getDescription().toString().trim();
    if (!NumberUtils.isNumber(value)) {
        return "Error. Not a number: " + parsedCommand.getDescription();
    }//from  ww w. ja  va2  s .  c o  m

    Weight weight = new Weight();
    weight.setValue(new Double(value));
    weight.setDateTime(parsedCommand.getDateTime());
    weightDao.save(weight);

    return "Weight watched.";
}

From source file:edu.usc.goffish.gofs.formats.gml.GMLWriter.java

public static Object classValueToGMLValue(Object value) {
    if (value instanceof Integer) {
        return new Long(((Integer) value).longValue());
    } else if (value instanceof Float) {
        return new Double(((Float) value).doubleValue());
    } else if (value instanceof Boolean) {
        return new Long(((Boolean) value).booleanValue() ? 1L : 0L);
    } else if (value instanceof List) {
        @SuppressWarnings("unchecked")
        List<Object> list = (List<Object>) value;
        List<KeyValuePair> children = new ArrayList<>(list.size());
        for (Object v : list) {
            children.add(KeyValuePair.createKVP("value", v));
        }/*  w w w.jav  a  2 s .  co  m*/
        return children;
    }

    return value;
}

From source file:gov.nih.nci.caintegrator.application.zip.FileNameGenerator.java

public static String generateUniqueFileName(String fileName, String type, String platform) {
    String uniqueZipFileName = null;
    String platformID = null;/*from www .j  av  a2 s  .  c o m*/

    if (fileName != null && type != null && platform != null) {
        if (platform.equals(Constants.AFFY_OLIGO_PLATFORM)) {
            platformID = "AFFY-U133P2";
        } else if (platform.equals(Constants.AFFY_100K_SNP_ARRAY)) {
            platformID = "AFFY-100K-SNP";
        }
        uniqueZipFileName = createFilename(fileName);
        // Get a random number of up to 7 digits      
        int sevenDigitRandom = new Double(Math.random() * 10000000).intValue();

        // Get the last 7 digits of the Java timestamp
        String s = String.valueOf(System.currentTimeMillis());
        String lastSevenOfTimeStamp = s.substring(s.length() - 7, s.length());

        // Put it all together
        uniqueZipFileName = fileName + "_" + platformID + "_" + type + "_" + sevenDigitRandom
                + lastSevenOfTimeStamp;
    }
    return uniqueZipFileName;
}