List of usage examples for java.lang Double valueOf
@HotSpotIntrinsicCandidate public static Double valueOf(double d)
From source file:com.c123.billbuddy.client.UserFeeder.java
@PostConstruct public void init() throws Exception { log.info("Starting User Feeder"); Integer userAccountId = 1;//www .j av a 2s . c om for (String u : userList) { User foundUser = gigaSpace.readById(User.class, userAccountId); if (foundUser == null) { User user = new User(); user.setName(u); Double balance = (Double.valueOf(Math.random() * 10000)); user.setBalance(Math.round(balance * 100.0) / 100.0); Double creditLimit = Math.random() * 10000; creditLimit = creditLimit - (creditLimit % 1000); creditLimit = Math.round(creditLimit * 100.0) / 100.0; user.setCreditLimit(Double.valueOf(-(creditLimit))); user.setStatus(AccountStatus.ACTIVE); user.setUserAccountId(userAccountId); Address tempAddress = new Address(); tempAddress.setCountry(CountryNames.values()[new Random().nextInt(CountryNames.values().length)]); tempAddress.setCity("123Completed.com"); tempAddress.setState("GIGASPACES"); tempAddress.setStreet("Here and There"); tempAddress.setZipCode(new Random().nextInt()); user.setAddress(tempAddress); // Writing the new user to the space gigaSpace.write(user); log.info(String.format("Added User object with name '%s'", user.getName())); } userAccountId++; } log.info("Stopping User Feeder"); }
From source file:guineu.modules.database.openQualityControlFileDB.SampleInfo.java
public SimplePeakListRowOther getRow(DescriptiveStatistics Stats[]) { SimplePeakListRowOther row = new SimplePeakListRowOther(); int cont = 1; row.setPeak(String.valueOf(cont++), sampleName); //Lyso/*w w w .ja v a 2 s . c o m*/ row.setPeak(String.valueOf(cont++), String.valueOf(LysoPC.RT)); Stats[0].addValue(LysoPC.RT); row.setPeak(String.valueOf(cont++), String.valueOf(LysoPC.heightArea)); Stats[1].addValue(LysoPC.heightArea); row.setPeak(String.valueOf(cont++), getLysoPCratio()); Stats[2].addValue(Double.valueOf(getLysoPCratio())); //PC row.setPeak(String.valueOf(cont++), String.valueOf(PC_50.RT)); Stats[3].addValue(PC_50.RT); row.setPeak(String.valueOf(cont++), String.valueOf(PC_50.heightArea)); Stats[4].addValue(PC_50.heightArea); row.setPeak(String.valueOf(cont++), getPCratio()); Stats[5].addValue(Double.valueOf(getPCratio())); //TG row.setPeak(String.valueOf(cont++), String.valueOf(TG_50.RT)); Stats[6].addValue(TG_50.RT); row.setPeak(String.valueOf(cont++), String.valueOf(TG_50.heightArea)); Stats[7].addValue(TG_50.heightArea); row.setPeak(String.valueOf(cont++), getTGratio()); Stats[8].addValue(Double.valueOf(getTGratio())); row.setPeak(String.valueOf(cont++), date); row.setPeak(String.valueOf(cont++), LysoPC.time); return row; }
From source file:com.ottogroup.bi.streaming.operator.json.aggregate.functions.DoubleContentAggregateFunction.java
/** * @see com.ottogroup.bi.streaming.operator.json.aggregate.functions.JsonContentAggregateFunction#max(java.io.Serializable, java.io.Serializable) */// w w w . ja va2s . co m public Double max(Double oldMax, Double value) throws Exception { if (oldMax == null && value == null) return null; if (oldMax != null && value == null) return oldMax; if (oldMax == null && value != null) return Double.valueOf(value.doubleValue()); if (oldMax.doubleValue() >= value.doubleValue()) return oldMax; return Double.valueOf(value.doubleValue()); }
From source file:com.anrisoftware.globalpom.math.MathUtils.java
/** * Returns the number of decimal places from the specified number string. * //from w w w . j a v a2 s. com * @param str * the {@link String} of the number. * * @param decimalSeparator * the decimal separator character. * * @return the number of decimal places. * * @see DecimalFormatSymbols#getDecimalSeparator() * * @since 2.1 */ public static int decimalPlaces(String str, char decimalSeparator, String exponentSeparator) { String[] split = StringUtils.split(str, exponentSeparator); double exponent = 0.0; int decimal = 0; if (split.length == 2) { exponent = Double.valueOf(split[1]); } String valuestr = split[0]; int i = valuestr.indexOf(decimalSeparator); if (i != -1) { decimal = valuestr.substring(i).length() - 1; } decimal += -1.0 * exponent; return FastMath.abs(decimal); }
From source file:com.ocs.dynamo.importer.impl.BaseTextImporter.java
/** * Reads a numeric value from a unit (and falls back to a default if needed) * //from ww w.j a v a 2 s . c o m * @param unit * the unit (cell or string value) to read from * @param field * the field definition (contains a default value) */ @Override protected Double getNumericValueWithDefault(String unit, XlsField field) { Double value = getNumericValue(unit); if (value == null && !StringUtils.isEmpty(field.defaultValue())) { value = Double.valueOf(field.defaultValue()); } return value; }
From source file:examples.javarpc.CustomMapping.java
public Double parseDouble(Object obj) { try {//w w w . j a v a2 s . c om return Double.valueOf("" + obj).doubleValue(); } catch (Exception err) { mLogger.error("[parseDouble]", err); } return null; }
From source file:io.acme.solution.query.handler.ProfileRegisteredEventHandler.java
@Override public void handleMessage(final Map<String, Object> eventEntries) { if (eventEntries.containsKey(MEMKEY_AGGREGATE_ID)) { final UUID id = UUID.fromString(eventEntries.get(MEMKEY_AGGREGATE_ID).toString()); final Long version = eventEntries.get(MEMKEY_VERSION) != null ? Double.valueOf(eventEntries.get(MEMKEY_VERSION).toString()).longValue() : null;/*from w ww. jav a 2s. co m*/ final String username = eventEntries.get(MAPKEY_USERNAME) != null ? eventEntries.get(MAPKEY_USERNAME).toString() : null; final String email = eventEntries.get(MAPKEY_EMAIL) != null ? eventEntries.get(MAPKEY_EMAIL).toString() : null; final String hashedPassword = eventEntries.get(MAPKEY_HASHEDPASS) != null ? eventEntries.get(MAPKEY_HASHEDPASS).toString() : null; if (id != null && username != null && version != null && email != null && hashedPassword != null) { final QueryableProfile profile = new QueryableProfile(id, version, username, email); final ProfileCredentials credentials = new ProfileCredentials(id, hashedPassword); this.profileDao.save(profile); this.profileCredentialsDao.save(credentials); log.info("New profile registered"); } else { log.trace("Profile discarded due to missing mandatory attributes in the event entries"); } } else { log.trace("Profile discarded due to missing aggregateId in the event entries"); } }
From source file:com.nubits.nubot.pricefeeds.feedservices.CcedkPriceFeed.java
@Override public LastPrice getLastPrice(CurrencyPair pair) { String url = TradeUtilsCCEDK.getCCEDKTickerUrl(pair); long now = System.currentTimeMillis(); long diff = now - lastRequest; if (diff >= refreshMinTime) { String htmlString;//w w w. jav a 2s .c o m try { htmlString = Utils.getHTML(url, true); } catch (IOException ex) { LOG.error(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.error(ex.toString()); lastRequest = System.currentTimeMillis(); return new LastPrice(true, name, pair.getOrderCurrency(), null); } } else { LOG.warn("Wait " + (refreshMinTime - (System.currentTimeMillis() - lastRequest)) + " ms " + "before making a new request. Now returning the last saved price\n\n"); return lastPrice; } }
From source file:org.jmesa.view.excel.Excel2007View.java
@Override public Object render() { XSSFWorkbook workbook = new XSSFWorkbook(); Table table = this.getTable(); String caption = table.getCaption(); if (!StringUtils.hasText(caption)) { caption = "JMesa Export"; }/*w w w. j a va 2 s . c o m*/ XSSFSheet sheet = workbook.createSheet(caption); Row row = table.getRow(); row.getRowRenderer(); List<Column> columns = table.getRow().getColumns(); // renderer header XSSFRow hssfRow = sheet.createRow(0); int columncount = 0; for (Column col : columns) { XSSFCell cell = hssfRow.createCell(columncount++); cell.setCellValue(new XSSFRichTextString(col.getTitle())); } // renderer body Collection<?> items = getCoreContext().getPageItems(); int rowcount = 1; for (Object item : items) { XSSFRow r = sheet.createRow(rowcount++); columncount = 0; for (Column col : columns) { XSSFCell cell = r.createCell(columncount++); Object value = col.getCellRenderer().render(item, rowcount); if (value == null) { value = ""; } if (value instanceof Number) { Double number = Double.valueOf(value.toString()); cell.setCellValue(number); } else { cell.setCellValue(new XSSFRichTextString(value.toString())); } } } return workbook; }
From source file:com.ipeirotis.gal.core.CategoryPair.java
public static void main(String[] args) { Category a = new Category("A"); Category b = new Category("B"); a.setPrior(0.5);/*ww w .ja v a 2 s. c o m*/ b.setPrior(0.5); a.setCost("A", 0.0); a.setCost("B", 1.0); b.setCost("A", 1.0); b.setCost("B", 0.0); Collection<Category> categories = new HashSet<Category>(); categories.add(a); categories.add(b); Map<String, Category> map = new HashMap<String, Category>(); map.put("A", a); map.put("B", b); ConfusionMatrix cm = new ConfusionMatrix(categories); // FOR TESTS: // q=1 should return 0 cost // q=1 should not be affected by m /* cm.setErrorRate("A", "A", 0.9); cm.setErrorRate("A", "B", 0.1); cm.setErrorRate("B", "B", 0.0); cm.setErrorRate("B", "A", 1.0); double tau=0.01; double w = cm.getWorkerWage(1.0, tau, map); double pwage = Double.valueOf(new DecimalFormat("#.####").format(w)); double pworkers = Double.valueOf(new DecimalFormat("#.####").format(1.0/w)); System.out.print("\t"+pwage+"\t"+pworkers); */ //double q=0.9; for (int Q = 95; Q >= 55; Q -= 5) { double q = Q / 100.0; cm.setErrorRate("A", "A", q); cm.setErrorRate("A", "B", 1 - q); cm.setErrorRate("B", "B", q); cm.setErrorRate("B", "A", 1 - q); // Classification cost of a set of m workers with the confusion matrix given above /* for (int m = 1; m<=40; m+=2) { System.out.print(q+"\t"+m); Double c = cm.getWorkerCost(m, map, 100*m*m); System.out.println("\t"+Math.round(100000*c)/100000.0); } */ for (double tau = 0.1; tau > 0.0001; tau /= 1.5) { double pq = Double.valueOf(new DecimalFormat("#.##").format(q)); double ptau = Double.valueOf(new DecimalFormat("#.####").format((1 - tau))); System.out.print(pq + "\t" + ptau); double w = cm.getWorkerWage(1.0, tau, map); double pwage = Double.valueOf(new DecimalFormat("#.####").format(w)); double pworkers = Double.valueOf(new DecimalFormat("#.####").format(1.0 / w)); System.out.print("\t" + pwage + "\t" + pworkers); double wr = cm.getWorkerWageRegr(1.0, tau, map); double pwager = Double.valueOf(new DecimalFormat("#.####").format(wr)); double pworkersr = Double.valueOf(new DecimalFormat("#.####").format(1.0 / wr)); System.out.print("\t" + pwager + "\t" + pworkersr); System.out.println(); } } }