List of usage examples for java.lang Double toString
public String toString()
From source file:by.zatta.pilight.model.Config.java
public static void parse(JSONObject jloc) { Iterator<?> lit = jloc.keys(); /* Iterate through all locations */ while (lit.hasNext()) { String locationID = (String) lit.next(); String locationName = ""; try {//from w ww . j a va 2 s . co m JSONObject jdev = jloc.getJSONObject(locationID); if (jdev.has("name")) locationName = jdev.getString("name"); // Log.v(TAG, locationID + " = " +locationName); Iterator<?> dit = jdev.keys(); /* Iterate through all devices of this location */ while (dit.hasNext()) { String dkey = (String) dit.next(); // Log.v("dkey", dkey); if (!dkey.equals("name")) { try { /* Create new device object for this location */ DeviceEntry device = new DeviceEntry(); device.setNameID(dkey); device.setLocationID(locationID); List<SettingEntry> settings = new ArrayList<SettingEntry>(); SettingEntry sentry = new SettingEntry(); sentry.setKey("locationName"); sentry.setValue(locationName); settings.add(sentry); JSONObject jset = jdev.getJSONObject(dkey); Iterator<?> sit = jset.keys(); /* Iterate through all settings of this device */ while (sit.hasNext()) { String skey = (String) sit.next(); if (skey.equals("type")) { device.setType(Integer.valueOf(jset.getString(skey))); } /* OBSOLETE LOOP SINCE PILIGHT 4.0 */ // } else if (skey.equals("settings")) { // // iterate over all specific settings // JSONObject jthi = jset.getJSONObject(skey); // Iterator<?> thit = jthi.keys(); // while (thit.hasNext()) { // String thkey = (String) thit.next(); // sentry = new SettingEntry(); // sentry.setKey("sett_" + thkey); // // JSONArray jvalarr = jthi.optJSONArray(thkey); // String jvalstr = jthi.optString(thkey); // Double jvaldbl = jthi.optDouble(thkey); // Long jvallng = jthi.optLong(thkey); // // if (jvalarr != null) { // for (Short i = 0; i < jvalarr.length(); i++) { // sentry.setKey(thkey); // sentry.setValue(jvalarr.get(i).toString()); // } // } else if (jvalstr != null) { // sentry.setValue(jvalstr.toString()); // } else if (jvaldbl != null) { // Log.e(TAG, skey + "double : " + jvaldbl.toString()); // sentry.setValue(jvaldbl.toString()); // } else if (jvallng != null) { // Log.e(TAG, skey + "long : " + jvallng.toString()); // sentry.setValue(jvallng.toString()); // } // if (sentry != null) settings.add(sentry); // } // } else if (skey.equals("id") || skey.equals("protocol") || skey.equals("order")) { } else { try { sentry = new SettingEntry(); sentry.setKey(skey); JSONArray jvalarr = jset.optJSONArray(skey); String jvalstr = jset.optString(skey); Double jvaldbl = jset.optDouble(skey); Long jvallng = jset.optLong(skey); if (jvalarr != null) { for (Short i = 0; i < jvalarr.length(); i++) { sentry.setKey(skey); sentry.setValue(jvalarr.get(i).toString()); } } else if (jvalstr != null) { sentry.setValue(jvalstr.toString()); } else if (jvaldbl != null) { Log.e(TAG, skey + "double : " + jvaldbl.toString()); sentry.setValue(jvaldbl.toString()); } else if (jvallng != null) { Log.e(TAG, skey + "long : " + jvallng.toString()); sentry.setValue(jvallng.toString()); } if (sentry != null) settings.add(sentry); } catch (JSONException e) { Log.w(TAG, "The received SETTING is of an incorrent format"); } } } device.setSettings(settings); mDevices.add(device); } catch (JSONException e) { Log.w(TAG, "The received DEVICE is of an incorrent format"); } } } } catch (JSONException e) { Log.w(TAG, "The received LOCATION is of an incorrent format"); } } try { print(); } catch (Exception e) { Log.w(TAG, "4) couldnt print"); } }
From source file:mitm.application.djigzo.james.matchers.ToFloatFunction.java
@Override public FunctionResult execute(Evaluator evaluator, String arguments) throws FunctionException { ArrayList<?> values = getOneStringAndOneDouble(arguments, EvaluationConstants.FUNCTION_ARGUMENT_SEPARATOR); if (values.size() != 2) { throw new FunctionException("A String and a number is required."); }/*w w w . j ava 2s . c o m*/ String stringValue = FunctionHelper.trimAndRemoveQuoteChars((String) values.get(0), evaluator.getQuoteCharacter()); Double value = NumberUtils.toDouble(stringValue, (Double) values.get(1)); return new FunctionResult(value.toString(), FunctionConstants.FUNCTION_RESULT_TYPE_NUMERIC); }
From source file:eu.optimis.ecoefficiencytool.core.ProactiveInfrastructure.java
public void setIpEnEffTH(Double value) { log.info("Set energy efficiency TH of IP to " + value.toString() + " MWIPS/W."); ipEnEffTH = value;/* www.j av a 2 s.c om*/ }
From source file:eu.optimis.ecoefficiencytool.core.ProactiveInfrastructure.java
public void setIpEcoEffTH(Double value) { log.info("Set ecological efficiency TH of IP to " + value.toString() + " MWIPS/grCO2."); ipEcoEffTH = value;/* w w w .j a v a2 s. com*/ }
From source file:eu.optimis.ecoefficiencytool.core.ProactiveInfrastructure.java
public void setNodeEnEffTH(String nodeId, Double value) { log.info("Set energy efficiency TH of node " + nodeId + " to " + value.toString() + " MWIPS/W."); nodeEnEffTH.put(nodeId, value);// ww w .j av a2 s . co m }
From source file:eu.optimis.ecoefficiencytool.core.ProactiveInfrastructure.java
public void setNodeEcoEffTH(String nodeId, Double value) { log.info("Set ecological efficiency TH of node " + nodeId + " to " + value.toString() + " MWIPS/grCO2."); nodeEcoEffTH.put(nodeId, value);//from w w w . j ava2s . c om }
From source file:com.couchbase.sqoop.mapreduce.db.CouchbaseRecordReadSerializeTest.java
@Before @Override/*from www . ja va 2 s. c om*/ public void setUp() throws Exception { super.setUp(); tappedStuff = new HashMap<String, ResponseMessage>(); URI uri = new URI(CouchbaseUtils.CONNECT_STRING); String user = CouchbaseUtils.COUCHBASE_USER_NAME; String pass = CouchbaseUtils.COUCHBASE_USER_PASS; try { cb = new CouchbaseClient(Arrays.asList(uri), user, pass); } catch (IOException e) { LOG.error("Couldn't connect to server" + e.getMessage()); fail(e.toString()); } this.client = new TapClient(Arrays.asList(uri), user, pass); cb.flush(); Thread.sleep(500); // set up the items we're going to deserialize Integer anint = new Integer(Integer.MIN_VALUE); cb.set(anint.toString(), 0x300, anint).get(); Long along = new Long(Long.MAX_VALUE); cb.set(along.toString(), 0, along).get(); Float afloat = new Float(Float.MAX_VALUE); cb.set(afloat.toString(), 0, afloat).get(); Double doubleBase = new Double(Double.NEGATIVE_INFINITY); cb.set(doubleBase.toString(), 0, doubleBase).get(); Boolean booleanBase = true; cb.set(booleanBase.toString(), 0, booleanBase).get(); rightnow = new Date(); // instance, needed later dateText = rightnow.toString().replaceAll(" ", "_"); cb.set(dateText, 0, rightnow).get(); Byte byteMeSix = new Byte("6"); cb.set(byteMeSix.toString(), 0, byteMeSix).get(); String ourString = "hi,there"; cb.set(ourString.toString(), 0, ourString).get(); client.tapDump("tester"); while (client.hasMoreMessages()) { ResponseMessage m = client.getNextMessage(); if (m == null) { continue; } tappedStuff.put(m.getKey(), m); } }
From source file:geogebra.kernel.AlgoBinomial.java
private double BinomBig(double n, double r) { if (r > n / 2) r = n - r;//from w ww. j a v a 2 s .c om BigInteger ncr = BigInteger.ONE, dd = BigInteger.ONE, nn, rr; // nn=BigInteger.valueOf((long)n); // rr=BigInteger.valueOf((long)r); // need a long-winded conversion in case n>10^18 Double nnn = new Double(n); Double rrr = new Double(r); nn = (new BigDecimal(nnn.toString())).toBigInteger(); rr = (new BigDecimal(rrr.toString())).toBigInteger(); while (dd.compareTo(rr) <= 0) { ncr = ncr.multiply(nn); ncr = ncr.divide(dd); // dd is guaranteed to divide exactly into ncr here nn = nn.subtract(BigInteger.ONE); dd = dd.add(BigInteger.ONE); } return ncr.doubleValue(); }
From source file:net.ponder2.managedobject.Reasoner.java
@Ponder2op("qoe_event:") public void qoeEventEntrypoint(P2Object c2bEvent) { try {/*from w ww . ja va 2s. co m*/ P2Object[] props = c2bEvent.asArray(); Bubble bubble = C2BUtils.getBubble(props[0].asString()); Double qoe = fuzzyEngine.evaluateQoe(C2BUtils.getCloudlet(props[1].asString()), bubble); C2BUtils.updateBubble(bubble.getId(), Environment.QOE.toString(), qoe.toString()); } catch (Ponder2ArgumentException e) { log.error(e); } catch (Ponder2OperationException e) { log.error(e); } catch (Ponder2Exception e) { log.error(e); } }
From source file:ch.zhaw.icclab.tnova.expressionsolver.OTFlyEval.java
String findAvg(LinkedList<Double> paramList) { Double sum = new Double("0.0"); for (int i = 0; i < paramList.size(); i++) { sum += paramList.get(i);/*from ww w. j av a 2 s . c o m*/ } Double avg = sum / (new Double(paramList.size())); return avg.toString(); }