@Override public Object unmarshal (HierarchicalStreamReader reader, UnmarshallingContext context) { String id = reader.getAttribute("id"); String temp = reader.getAttribute("temp"); String wind = reader.getAttribute("windspeed"); String dir = reader.getAttribute("winddir"); String cloudCvr = reader.getAttribute("cloudcover"); return new WeatherForecastPrediction(Integer.parseInt(id), Double.parseDouble(temp), Double.parseDouble(wind), Double.parseDouble(dir), Double.parseDouble(cloudCvr)); } }
new WeatherForecastPrediction( Integer.parseInt(temp[3]), Double.parseDouble(temp[4]), Double.parseDouble(temp[5]),
private void broadcastWeatherForecasts () { WeatherForecast forecast = null; try { forecast = weatherForecastRepo.currentWeatherForecast(); } catch (PowerTacException e) { log.error("Weather Service reports Weather Forecast Repo emtpy"); } if (forecast == null) { log.error("null weather-forecast for : " + timeslotRepo.currentSerialNumber() +" " + timeslotRepo.currentTimeslot()); // In the event of an error return a default List<WeatherForecastPrediction> currentPredictions = new ArrayList<WeatherForecastPrediction>(); for (int j = 1; j <= getForecastHorizon(); j++) { currentPredictions.add( new WeatherForecastPrediction(j, 0.0, 0.0, 0.0, 0.0)); } brokerProxyService.broadcastMessage(new WeatherForecast( timeslotRepo.currentSerialNumber(), currentPredictions)); } else { brokerProxyService.broadcastMessage(forecast); } }