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); }
void parseCurrentWeather(JSONObject json) throws WeatherException { try { int code = json.getInt("cod"); if (code != 200) { this.empty = true; return; } parseCityId(json); parseLocation(json); parseTime(json); WeatherParser parser = new CurrentWeatherParser(json); parser.parseCondition(); } catch (JSONException e) { throw new WeatherException("cannot parse the weather", e); } this.empty = false; }
private void parseForecast(SimpleWeatherCondition condition, JSONObject json) throws JSONException { appendForecastTemperature(condition, json); WeatherParser parser = new ForecastWeatherParser(json); condition.setHumidity(parser.parseHumidity()); condition.setWind(parser.parseWind()); condition.setPrecipitation(parser.parsePrecipitation()); condition.setCloudiness(parser.parseCloudiness()); parser.parseWeatherType(condition); }