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