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.brsanthu.dataexporter.DataExporterTestBase.java

protected void addData() {

    exporter.addRow(new Date(dateReference - 2397984), new Integer(1), "Laptop", new Boolean(false),
            new Integer(1), new Double(799.78));
    exporter.addRow(new Date(dateReference - 232042098), new Integer(2), "Mouse", new Boolean(true),
            new Integer(2), new Double(49.30));
    exporter.addRow(new Date(dateReference - 234084277), new Integer(3), "Keyboard", new Boolean(false),
            new Integer(5), new Double(75));
}

From source file:org.jfree.data.category.CategoryToPieDatasetTest.java

/**
 * Some checks for the getValue() method.
 *//*w  ww . j  ava 2  s .c om*/
@Test
public void testGetValue() {
    DefaultCategoryDataset underlying = new DefaultCategoryDataset();
    underlying.addValue(1.1, "R1", "C1");
    underlying.addValue(2.2, "R1", "C2");
    CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, TableOrder.BY_ROW, 0);
    assertEquals(d1.getValue("C1"), new Double(1.1));
    assertEquals(d1.getValue("C2"), new Double(2.2));

    // check negative index throws exception
    try {
        /* Number n = */ d1.getValue(-1);
        fail("Expected IndexOutOfBoundsException.");
    } catch (IndexOutOfBoundsException e) {
        // this is expected
    }

    // check index == getItemCount() throws exception
    try {
        /* Number n = */ d1.getValue(d1.getItemCount());
        fail("Expected IndexOutOfBoundsException.");
    } catch (IndexOutOfBoundsException e) {
        // this is expected
    }

    // test null source
    CategoryToPieDataset p1 = new CategoryToPieDataset(null, TableOrder.BY_COLUMN, 0);
    try {
        /* Number n = */ p1.getValue(0);
        fail("Expected IndexOutOfBoundsException.");
    } catch (IndexOutOfBoundsException e) {
        // this is expected
    }
}

From source file:com.orange.clara.cloud.cf.servicebroker.dbaas.config.CatalogConfig.java

private List<Map<String, Object>> getCosts() {
    Map<String, Object> costsMap = new HashMap<String, Object>();
    Map<String, Object> amount = new HashMap<String, Object>();
    amount.put("usd", new Double(0.0));
    costsMap.put("amount", amount);
    costsMap.put("unit", "MONTHLY");
    return Arrays.asList(costsMap);
}

From source file:com.nubits.nubot.options.SecondaryPegOptionsJSON.java

/**
 *
 * @param optionsJSON/*w  w w.j av  a 2  s .c om*/
 * @return
 */
public static SecondaryPegOptionsJSON create(org.json.JSONObject optionsJSON, CurrencyPair pair) {
    OptionsJSON options = null;
    try {
        //First try to parse compulsory parameters

        String mainFeed = (String) optionsJSON.get("main-feed");

        ArrayList<String> backupFeedNames = new ArrayList<>();
        org.json.JSONObject dataJson = (org.json.JSONObject) optionsJSON.get("backup-feeds");

        //Iterate on backupFeeds

        String names[] = org.json.JSONObject.getNames(dataJson);
        if (names.length < 2) {
            LOG.severe("The bot requires at least two backup data feeds to run");
            System.exit(0);
        }
        for (int i = 0; i < names.length; i++) {
            try {
                org.json.JSONObject tempJson = dataJson.getJSONObject(names[i]);
                backupFeedNames.add((String) tempJson.get("name"));
            } catch (JSONException ex) {
                LOG.severe(ex.toString());
                System.exit(0);
            }
        }

        //Then parse optional settings. If not use the default value declared here

        //set the refresh time according to the global trading pair
        long refreshTime;
        if (pair.getPaymentCurrency().isFiat()) {
            refreshTime = 8 * 60 * 59 * 1000; //8 hours;
        } else {
            refreshTime = 61;
        }
        double wallchangeThreshold = 0.5;
        double spread = 0;
        double distanceThreshold = 10;

        if (optionsJSON.has("wallshift-threshold")) {
            wallchangeThreshold = new Double((optionsJSON.get("wallshift-threshold")).toString());
        }

        if (optionsJSON.has("spread")) {
            spread = new Double((optionsJSON.get("spread")).toString());
            if (spread != 0) {
                LOG.warning(
                        "You are using the \"spread\" != 0 , which is not reccomented by Nu developers for purposes different from testing.");
            }

        }

        if (optionsJSON.has("price-distance-threshold")) {
            distanceThreshold = new Double((optionsJSON.get("price-distance-threshold")).toString());
        }

        /* ignore the refresh-time parameter to avoid single custodians checking faster than others (causing self-executing orders)
         if (optionsJSON.has("refresh-time")) {
         refreshTime = new Integer((optionsJSON.get("refresh-time")).toString());
         }
         */

        return new SecondaryPegOptionsJSON(wallchangeThreshold, spread, distanceThreshold, mainFeed,
                backupFeedNames);
    } catch (JSONException ex) {
        LOG.severe(ex.toString());
        System.exit(0);
    }
    return null; //never reached
}

From source file:bencoding.securely.Converters.java

public static String DoubleToString(double value) {
    String sValue = new Double(value).toString();
    return sValue;
}

From source file:net.decix.jatlasx.test.HandlerTest.java

