1 package name.gumartinm.weather.information.service;
3 import com.fasterxml.jackson.core.JsonParseException;
5 import java.io.IOException;
6 import java.text.MessageFormat;
7 import java.util.Locale;
9 import name.gumartinm.weather.information.model.forecastweather.Forecast;
10 import name.gumartinm.weather.information.parser.JPOSForecastParser;
12 public class ServiceForecastParser {
13 private final JPOSForecastParser JPOSParser;
15 public ServiceForecastParser(final JPOSForecastParser jposParser) {
16 this.JPOSParser = jposParser;
19 public Forecast retrieveForecastFromJPOS(final String jsonData)
20 throws JsonParseException, IOException {
21 return this.JPOSParser.retrieveForecastFromJPOS(jsonData);
24 public String createURIAPIForecast(final String urlAPI, final String APIVersion,
25 final double latitude, final double longitude, final String resultsNumber) {
27 final MessageFormat formatURIAPI = new MessageFormat(urlAPI, Locale.US);
28 final Object[] values = new Object[4];
29 values[0] = APIVersion;
31 values[2] = longitude;
32 values[3] = resultsNumber;
34 return formatURIAPI.format(values);