2 * Copyright 2014 Gustavo Martin Morcuende
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package name.gumartinm.weather.information.service;
18 import com.fasterxml.jackson.core.JsonParseException;
20 import java.io.IOException;
21 import java.text.MessageFormat;
22 import java.util.Locale;
24 import name.gumartinm.weather.information.model.forecastweather.Forecast;
25 import name.gumartinm.weather.information.parser.JPOSForecastParser;
27 public class ServiceForecastParser {
28 private final JPOSForecastParser JPOSParser;
30 public ServiceForecastParser(final JPOSForecastParser jposParser) {
31 this.JPOSParser = jposParser;
34 public Forecast retrieveForecastFromJPOS(final String jsonData)
35 throws JsonParseException, IOException {
36 return this.JPOSParser.retrieveForecastFromJPOS(jsonData);
39 public String createURIAPIForecast(final String urlAPI, final String APIVersion,
40 final double latitude, final double longitude, final String resultsNumber) {
42 final MessageFormat formatURIAPI = new MessageFormat(urlAPI, Locale.US);
43 final Object[] values = new Object[4];
44 values[0] = APIVersion;
46 values[2] = longitude;
47 values[3] = resultsNumber;
49 return formatURIAPI.format(values);