@Test
public void testMeasurementIDHandler() {

    boolean receivedData = false;
    ResponseHandler<Long> handler = new MeasurementIDHandler();

    JSONArray jsonTestArrayLong = new JSONArray();
    jsonTestArrayLong.put(new Long(10));
    jsonTestArrayLong.put(new Long(100));
    jsonTestArrayLong.put(new Long(1000));
    jsonTestArrayLong.put(new Long(10000));
    jsonTestArrayLong.put(new Long(0));

    JSONObject obj = new JSONObject();
    obj.put("measurements", jsonTestArrayLong);
    obj.put("num", new Integer(100));
    obj.put("balance", new Double(1000.21));
    obj.put("is_vip", new Boolean(true));
    obj.put("nickname", new Object());

    String definitions = new JSONStringer().array().object().key("target").value("192.168.178.1").key("af")
            .value("4").endObject().object().key("newline").value("123").key("newline2").value("456")
            .endObject().endArray().toString();

    String probes = new JSONStringer().array().object().key("value").value("21931").key("type").value("probes")
            .key("requested").value("1").endObject().endArray().toString();

    String myString = new JSONStringer().object().key("definitions").value(definitions).key("probes")
            .value(probes).key("measurements").value(jsonTestArrayLong).key("is_oneoff").value(false)
            .endObject().toString();//  w w  w .  j  a va  2s. co m

    List<Long> list = handler.handleResponse(myString);
    if (!list.isEmpty()) {
        if (PRINT_RESULTS) {
            System.out.println("TEST (HandlerTest) - MeasurementIDHandler " + list);
        }
        receivedData = true;
    }
    assertTrue(receivedData);
}

From source file:ComputeNode.java

public ComputeNode(String servername, Double _underLoadThreshold, Double _overLoadThreshold,
        Double _failProbability, Double _loadConstant, Pair<Double, Double> _loadGaussian, String configFile)
        throws Exception {

    server = (ServerInterface) Naming.lookup("//" + servername + "/Server");

    id = server.registerNode();//from w  w w.  j  av  a2 s  .  com

    lg = new Logger("Compute Node:" + id);
    lg.log(Level.INFO, "ComputeNode " + id + " started.");

    // If a config file was specified
    if (configFile == null) {
        configFile = defaultconf;
    }

    try {
        // TODO: Only load if we need to.
        Properties properties = new Properties();
        properties.load(new FileInputStream(configFile));

        if (_overLoadThreshold == null)
            _overLoadThreshold = new Double(properties.getProperty("computenode.overload_threshhold"));
        overLoadThreshold = _overLoadThreshold;

        if (_underLoadThreshold == null)
            _underLoadThreshold = new Double(properties.getProperty("computenode.underload_threshhold"));
        underLoadThreshold = _underLoadThreshold;

        if (_failProbability == null)
            _failProbability = new Double(properties.getProperty("computenode.fail_probability"));
        failProbability = _failProbability;

        lg.log(Level.FINER, "ComputeNode " + id + ": under load threshhold = " + underLoadThreshold);
        lg.log(Level.FINER, "ComputeNode " + id + ": over load threshhold = " + overLoadThreshold);
        lg.log(Level.FINER, "ComputeNode " + id + ": fail probability = " + failProbability);

        loadConstant = _loadConstant;
        if (loadConstant != null)
            lg.log(Level.FINER, "ComputeNode " + id + ": load constant = " + loadConstant);

        loadGaussian = _loadGaussian;
        if (loadGaussian != null)
            lg.log(Level.FINER,
                    "ComputeNode " + id + ": load gaussian = " + loadGaussian.fst() + "," + loadGaussian.snd());

    } catch (Exception e) {
        lg.log(Level.SEVERE, "ComputeNode " + id + ": Constructor failure! " + underLoadThreshold);
        e.printStackTrace();
        System.exit(1);
    }

    myNodeStats = new NodeStats();
    myNodeStats.setCurrentLoad(getCurrentLoad());
}

From source file:RMOS.PieChart.java

/**
 * Creates a sample dataset.// w  ww  . j  a va 2 s  . com
 * 
 * Source: http://www.bbc.co.uk/news/business-15489523
 *
 * @return A sample dataset.
 */
private static PieDataset createDataset() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    ArrayList<String> s1 = new ArrayList<String>();
    s1 = f1.getStationInGroup();
    for (int i = 0; i < s1.size(); i++) {
        //System.out.println(f1.getStationInGroup().get(i));
        //System.out.println(u.getInCapacity().get(i));
        dataset.setValue(f1.getStationInGroup().get(i), new Double(u.getInCapacity().get(i)));

    }

    /* dataset.setValue("Samsung", new Double(27.8));
     dataset.setValue("Others", new Double(55.3));
     dataset.setValue("Nokia", new Double(16.8));
     dataset.setValue("Apple", new Double(17.1));*/
    return dataset;
}

From source file:org.primefaces.examples.view.DynamicImageController.java

private PieDataset createDataset() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("Istanbul", new Double(45.0));
    dataset.setValue("Ankara", new Double(15.0));
    dataset.setValue("Izmir", new Double(25.2));
    dataset.setValue("Antalya", new Double(14.8));

    return dataset;
}

From source file:com.itemanalysis.psychometrics.polycor.PearsonCorrelation.java

@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if ((obj == null) || (obj.getClass() != this.getClass()))
        return false;
    Double v = new Double(this.value());
    return ((Double) obj) == v;

}