1 package name.gumartinm.weather.information.service;
3 import com.fasterxml.jackson.core.JsonParseException;
4 import name.gumartinm.weather.information.model.currentweather.Current;
5 import name.gumartinm.weather.information.model.forecastweather.Forecast;
6 import name.gumartinm.weather.information.parser.IJPOSParser;
8 import java.io.IOException;
9 import java.text.MessageFormat;
10 import java.util.Locale;
13 public class ServiceParser {
14 private final IJPOSParser JPOSParser;
16 public ServiceParser(final IJPOSParser JPOSWeatherParser) {
17 this.JPOSParser = JPOSWeatherParser;
20 public Current retrieveCurrentFromJPOS(final String jsonData)
21 throws JsonParseException, IOException {
22 return this.JPOSParser.retrieveCurrenFromJPOS(jsonData);
25 public Forecast retrieveForecastFromJPOS(final String jsonData)
26 throws JsonParseException, IOException {
27 return this.JPOSParser.retrieveForecastFromJPOS(jsonData);
30 public String createURIAPIForecast(final String urlAPI, final String APIVersion,
31 final double latitude, final double longitude, final String resultsNumber) {
33 final MessageFormat formatURIAPI = new MessageFormat(urlAPI, Locale.US);
34 final Object[] values = new Object[4];
35 values[0] = APIVersion;
37 values[2] = longitude;
38 values[3] = resultsNumber;
40 return formatURIAPI.format(values);
43 public String createURIAPICurrent(final String urlAPI, final String APIVersion,
44 final double latitude, final double longitude) {
46 final MessageFormat formatURIAPI = new MessageFormat(urlAPI, Locale.US);
47 final Object[] values = new Object[3];
48 values[0] = APIVersion;
50 values[2] = longitude;
52 return formatURIAPI.format(values);
55 public String createURIAPIicon(final String icon, final String urlAPI) {
57 final MessageFormat formatURIAPI = new MessageFormat(urlAPI, Locale.US);
58 final Object[] values = new Object[1];
61 return formatURIAPI.format(values);