private void appendForecastTemperature(SimpleWeatherCondition condition, JSONObject json) throws JSONException { WeatherParser parser = new ForecastWeatherParser(json); AppendableTemperature existedTemp = (AppendableTemperature) condition.getTemperature(); SimpleTemperature newTemp = parser.parseTemperature(); existedTemp.append(newTemp); }
private SimpleTemperature parseTemperature() { AppendableTemperature temperature = new AppendableTemperature(TemperatureUnit.K); JSONObject main; if (!hasTemp()) { // temp is optional return temperature; } try { double currentTemp = getCurrentTemp(); temperature.setCurrent((int) currentTemp, TemperatureUnit.K); } catch (JSONException e) { // temp is optional } try { double minTemp = getMinTemp(); temperature.setLow((int) minTemp, TemperatureUnit.K); } catch (JSONException e) { // min temp is optional } try { double maxTemp = getMaxTemp(); temperature.setHigh((int) maxTemp, TemperatureUnit.K); } catch (JSONException e) { // max temp is optional } return temperature; }