List of usage examples for java.lang Double doubleValue
@HotSpotIntrinsicCandidate public double doubleValue()
From source file:net.solarnetwork.node.weather.nz.metservice.MetserviceWeatherDatumDataSource.java
@Override public GeneralLocationDatum readCurrentDatum() { GeneralAtmosphericDatum result = null; String url = getBaseUrl() + '/' + localObs; final SimpleDateFormat tsFormat = new SimpleDateFormat(getTimestampDateFormat()); try {//from w w w . j a va2 s .com URLConnection conn = getURLConnection(url, HTTP_METHOD_GET); JsonNode root = getObjectMapper().readTree(getInputStreamFromURLConnection(conn)); JsonNode data = root.get(localObsContainerKey); if (data == null) { log.warn("Local observation container key '{}' not found in {}", localObsContainerKey, url); return null; } Date infoDate = parseDateAttribute("dateTime", data, tsFormat); Float temp = parseFloatAttribute("temp", data); if (infoDate == null || temp == null) { log.debug("Date and/or temperature missing from {}", url); return null; } result = new GeneralAtmosphericDatum(); result.setCreated(infoDate); result.setTemperature(temp); result.setHumidity(parseIntegerAttribute("humidity", data)); Double millibar = parseDoubleAttribute("pressure", data); if (millibar != null) { int pascals = (int) (millibar.doubleValue() * 100); result.setAtmosphericPressure(pascals); } // get local forecast try { url = getBaseUrl() + '/' + localForecast; conn = getURLConnection(url, HTTP_METHOD_GET); root = getObjectMapper().readTree(getInputStreamFromURLConnection(conn)); JsonNode forecastWord = root.findValue("forecastWord"); if (forecastWord != null) { result.setSkyConditions(forecastWord.asText()); } } catch (IOException e) { log.warn("Error reading MetService URL [{}]: {}", url, e.getMessage()); } log.debug("Obtained WeatherDatum: {}", result); } catch (IOException e) { log.warn("Error reading MetService URL [{}]: {}", url, e.getMessage()); } return result; }
From source file:org.hyperic.hq.plugin.apache.JkStatusCollector.java
private void parse(HttpResponse response) throws IOException { _lbs.clear();/* w w w .j ava 2s . c o m*/ _workers.clear(); InputStream is = response.getEntity().getContent(); String line; BufferedReader bf = new BufferedReader(new InputStreamReader(is)); final String prefix = "worker."; String prevKey = null; while (null != (line = bf.readLine())) { int ix = line.indexOf('='); if (ix == -1) { continue; } String worker = line.substring(0, ix); String val = line.substring(ix + 1); if (!worker.startsWith(prefix)) { continue; } worker = worker.substring(prefix.length()); if ((ix = worker.indexOf('.')) == -1) { continue; } String name = worker.substring(0, ix); String key = worker.substring(ix + 1); if (key.equals("type")) { if (val.equals("lb")) { _lbs.add(name); } else if (val.startsWith("ajp")) { if ("balance_workers".equals(prevKey)) { _workers.add(name); } } continue; } prevKey = key; if (_filter.get(key) != Boolean.TRUE) { continue; } if (key.equals("state")) { Double state = (Double) _state.get(val); double avail; if (state == null) { avail = Metric.AVAIL_UP; } else { avail = state.doubleValue(); } setValue(worker, avail); } else { setValue(worker, val); } } }
From source file:jp.co.opentone.bsol.linkbinder.dto.AbstractDto.java
/** * Double?clone????.//w w w . j a va 2 s. c om * BigDecimal?clone????. * @param value ? * @return ???clone. value?null???null. */ protected Double cloneField(Double value) { Double clone = null; if (null != value) { clone = new Double(value.doubleValue()); } return clone; }
From source file:com.nestof.paraweather.utils.LocationConverter.java
/** * Returns a formatted DMS String using value loaded into DecimalDegrees ie. * DD MM' SS" E/*from ww w.j ava 2 s. c o m*/ * * @return String */ public String toDMS(String DecimalDegreesAndMinutes, String type) { this.type = type; String returnstring = null; Double DegreesAndMinutes; Integer decDegrees; Integer decMinutes; Double decSeconds; DegreesAndMinutes = Double.parseDouble(DecimalDegreesAndMinutes); decDegrees = (int) DegreesAndMinutes.doubleValue(); decMinutes = (int) ((DegreesAndMinutes.doubleValue() - decDegrees) * 60); decSeconds = ((((DegreesAndMinutes.doubleValue() - decDegrees) * 60) - decMinutes) * 60); decDegrees = Math.abs(decDegrees); decMinutes = Math.abs(decMinutes); decSeconds = Math.abs(decSeconds); setDegrees(decDegrees.toString()); setMinutes(decMinutes.toString()); setSeconds(decSeconds.toString()); if (getType().equalsIgnoreCase("Latitude")) { if (Double.parseDouble(getDegrees()) < 0) { setDirection("S"); } else { setDirection("N"); } } if (getType().equalsIgnoreCase("Longitude")) { if (Double.parseDouble(getDegrees()) < 0) { setDirection("W"); } else { setDirection("E"); } } returnstring = toFormattedDMSString(); return returnstring; }
From source file:com.joliciel.csvLearner.maxent.MaxentBestFeatureObserver.java
public void writeFileTotalsToFile(Writer writer) { try {/*from ww w .j a v a 2 s. c o m*/ boolean firstOutcome = true; Map<String, Double> totalPerFile = new HashMap<String, Double>(); for (String fileName : fileNames) totalPerFile.put(fileName, 0.0); for (String outcome : filePercentagePerOutcome.keySet()) { if (firstOutcome) { writer.append("outcome,"); for (String fileName : fileNames) writer.append(CSVFormatter.format(fileName) + ","); writer.append("\n"); } writer.append(CSVFormatter.format(outcome) + ","); for (String fileName : fileNames) { Double filePercentageObj = filePercentagePerOutcome.get(outcome).get(fileName); double filePercentage = filePercentageObj == null ? 0 : filePercentageObj.doubleValue(); double currentTotal = totalPerFile.get(fileName); totalPerFile.put(fileName, currentTotal + filePercentage); writer.append(CSVFormatter.format(filePercentage) + ","); } writer.append("\n"); firstOutcome = false; } writer.append(CSVFormatter.format("AVERAGE") + ","); for (String fileName : fileNames) { double total = totalPerFile.get(fileName); writer.append(CSVFormatter.format(total / filePercentagePerOutcome.size()) + ","); } writer.append("\n"); } catch (IOException ioe) { throw new RuntimeException(ioe); } }
From source file:de.hybris.platform.solrfacetsearch.integration.IndexFullProductTest.java
private void checkPriceForAllProducts(final String currency) throws SolrServerException { final List<ProductModel> productModels = searchResult.getResult(); final CurrencyModel currencyModel = commonI18NService.getCurrency(currency); commonI18NService.setCurrentCurrency(currencyModel); for (final ProductModel productModel : productModels) { final String solrDocId = prepareProductSolrId(productModel); final List<PriceInformation> prices = priceService.getPriceInformationsForProduct(productModel); assertNotNull(prices);/* www. j a v a2 s .c o m*/ assertFalse(prices.isEmpty()); final Double value = Double.valueOf(prices.get(0).getPriceValue().getValue()); if (value != null && value.doubleValue() > 0) { final String rangeStr = getPriceRangeForValue(value.doubleValue()); final IndexedProperty priceProperty = indexedType.getIndexedProperties().get("price"); final String priceField = fieldNameProvider.getFieldName(priceProperty, currency, FieldType.INDEX); final String solrQuery = priceField + ":\"" + rangeStr + "\" AND id:\"" + solrDocId + "\""; final QueryResponse solrResponse = solrServer.query(new SolrQuery(solrQuery)); final SolrDocumentList solrDocumentList = solrResponse.getResults(); assertNotNull(solrDocumentList); assertEquals("Price range " + rangeStr + " was not find for currency " + currency + ", solrDocId: " + solrDocId, 1, solrDocumentList.getNumFound()); } } }
From source file:at.uni_salzburg.cs.ckgroup.cscpp.mapper.algorithm.VehicleStatus.java
public VehicleStatus(JSONObject obj) { name = (String) obj.get("name"); id = (String) obj.get("vehicle.id"); state = Status.valueOf(((String) obj.get("state")).toUpperCase()); if (state == Status.ACTIVE || state == Status.SUSPENDED) { Double latitude = (Double) obj.get("latitude"); Double longitude = (Double) obj.get("longitude"); Double altitude = (Double) obj.get("altitude"); if (latitude != null && longitude != null && altitude != null) { position = new PolarCoordinate(latitude.doubleValue(), longitude.doubleValue(), altitude.doubleValue()); } else {//from w ww . jav a 2 s . c o m position = null; } Double t = (Double) obj.get("tolerance"); tolerance = t != null ? t.doubleValue() : 5.0; JSONArray as = (JSONArray) obj.get("actions"); actions = new HashSet<String>(); if (as != null) { for (int k = 0; k < as.size(); ++k) { actions.add((String) as.get(k)); } } } }
From source file:chibi.gemmaanalysis.AffyPlatFormAnalysisCli.java
String processEE(ExpressionExperiment ee) { // eeService.thaw( ee ); QuantitationType qt = this.getQuantitationType(ee, null, true); if (qt == null) return ("No usable quantitation type in " + ee.getShortName()); log.info("Load Data for " + ee.getShortName()); Collection<ProcessedExpressionDataVector> dataVectors = eeService.getProcessedDataVectors(ee); if (dataVectors == null) return ("No data vector " + ee.getShortName()); if (this.probeToGeneAssociation == null) { this.probeToGeneAssociation = this.getDevToGeneAssociation(dataVectors); }//from w w w.j a v a2s . c o m for (ProcessedExpressionDataVector vector : dataVectors) { CompositeSequence de = vector.getDesignElement(); DoubleArrayList rankList = this.rankData.get(de); if (rankList == null) { return (" EE data vectors don't match array design for probe " + de.getName()); } Double rank = vector.getRankByMean(); if (rank != null) { rankList.add(rank.doubleValue()); } } return null; }
From source file:io.mapzone.arena.geocode.here.HereGeocodeService.java
protected Address transform(final JSONObject jsonResult) { final Address address = new Address(); final JSONObject jsonLocation = jsonResult.optJSONObject("location"); if (jsonLocation != null) { address.id = jsonLocation.optString("locationId"); // geometry final JSONObject jsonGeometry = jsonLocation.optJSONObject("displayPosition"); if (jsonGeometry != null) { final Double latitude = jsonGeometry.optDouble("latitude"); final Double longitude = jsonGeometry.optDouble("longitude"); if (latitude != null && longitude != null) { final Point point = GEOMETRYFACTORY .createPoint(new Coordinate(longitude.doubleValue(), latitude.doubleValue())); address.position = point; }/*from ww w .j a v a2 s. c o m*/ } // details final JSONObject jsonAddress = jsonLocation.optJSONObject("address"); if (jsonAddress != null) { address.label = jsonAddress.optString("label"); address.country = jsonAddress.optString("country"); address.state = jsonAddress.optString("state"); address.county = jsonAddress.optString("county"); address.city = jsonAddress.optString("city"); address.postalCode = jsonAddress.optString("postalCode"); address.district = jsonAddress.optString("district"); address.street = jsonAddress.optString("street"); address.houseNumber = jsonAddress.optString("houseNumber"); } } return address; }
From source file:com.netthreads.traffic.view.TrafficDataMapFragment.java
/** * Setup view.//from w ww .j av a 2 s.c om * * @param mapView */ private void setupView(final View mapView) { Bundle bundle = getArguments(); String region = bundle.getString(ARG_REGION); final String lat = bundle.getString(ARG_LAT); final String lng = bundle.getString(ARG_LNG); // Load region and generate view bounds. final LatLngBounds bounds = calculateBounds(region); if (mapView.getViewTreeObserver().isAlive()) { mapView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @SuppressLint("NewApi") // We check which build version we are using. @Override public void onGlobalLayout() { // Add listener. if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { mapView.getViewTreeObserver().removeGlobalOnLayoutListener(this); } else { mapView.getViewTreeObserver().removeOnGlobalLayoutListener(this); } // Centre if directed to. if (lat != null && lng != null) { Double latitude = Double.parseDouble(lat); Double longitude = Double.parseDouble(lng); LatLng location = new LatLng(latitude.doubleValue(), longitude.doubleValue()); map.moveCamera(CameraUpdateFactory.zoomTo(SINGLE_MARKER_ZOOM)); map.moveCamera(CameraUpdateFactory.newLatLng(location)); } else { map.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, MAP_VIEW_BORDER)); } } }); } }