c7b727f547d1442a0943b7ed8f0c4cbd8bd36d52
[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.currentweather.Current;
10 import name.gumartinm.weather.information.parser.JPOSCurrentParser;
11
12 public class ServiceCurrentParser {
13     private final JPOSCurrentParser JPOSParser;
14
15     public ServiceCurrentParser(final JPOSCurrentParser jposParser) {
16         this.JPOSParser = jposParser;
17     }
18
19     public Current retrieveCurrentFromJPOS(final String jsonData)
20             throws JsonParseException, IOException {
21         return this.JPOSParser.retrieveCurrenFromJPOS(jsonData);
22     }
23
24     public String createURIAPICurrent(final String urlAPI, final String APIVersion,
25                                       final double latitude, final double longitude) {
26
27         final MessageFormat formatURIAPI = new MessageFormat(urlAPI, Locale.US);
28         final Object[] values = new Object[3];
29         values[0] = APIVersion;
30         values[1] = latitude;
31         values[2] = longitude;
32
33         return formatURIAPI.format(values);
34     }
35 }