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.currentweather.Current;
25 import name.gumartinm.weather.information.parser.JPOSCurrentParser;
27 public class ServiceCurrentParser {
28 private final JPOSCurrentParser JPOSParser;
30 public ServiceCurrentParser(final JPOSCurrentParser jposParser) {
31 this.JPOSParser = jposParser;
34 public Current retrieveCurrentFromJPOS(final String jsonData)
35 throws JsonParseException, IOException {
36 return this.JPOSParser.retrieveCurrenFromJPOS(jsonData);
39 public String createURIAPICurrent(final String urlAPI, final String APIVersion,
40 final double latitude, final double longitude) {
42 final MessageFormat formatURIAPI = new MessageFormat(urlAPI, Locale.US);
43 final Object[] values = new Object[3];
44 values[0] = APIVersion;
46 values[2] = longitude;
48 return formatURIAPI.format(values);