List of usage examples for java.lang Double valueOf
@HotSpotIntrinsicCandidate public static Double valueOf(double d)
From source file:com.ibasco.agql.core.AbstractWebRequest.java
protected void urlParam(String name, Object value) { RequestBuilder builder = request();/*from w w w . ja va2 s . c o m*/ if (value == null) return; String strValue = String.valueOf(value); if (NumberUtils.isNumber(strValue)) { Double nVal = Double.valueOf(strValue); if (nVal > 0) builder.addQueryParam(name, String.valueOf(value)); return; } builder.addQueryParam(name, String.valueOf(value)); }
From source file:com.nubits.nubot.pricefeeds.CcedkPriceFeed.java
@Override public LastPrice getLastPrice(CurrencyPair pair) { String url = TradeUtils.getCCEDKTickerUrl(pair); long now = System.currentTimeMillis(); long diff = now - lastRequest; if (diff >= refreshMinTime) { String htmlString;/*from www . j a v a 2 s . c o m*/ try { htmlString = Utils.getHTML(url, true); } catch (IOException ex) { LOG.severe(ex.toString()); return new LastPrice(true, name, pair.getOrderCurrency(), null); } JSONParser parser = new JSONParser(); try { //{"errors":false,"response":{"entity":{"pair_id":"2","min":"510","max":"510","avg":"510","vol":"0.0130249"}}} JSONObject httpAnswerJson = (JSONObject) (parser.parse(htmlString)); JSONObject tickerObject = (JSONObject) httpAnswerJson.get("response"); JSONObject entityObject = (JSONObject) tickerObject.get("entity"); double last = Double.valueOf((String) entityObject.get("avg")); lastRequest = System.currentTimeMillis(); lastPrice = new LastPrice(false, name, pair.getOrderCurrency(), new Amount(last, pair.getPaymentCurrency())); return lastPrice; } catch (Exception ex) { LOG.severe(ex.toString()); lastRequest = System.currentTimeMillis(); return new LastPrice(true, name, pair.getOrderCurrency(), null); } } else { LOG.fine("Wait " + (refreshMinTime - (System.currentTimeMillis() - lastRequest)) + " ms " + "before making a new request. Now returning the last saved price\n\n"); return lastPrice; } }
From source file:com.lm.lic.manager.util.GenUtil.java
public static double roundToTwoDecimals(double d) { DecimalFormat twoDecimalFormatter = new DecimalFormat("#.##"); twoDecimalFormatter.setRoundingMode(RoundingMode.DOWN); return Double.valueOf(twoDecimalFormatter.format(d)); }
From source file:de.hybris.platform.integration.cis.tax.strategies.impl.DefaultCisCalculateExternalTaxesFallbackStrategyTest.java
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); defaultCisCalculateExternalTaxesFallbackStrategy = new DefaultCisCalculateExternalTaxesFallbackStrategy(); defaultCisCalculateExternalTaxesFallbackStrategy.setConfigurationService(configurationService); given(configuration.getBigDecimal("cistax.taxCalculation.fallback.fixedpercentage", BigDecimal.valueOf(0D))) .willReturn(BigDecimal.valueOf(9.70d)); given(configurationService.getConfiguration()).willReturn(configuration); final CurrencyModel currencyModel = mock(CurrencyModel.class); final AbstractOrderEntryModel entry = mock(AbstractOrderEntryModel.class); given(currencyModel.getIsocode()).willReturn("USD"); given(abstractOrder.getCurrency()).willReturn(currencyModel); given(abstractOrder.getEntries()).willReturn(Collections.singletonList(entry)); given(entry.getTotalPrice()).willReturn(Double.valueOf(100D)); given(abstractOrder.getDeliveryCost()).willReturn(Double.valueOf(9.9D)); }
From source file:fr.esiea.windmeal.controller.provider.search.geo.GeoProviderSearchCtrl.java
@RequestMapping(method = RequestMethod.GET, params = { "longitude", "latitude" }) @ResponseBody/*from w w w. j av a2 s.co m*/ public Iterable<FoodProvider> SearchProviderNearLocation(@RequestParam("longitude") String longitude, @RequestParam("latitude") String latitude) throws ServiceException, DaoException { Location location = new Location(); location.setLng(Double.valueOf(longitude)); location.setLat(Double.valueOf(latitude)); return geoService.getProviderNear(location); }
From source file:br.com.webbudget.application.component.Color.java
/** * * @param data/*from w w w . j a va2s . co m*/ * @return */ public static Color parse(String data) { if (StringUtils.isBlank(data)) { return null; } final String numbers = data.replace(" ", "").replace("rgba", "").replace("rgb", "").replace("(", "") .replace(")", ""); final String color[] = numbers.split(","); if (color.length < 4) { return new Color(Integer.valueOf(color[0]), Integer.valueOf(color[1]), Integer.valueOf(color[2])); } else { return new Color(Integer.valueOf(color[0]), Integer.valueOf(color[1]), Integer.valueOf(color[2]), Double.valueOf(color[3])); } }
From source file:it.iit.genomics.cru.simsearch.bundle.utils.PantherBridge.java
public static Collection<String[]> getEnrichment(String organism, String fileName, double threshold) { ArrayList<String[]> results = new ArrayList<>(); ArrayListMultimap<String, String> genes = ArrayListMultimap.create(); ArrayListMultimap<Double, String> pvalues = ArrayListMultimap.create(); HashSet<String> uniqueGenes = new HashSet<>(); try {//from ww w . j av a 2 s . c o m String[] enrichmentTypes = { "process", "pathway" }; for (String enrichmentType : enrichmentTypes) { HttpClient client = new HttpClient(); MultipartPostMethod method = new MultipartPostMethod( "http://pantherdb.org/webservices/garuda/tools/enrichment/VER_2/enrichment.jsp?"); // Define name-value pairs to set into the QueryString method.addParameter("organism", organism); method.addParameter("type", "enrichment"); method.addParameter("enrichmentType", enrichmentType); // "function", // "process", // "cellular_location", // "protein_class", // "pathway" File inputFile = new File(fileName); method.addPart(new FilePart("geneList", inputFile, "text/plain", "ISO-8859-1")); // PANTHER does not use the ID type // method.addParameter("IdType", "UniProt"); // Execute and print response client.executeMethod(method); String response = method.getResponseBodyAsString(); for (String line : response.split("\n")) { if (false == "".equals(line.trim())) { String[] row = line.split("\t"); // Id Name GeneId P-value if ("Id".equals(row[0])) { // header continue; } // if (row.length > 1) { String name = row[1]; String gene = row[2]; Double pvalue = Double.valueOf(row[3]); uniqueGenes.add(gene); if (pvalue < threshold) { if (false == genes.containsKey(name)) { pvalues.put(pvalue, name); } genes.put(name, gene); } // } else { // System.out.println("oups: " + row[0]); // } } } method.releaseConnection(); } ArrayList<Double> pvalueList = new ArrayList<>(); Collections.sort(pvalueList); pvalueList.addAll(pvalues.keySet()); Collections.sort(pvalueList); int numGenes = uniqueGenes.size(); for (Double pvalue : pvalueList) { for (String name : pvalues.get(pvalue)) { String geneList = String.join(",", genes.get(name)); String result[] = { name, "" + pvalue, genes.get(name).size() + "/" + numGenes, geneList }; results.add(result); } } } catch (IOException e) { e.printStackTrace(); } return results; }
From source file:com.sarm.aussiepayslipgenerator.service.PaySlipServiceImplTest.java
/** * Test of calculatePayslip method, of class PaySlipServiceImpl. with values * for an employee in Bracket2/*from w w w.j a v a 2 s. c o m*/ */ @Test public void testCalculatePayslipForBracket2() { System.out.println("calculatePayslip"); EmployeeInfo employee = new EmployeeInfo(); employee.setAnnualSalary(29452); employee.setFirstName("Bracket2"); employee.setLastName("Emp2"); employee.setSuperRate(Double.valueOf("9")); employee.setStartDate(new DateTime(2014, 2, 14, 00, 00)); Bracket bracket = new BracketServiceImpl().populate("Bracket2"); PaySlipServiceImpl instance = new PaySlipServiceImpl(); EmployeePaySlip expResult = new EmployeePaySlip(); expResult.setGrossIncome(Integer.toString(2454)); expResult.setIncomeTax(Integer.toString(178)); expResult.setMonthlySuper(Integer.toString(221)); expResult.setNetIncome(Integer.toString(2276)); EmployeePaySlip result = instance.calculatePayslip(employee, bracket); assertEquals(expResult, result); }
From source file:io.hops.experiments.stats.TransactionStatsAggregator.java
public static Map<String, DescriptiveStatistics> aggregate(File statsFile, String headerPattern, String transaction, boolean printSummary) throws IOException { if (!statsFile.exists()) return null; transaction = transaction.toUpperCase(); BufferedReader reader = new BufferedReader(new FileReader(statsFile)); String tx = reader.readLine(); String[] headers = null;// w w w .j a v a 2s .com Map<Integer, DescriptiveStatistics> statistics = Maps.newHashMap(); if (tx != null) { headers = tx.split(","); for (int i = 1; i < headers.length; i++) { String h = headers[i].toUpperCase(); if (h.contains(headerPattern) || headerPattern.equals(ALL)) { statistics.put(i, new DescriptiveStatistics()); } } } int txCount = 0; while ((tx = reader.readLine()) != null) { if (tx.startsWith(transaction) || transaction.equals(ALL)) { txCount++; String[] txStats = tx.split(","); if (txStats.length == headers.length) { for (Map.Entry<Integer, DescriptiveStatistics> e : statistics.entrySet()) { e.getValue().addValue(Double.valueOf(txStats[e.getKey()])); } } } } reader.close(); if (headers == null) return null; if (printSummary) { System.out.println("Transaction: " + transaction + " " + txCount); List<Integer> keys = new ArrayList<Integer>(statistics.keySet()); Collections.sort(keys); for (Integer i : keys) { DescriptiveStatistics stats = statistics.get(i); if (stats.getMin() == 0 && stats.getMax() == 0) { continue; } System.out.println(headers[i]); System.out.println("Min " + stats.getMin() + " Max " + stats.getMax() + " Avg " + stats.getMean() + " Std " + stats.getStandardDeviation()); } } Map<String, DescriptiveStatistics> annotatedStats = Maps.newHashMap(); for (Map.Entry<Integer, DescriptiveStatistics> e : statistics.entrySet()) { annotatedStats.put(headers[e.getKey()].trim(), e.getValue()); } return annotatedStats; }
From source file:com.eu.evaluation.web.controller.ResultController.java
/** * 7.1.7 /*from w w w . j a v a 2 s .c om*/ * * @param evaluateVersionID * @param position * @param instanceType * @return List<StatisticsVO> */ @ResponseBody @RequestMapping(value = "/unilateral/{position}/{evaluateVersionID}/{instanceType}", method = RequestMethod.GET) public List<StatisticsVO> unilateral(@PathVariable("evaluateVersionID") String evaluateVersionID, @PathVariable("position") String position, @PathVariable("instanceType") int instanceType) { evaluateVersionID = THE_LAST_EVALUATE_VERSION_ID.equals(evaluateVersionID) ? findTheLastEvaluateVersionID() : evaluateVersionID; List<SimpleStatistics> list = resultService.findSimpleStatistics(evaluateVersionID, position, EntityEnum.getByInstanceType(instanceType)); List<StatisticsVO> result = new ArrayList<StatisticsVO>(); for (SimpleStatistics ss : list) { double persent = Double.valueOf(ss.getSuccessCount()) / Double.valueOf(ss.getTotal()) * 100; StatisticsVO vo = new StatisticsVO(ss.getEvaluateTypeEnum().getName(), Double.valueOf(StringUtils.formatDouble_2_floor(persent))); result.add(vo); } return result; }