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:io.rhiot.component.gps.gpsd.GpsdHelper.java

/**
 * Process the TPVObject, all params required.
 * //from  www.j  a v a2s.co  m
 * @param tpv The time-position-velocity object to process
 * @param processor Processor that handles the exchange.
 * @param endpoint GpsdEndpoint receiving the exchange.
 */
public static void consumeTPVObject(TPVObject tpv, Processor processor, GpsdEndpoint endpoint) {
    Validate.notNull(tpv);
    Validate.notNull(processor);
    Validate.notNull(endpoint);

    Exchange exchange = createOutOnlyExchangeWithBodyAndHeaders(endpoint, new ClientGpsCoordinates(
            new Date(new Double(tpv.getTimestamp()).longValue()), tpv.getLatitude(), tpv.getLongitude()), tpv);
    try {

        processor.process(exchange);
    } catch (Exception e) {
        exchange.setException(e);
    }
}

From source file:videoquotes.util.VideoUtil.java

public void insertQuote(Quote quote, String channelId) {
    int s = new Double(quote.getStart()).intValue(), e = new Double(quote.getEnd()).intValue();
    try {// w  w w . j  a v a2  s . c o m
        Video video = Videos.findOne(quote.getVideoId());
        int segStart[] = video.getStart();
        int segEnd[] = video.getEnd();
        Long quoteId[] = video.getQuoteId();
        if (segStart == null) {
            segStart = new int[] { s };
            segEnd = new int[] { e };
            quoteId = new Long[] { (quote.getKey()) };
        } else {
            for (int i = 0; i < segStart.length; i++)
                if ((s <= segStart[i] && segStart[i] <= e) || (s <= segEnd[i] && segEnd[i] <= e)
                        || (segStart[i] <= s && s <= segEnd[i]) || (segStart[i] <= e && e <= segEnd[i])) {
                    Quotes.delete(quote);
                    throw new VideoIntervalIntersect();
                }

            segStart = Arrays.copyOf(segStart, segStart.length + 1);
            segStart[segStart.length - 1] = s;
            segEnd = Arrays.copyOf(segEnd, segEnd.length + 1);
            segEnd[segEnd.length - 1] = e;
            quoteId = Arrays.copyOf(quoteId, quoteId.length + 1);
            quoteId[quoteId.length - 1] = (quote.getKey());

        }
        video.setStart(segStart);
        video.setEnd(segEnd);
        video.setQuoteId(quoteId);
        video = Videos.update(video);
    } catch (Exception we) {
        try {
            int segStart[] = new int[] { s };
            int segEnd[] = new int[] { e };
            Long quoteId[] = new Long[] { (quote.getKey()) };
            long time = YoutubeUtil.getPublishedTime(quote.getVideoId());
            Videos.save(new Video(quote.getVideoId(), time, channelId, quoteId, segStart, segEnd));
        } catch (Exception eww) {
            throw new UpdateVideoFailed();
        }
    }
}

From source file:com.fileanalyzer.analitics.StatisticCalculatorTest.java

@Ignore
public void statisticCalculatorTest() {
    FileStatistic canonicfileStatistic = new FileStatistic(statCalc.getLine(), 9l, 3l, 36l, new Double(31 / 5));
    log.info(canonicfileStatistic);/*from  w w w .  j  a  v a  2s.c o m*/

    FileStatistic fileStatistic = statCalc.getFileStatistic();
    log.info(fileStatistic);
    assertEquals("Canonic FileStatistic object must be equals calculated object statistics",
            canonicfileStatistic, fileStatistic);
}

From source file:sr.ifes.edu.br.bd2.util.datafactory.LocacaoData.java

public Locacao build(DataFactory df) {

    Locacao locacao = new Locacao();

    locacao.setDataLocacao(df.getDateBetween(df.getDate(1960, 1, 1), df.getDate(2015, 8, 1)));
    Date dataDevolucao = new Date();
    int diasAmais = df.getNumberBetween(5, 15);
    dataDevolucao.setDate(locacao.getDataLocacao().getDate() + diasAmais);
    locacao.setDataDevolucao(dataDevolucao);

    locacao.setCliente(clienteData.build(df));
    locacao.setFilme(filmeData.build(df));

    if (diasAmais > 5) {
        locacao.setMulta(new Double(((diasAmais - 5) * 2)));
    }//w  ww  .  j a  v  a 2 s  .  c o  m

    return locacao;
}

From source file:com.ibm.bluej.commonutil.DenseVectors.java

public static double pearsonsR(double[] x, double[] y) {
    PearsonsCorrelation pc = new PearsonsCorrelation();
    double corrValue = pc.correlation(x, y);

    if (new Double(corrValue).isNaN())
        corrValue = 0.0;/*from   ww w .j a va  2  s. c  o  m*/

    return corrValue;
}

