List of usage examples for java.lang Double toString
public static String toString(double d)
From source file:io.fabric8.example.variance.msg.VarianceProcessor.java
@Override public void process(Exchange exchange) throws Exception { System.err.println("VARIANCE GOT EXCHANGE " + exchange); String message = exchange.getIn().getBody(String.class); ObjectMapper objectMapper = new ObjectMapper(); TypeFactory typeFactory = objectMapper.getTypeFactory(); List<Double> values = objectMapper.readValue(message, typeFactory.constructCollectionType(List.class, Double.class)); SummaryStatistics summaryStatistics = new SummaryStatistics(); List<Double> list = new ObjectMapper().readValue(message, List.class); for (Double value : list) { summaryStatistics.addValue(value); }//from www . j av a 2 s . com String variance = Double.toString(summaryStatistics.getVariance()); ActiveMQDestination replyTo = exchange.getIn().getHeader("JMSReplyTo", ActiveMQDestination.class); final String messageId = exchange.getIn().getHeader("JMSMessageID", String.class); if (replyTo != null) { Exchange copy = new DefaultExchange(exchange); copy.setPattern(ExchangePattern.InOnly); copy.getIn().setHeader(Variables.CORRELATION_HEADER, messageId); copy.getIn().setBody(variance); producerTemplate.send("jms:queue:" + replyTo.getPhysicalName(), copy); System.err.println("REPLIED TO " + "jms:queue:" + replyTo.getPhysicalName()); } else { System.err.println("REPLOY NOT SET for exchange: " + exchange.getIn().getHeaders()); } }
From source file:matrix.CreateUrlMatrix.java
public void urlMatrix() throws UnsupportedEncodingException, FileNotFoundException, IOException, ParseException { CosSim cossim = new CosSim(); JSONParser jParser = new JSONParser(); BufferedReader in = new BufferedReader(new InputStreamReader( new FileInputStream("/Users/nSabri/Desktop/tweetMatris/userTweetsUrls.json"), "ISO-8859-9")); JSONArray a = (JSONArray) jParser.parse(in); File fout = new File("/Users/nSabri/Desktop/urlMatris.csv"); FileOutputStream fos = new FileOutputStream(fout); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos)); for (int i = 0; i < a.size(); i++) { for (int j = 0; j < a.size(); j++) { JSONObject tweet1 = (JSONObject) a.get(i); JSONObject tweet2 = (JSONObject) a.get(j); String tweetUrl1 = tweet1.get("title").toString() + tweet1.get("meta").toString(); System.out.println(tweetUrl1); String tweetUrl2 = tweet2.get("title").toString() + tweet1.get("meta").toString(); System.out.println(tweetUrl2); double CosSimValue = cossim.Cosine_Similarity_Score(tweetUrl1, tweetUrl2); CosSimValue = Double.parseDouble(new DecimalFormat("##.###").format(CosSimValue)); bw.write(Double.toString(CosSimValue) + ", "); }//from w w w. ja v a 2 s. com bw.newLine(); } bw.close(); }
From source file:org.cds06.speleograph.graph.ValueAxisEditor.java
public ValueAxisEditor(NumberAxis axis) { super();/*ww w .j a va 2 s. c o m*/ this.axis = axis; this.oldLowValue = axis.getLowerBound(); this.oldHighValue = axis.getUpperBound(); this.maxField = new JTextField(Double.toString(axis.getUpperBound())); this.lowField = new JTextField(Double.toString(axis.getLowerBound())); int max = (int) (axis.getUpperBound() / 5); translateSlider = new JSlider(Adjustable.VERTICAL, -max, max, 0); homotSlider = new JSlider(Adjustable.VERTICAL, -max, max, 0); construct(); setTitle(I18nSupport.translate("graph.valueAxisEditor")); }
From source file:jetbrains.exodus.entitystore.BackupTests.java
public void testSingular() throws Exception { final PersistentEntityStoreImpl store = getEntityStore(); store.getConfig().setMaxInPlaceBlobSize(0); // no in-place blobs final String randomDescription[] = { null }; store.executeInTransaction(new StoreTransactionalExecutable() { @Override// w ww . j a va 2s . co m public void execute(@NotNull StoreTransaction txn) { final Entity issue = txn.newEntity("Issue"); randomDescription[0] = Double.toString(Math.random()); issue.setBlobString("description", randomDescription[0]); } }); final File backupDir = TestUtil.createTempDir(); try { final File backup = CompressBackupUtil.backup(store, backupDir, null, true); final File restoreDir = TestUtil.createTempDir(); try { extractEntireZip(backup, restoreDir); final PersistentEntityStoreImpl newStore = PersistentEntityStores.newInstance(restoreDir); try { newStore.executeInReadonlyTransaction(new StoreTransactionalExecutable() { @Override public void execute(@NotNull final StoreTransaction txn) { assertEquals(1, txn.getAll("Issue").size()); final Entity issue = txn.getAll("Issue").getFirst(); assertNotNull(issue); assertEquals(randomDescription[0], issue.getBlobString("description")); } }); } finally { newStore.close(); } } finally { IOUtil.deleteRecursively(restoreDir); } } finally { IOUtil.deleteRecursively(backupDir); } }
From source file:com.addthis.bundle.value.DefaultDouble.java
@Override public String toString() { return Double.toString(value); }
From source file:ca.ualberta.cs.unter.util.OSMapUtil.java
/** * Convers geo-coordinate into actual address in text * @param coordinate the coordiante// ww w .ja va 2s . c o m * @param responseHandler a custom async event handler */ public static void ReverseGeoCoding(GeoPoint coordinate, AsyncHttpResponseHandler responseHandler) { String url = "latlng=" + Double.toString(coordinate.getLatitude()) + "," + Double.toString(coordinate.getLongitude()); HttpClientUtil.get(url, null, responseHandler); }
From source file:net.sf.json.JSONUtils.java
/** * Produce a string from a double. The string "null" will be returned if the * number is not finite.// ww w.j av a 2 s .c o m * * @param d A double. * @return A String. */ public static String doubleToString(double d) { if (Double.isInfinite(d) || Double.isNaN(d)) { return "null"; } // Shave off trailing zeros and decimal point, if possible. String s = Double.toString(d); if ((s.indexOf('.') > 0) && (s.indexOf('e') < 0) && (s.indexOf('E') < 0)) { while (s.endsWith("0")) { s = s.substring(0, s.length() - 1); } if (s.endsWith(".")) { s = s.substring(0, s.length() - 1); } } return s; }
From source file:net.sourceforge.fenixedu.domain.degreeStructure.EctsComparabilityPercentages.java
@Override public String toString() { List<String> percents = new ArrayList<String>(); for (double percentage : percentages) { percents.add(Double.toString(percentage)); }/*from ww w . j a v a 2 s . c om*/ return StringUtils.join(percents, ":"); }
From source file:com.autentia.intra.converter.MinuteToHourConverter.java
public String getAsString(FacesContext context, UIComponent component, Object value) throws ConverterException { if (value instanceof Integer) { int val = ((Integer) value).intValue(); return Double.toString(val / 60.0); } else {/*w ww . j a v a2s. co m*/ return (String) value; } }
From source file:com.ns.retailmgr.connector.gmaps.GMapConnectorImpl.java
@Override public Map<String, String> getLngLatByAddress(String address) throws RuntimeException { LOGGER.debug("Started method {} - params {}", "getLngLatByAddress", address); final String url = geoLatngUrl + address; try {// w w w.ja v a2 s. co m final GeoCodeLocInfo geocodingResult = restTemplate.getForObject(url, GeoCodeLocInfo.class); final Map<String, String> returnMap = new HashMap<>(); LngLatInfo[] results = geocodingResult.getResults(); for (LngLatInfo res : results) { returnMap.put(ShopConstant.LATITUDE_KEY, Double.toString(res.getGeometry().getLocation().getLat())); returnMap.put(ShopConstant.LONGITUDE_KEY, Double.toString(res.getGeometry().getLocation().getLng())); } return returnMap; } catch (RestClientException e) { LOGGER.error("Failed to find location lng lat. Exception {}", e); throw new RuntimeException("Failed to find latitude/longitude of address", e.getCause()); } }