List of usage examples for java.lang Double Double
@Deprecated(since = "9") public Double(String s) throws NumberFormatException
From source file:de.loercher.localpress.integration.GeoAndRatingITest.java
@Test public void testAddArticle() { String nowString = "2015-10-12T08:00+02:00[Europe/Berlin]"; ZonedDateTime now = new DateTimeConverter().fromString(nowString); AddArticleEntityDTO geoDTO = new AddArticleEntityDTO(nowString); Instant instant = now.toInstant(); Instant fir = Instant.now(); MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); headers.add("UserID", "ulf"); HttpEntity<AddArticleEntityDTO> request = new HttpEntity<>(geoDTO, headers); RestTemplate template = new RestTemplate(); ResponseEntity<Map> result = template.postForEntity("http://52.29.77.191:8080/localpress/feedback", request, Map.class); Instant afterRating = Instant.now(); GeoBaseEntity.EntityBuilder builder = new GeoBaseEntity.EntityBuilder(); GeoBaseEntity entity = builder.author("ulf") .coordinates(Arrays.asList(new Coordinate[] { new Coordinate(50.1, 8.4) })) .timestamp(now.toEpochSecond()).content("abc.de").title("mein titel").user("ulf").build(); HttpEntity<GeoBaseEntity> second = new HttpEntity<>(entity, headers); System.out.println(result.getBody().get("articleID")); template.put("http://euve33985.vserver.de:8080/geo/" + result.getBody().get("articleID"), second); Instant afterGeoPut = Instant.now(); result = template.getForEntity("http://euve33985.vserver.de:8080/geo/" + result.getBody().get("articleID"), Map.class); Instant afterGeoGet = Instant.now(); assertEquals("User ID has changed over time!", "ulf", result.getBody().get("user")); assertEquals("Content URL has changed over time!", "abc.de", result.getBody().get("content")); DateTimeConverter conv = new DateTimeConverter(); Duration first = Duration.between(fir, afterRating); Duration sec = Duration.between(afterRating, afterGeoPut); Duration third = Duration.between(afterGeoPut, afterGeoGet); System.out.println("Begin: " + conv.toString(now)); System.out.println("Time until POST to rating: " + new Double(first.toMillis()) / 1000); System.out.println("Time until PUT to geo: " + new Double(sec.toMillis()) / 1000); System.out.println("Time until GET to geo: " + new Double(third.toMillis()) / 1000); }
From source file:org.jfree.data.general.DefaultKeyedValueDatasetTest.java
/** * Confirm that the clone is independent of the original. *///from w w w. j a va 2s . com @Test public void testCloneIndependence() throws CloneNotSupportedException { DefaultKeyedValueDataset d1 = new DefaultKeyedValueDataset("Key", new Double(10.0)); DefaultKeyedValueDataset d2 = (DefaultKeyedValueDataset) d1.clone(); assertTrue(d1.equals(d2)); d2.updateValue(new Double(99.9)); assertFalse(d1.equals(d2)); d2.updateValue(new Double(10.0)); assertTrue(d1.equals(d2)); }
From source file:WriteDoubleUsingSockets.java
public void init() { Date d = new Date(); // Get the portnumber and servername and allow to be called from a // java main program also try {// w w w . ja v a2 s . c o m String param; param = getParameter("PortNumber"); if (param != null) PortNumber = Integer.parseInt(param); param = getParameter("ServerName"); if (param != null) ServerName = param; } catch (NullPointerException e) { // Must be called from a main ignore } try { Socket skt = new Socket(ServerName, PortNumber); os = new DataOutputStream(skt.getOutputStream()); } catch (Exception e) { Label l = new Label(e.toString()); add(l); System.out.println(e); return; } try { s = new ObjectOutputStream(os); } catch (Exception e) { System.out.println(e); System.out.println("Unable to open stream as an object stream"); } try { long startTime = System.currentTimeMillis(); for (int i = 0; i < 25; i++) { s.writeObject(new Double(i)); } os.close(); long endTime = System.currentTimeMillis() - startTime; Label l = new Label( "Writing 25 doubles server took: " + new Long(endTime).toString() + " milliseconds."); add(l); System.out.println("Object written"); } catch (Exception e) { System.out.println(e); System.out.println("Unable to write Objects"); } }
From source file:de.tudarmstadt.ukp.dkpro.tc.weka.report.WekaOutcomeIDReport.java
protected static Properties generateProperties(Instances predictions, boolean isMultilabel, boolean isRegression) { Properties props = new Properties(); String[] classValues = new String[predictions.numClasses()]; for (int i = 0; i < predictions.numClasses(); i++) { classValues[i] = predictions.classAttribute().value(i); }//from ww w .j a va 2 s . c o m int attOffset = predictions.attribute(Constants.ID_FEATURE_NAME).index(); for (Instance inst : predictions) { if (isMultilabel) { List<String> predictionOutcomes = new ArrayList<String>(); List<String> goldOutcomes = new ArrayList<String>(); for (int i = 0; i < predictions.classIndex(); i++) { if (inst.value(predictions.attribute(i)) == 1.) { goldOutcomes.add(predictions.attribute(i).name()); } if (inst.value(predictions.attribute(i + predictions.classIndex())) == 1.) { predictionOutcomes.add(predictions.attribute(i).name()); } } String s = (StringUtils.join(predictionOutcomes, ",") + SEPARATOR_CHAR + StringUtils.join(goldOutcomes, ",")); props.setProperty(inst.stringValue(attOffset), s); } else { Double gold; try { gold = new Double(inst.value(predictions .attribute(Constants.CLASS_ATTRIBUTE_NAME + WekaUtils.COMPATIBLE_OUTCOME_CLASS))); } catch (NullPointerException e) { // if train and test data have not been balanced gold = new Double(inst.value(predictions.attribute(Constants.CLASS_ATTRIBUTE_NAME))); } Attribute gsAtt = predictions.attribute(WekaTestTask.PREDICTION_CLASS_LABEL_NAME); Double prediction = new Double(inst.value(gsAtt)); if (!isRegression) { props.setProperty(inst.stringValue(attOffset), gsAtt.value(prediction.intValue()) + SEPARATOR_CHAR + classValues[gold.intValue()]); } else { // the outcome is numeric props.setProperty(inst.stringValue(attOffset), prediction + SEPARATOR_CHAR + gold); } } } return props; }
From source file:com.agiletec.plugins.jpgeoref.aps.system.services.content.parse.extraAttribute.CoordsAttributeHandler.java
/** * Sets coordinate property/* w w w .j a va 2 s. com*/ * @param textBuffer property value * @param property property name */ private void endCoords(StringBuffer textBuffer, String property) { if (null != textBuffer && null != this.getCurrentAttr()) { String coordsString = textBuffer.toString(); double coord = Double.parseDouble(coordsString); CoordsAttribute attribute = (CoordsAttribute) this.getCurrentAttr(); try { BeanUtils.setProperty(attribute, property, new Double(coord)); } catch (Throwable t) { throw new RuntimeException("Error setting '" + property + "' property", t); } } }
From source file:org.jfree.data.category.DefaultIntervalCategoryDatasetTest.java
/** * Some checks for the getValue() method. *//* w w w. j ava2s . c o m*/ @Test public void testGetValue() { double[] starts_S1 = new double[] { 0.1, 0.2, 0.3 }; double[] starts_S2 = new double[] { 0.3, 0.4, 0.5 }; double[] ends_S1 = new double[] { 0.5, 0.6, 0.7 }; double[] ends_S2 = new double[] { 0.7, 0.8, 0.9 }; double[][] starts = new double[][] { starts_S1, starts_S2 }; double[][] ends = new double[][] { ends_S1, ends_S2 }; DefaultIntervalCategoryDataset d = new DefaultIntervalCategoryDataset( new Comparable[] { "Series 1", "Series 2" }, new Comparable[] { "Category 1", "Category 2", "Category 3" }, DataUtilities.createNumberArray2D(starts), DataUtilities.createNumberArray2D(ends)); assertEquals(new Double(0.1), d.getStartValue("Series 1", "Category 1")); assertEquals(new Double(0.2), d.getStartValue("Series 1", "Category 2")); assertEquals(new Double(0.3), d.getStartValue("Series 1", "Category 3")); assertEquals(new Double(0.3), d.getStartValue("Series 2", "Category 1")); assertEquals(new Double(0.4), d.getStartValue("Series 2", "Category 2")); assertEquals(new Double(0.5), d.getStartValue("Series 2", "Category 3")); assertEquals(new Double(0.5), d.getEndValue("Series 1", "Category 1")); assertEquals(new Double(0.6), d.getEndValue("Series 1", "Category 2")); assertEquals(new Double(0.7), d.getEndValue("Series 1", "Category 3")); assertEquals(new Double(0.7), d.getEndValue("Series 2", "Category 1")); assertEquals(new Double(0.8), d.getEndValue("Series 2", "Category 2")); assertEquals(new Double(0.9), d.getEndValue("Series 2", "Category 3")); boolean pass = false; try { d.getValue("XX", "Category 1"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); pass = false; try { d.getValue("Series 1", "XX"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); }
From source file:AlgorithmAnimation.java
/** * Constructs a Sorter.// w w w .j a v a2 s . co m * @param values the array to be sorted * @param comp the component on which to display the sorting progress */ public Sorter(ArrayComponent comp) { values = new Double[VALUES_LENGTH]; for (int i = 0; i < values.length; i++) values[i] = new Double(Math.random()); this.component = comp; this.gate = new Semaphore(1); this.run = false; }
From source file:th.co.geniustree.dental.controller.ListSelectHealController.java
@RequestMapping(value = "/countsearchlistselectheal", method = RequestMethod.POST) private long countSearchListSelectHeal(@RequestBody SearchData searchData) { long count = 0; String searchBy = searchData.getSearchBy(); String keyword = searchData.getKeyword(); if ("Name".equals(searchBy)) { count = listSelectHealRepo.count(ListSelectHealSpec.nameLike("%" + keyword + "%")); }/*from w w w .j a v a2s .c o m*/ if ("Price".equals(searchBy)) { count = listSelectHealRepo.count(ListSelectHealSpec.priceLike(new Double(keyword))); } return count; }
From source file:io.isoft.blood.service.RdServiceImpl.java
@Override public MyFilterResult findByFilter(MyFilter filter) { try {//from www . jav a 2 s. c o m FilterBuilder filterBuilder = new FilterBuilder(); String hql = " from BloodRdsMaster e "; if (filter.arguments.size() > 0) hql += " WHERE " + filterBuilder.buildHql(filter, "e"); //???count?; Query countQuery = entityManager.createQuery("select count(*) " + hql); if (filter.sorts.size() == 0) hql += " ORDER BY e.autoId"; else { //?; hql += " ORDER BY "; int sortIndex = 0; for (MyFilterSort myFilterSort : filter.sorts) { hql += String.format(" e.%s %s %s", myFilterSort.sortColumn, myFilterSort.isAscending ? "" : "DESC", (++sortIndex == filter.sorts.size()) ? "" : ","); } } //?? Query query = entityManager.createQuery(hql); //?queryquery? for (ObjectParameter parameter : filterBuilder.parameters) { if (parameter.fieldName.equals("amount")) { //blazeDs value?int?, ? big decimal parameter.value = new BigDecimal((Integer) parameter.value); // parameter.value = (String)parameter.value; } if (parameter.fieldName.equals("tradePrice")) { parameter.value = new Double(parameter.value.toString()); } query.setParameter(parameter.name, parameter.value); countQuery.setParameter(parameter.name, parameter.value); } Object o = countQuery.getSingleResult(); int recordCount = Integer.parseInt(o.toString()); int pageStart = (filter.pageIndex) * filter.pageSize; List<BloodRdsMaster> results = query.setFirstResult(pageStart).setMaxResults(filter.pageSize) .getResultList(); return new MyFilterResult((ArrayList<BloodRdsMaster>) results, recordCount); } catch (RuntimeException re) { throw re; } }
From source file:org.jfree.data.RangeTest.java
/** * Confirm that the equals method can distinguish all the required fields. *///from w w w . j a v a2s . c o m @Test public void testEquals() { Range r1 = new Range(0.0, 1.0); Range r2 = new Range(0.0, 1.0); assertEquals(r1, r2); assertEquals(r2, r1); r1 = new Range(0.0, 1.0); r2 = new Range(0.5, 1.0); assertFalse(r1.equals(r2)); r1 = new Range(0.0, 1.0); r2 = new Range(0.0, 2.0); assertFalse(r1.equals(r2)); // a Range object cannot be equal to a different object type assertFalse(r1.equals(new Double(0.0))); }