From source file:Main.java

public void actionPerformed(ActionEvent event) {
    loanAmountField.setValue(new Double(12.22));
}

From source file:org.jfree.chart.demo.selection.SelectionDemo7ScatterRenderer.java

private static List<Number> listOfValues(double[] values) {
    List<Number> result = new ArrayList<Number>();
    for (int i = 0; i < values.length; i++) {
        result.add(new Double(values[i]));
    }/*from  ww w.  j  a  v  a 2 s .com*/
    return result;
}

From source file:com.openbravo.pos.payment.PaymentInfo.java

public String printTotal() {
    return Formats.CURRENCY.formatValue(new Double(getTotal()));
}

From source file:Main.java

private static ArrayList<ArrayList> sortObjectArrayListSimpleMaster(ArrayList listIn, String paramName) {
    ArrayList<ArrayList> answer = new ArrayList<ArrayList>();
    ArrayList newList = new ArrayList();
    ArrayList<Integer> indices = new ArrayList<Integer>();
    try {/*from w  w  w .  j  av  a 2s . co m*/
        if (listIn.size() > 0) {
            Class<?> c = listIn.get(0).getClass();
            Field f = c.getDeclaredField(paramName);
            f.setAccessible(true);
            Class<?> t = f.getType();
            Double dd = new Double(14);
            Float ff = new Float(14);
            Integer ii = new Integer(14);
            Map sortedPos = new LinkedHashMap();
            Map sortedNeg = new LinkedHashMap();
            Map unsorted = new LinkedHashMap();
            int indexCount = 0;
            long count = 0;
            if (t.isPrimitive()) {
                for (Object thisObj : listIn) {
                    Object o = f.get(thisObj);
                    double d = 0;
                    if (t.getName().equals("char")) {
                        d = (int) ((Character) o);
                    } else if (t.isInstance(dd))
                        d = (Double) o;
                    else if (t.isInstance(ff))
                        d = (Float) o;
                    else if (t.isInstance(ii))
                        d = (Integer) o;
                    else
                        d = new Double(o.toString());

                    boolean isNegative = false;

                    if (d < 0) {
                        isNegative = true;
                        d = Math.abs(d);
                    }

                    String format = "%1$30f";
                    String newKey = String.format(format, d);
                    String format2 = "%1$20d";
                    String countString = String.format(format2, count);
                    newKey += "-" + countString;
                    if (isNegative) {
                        sortedNeg.put(newKey, thisObj);
                    } else {
                        sortedPos.put(newKey, thisObj);
                    }
                    unsorted.put(thisObj, indexCount);
                    count++;
                    indexCount++;
                }
                TreeMap<String, Object> resultPos = new TreeMap();
                resultPos.putAll(sortedPos);
                sortedPos = resultPos;
                TreeMap<String, Object> resultNeg = new TreeMap();
                resultNeg.putAll(sortedNeg);
                sortedNeg = resultNeg;
            } else if (t.isInstance(paramName)) {
                // System.out.println("is a string with value " + o);
                for (Object thisObj : listIn) {
                    String key = (String) (f.get(thisObj));
                    sortedPos.put(key + "-" + count, thisObj);
                    unsorted.put(thisObj, indexCount);
                    count++;
                    indexCount++;
                }
                TreeMap<String, Object> result = new TreeMap(String.CASE_INSENSITIVE_ORDER);
                result.putAll(sortedPos);
                sortedPos = result;
            }

            Iterator itNeg = sortedNeg.entrySet().iterator();
            while (itNeg.hasNext()) {
                Map.Entry pairs = (Map.Entry) itNeg.next();
                newList.add(pairs.getValue());
                itNeg.remove();
            }

            Collections.reverse(newList);

            Iterator itPos = sortedPos.entrySet().iterator();
            while (itPos.hasNext()) {
                Map.Entry pairs = (Map.Entry) itPos.next();
                Object obj = pairs.getValue();
                newList.add(obj);
                indices.add((Integer) unsorted.get(obj));
                itPos.remove();
            }
        }
    } catch (Exception e) {
        System.out
                .println("problem sorting list.  listIn.size(): " + listIn.size() + " and param: " + paramName);
        answer.add(newList);
        answer.add(indices);
        return answer;
    }
    answer.add(newList);
    answer.add(indices);
    return answer;
}

From source file:org.workin.http.httpclient.v4.handler.response.DoubleResponseHandler.java

@Override
public Double handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
    String result = super.doResponse(response);
    if (result != null)
        return new Double(result);

    String defaultValue = super.getDefaultValue();
    return StringUtils.isNotBlank(defaultValue) ? new Double(defaultValue) : null;
}