コード例 #1
0
ファイル: GeonamesProcessor.java プロジェクト: nattyco/fermat
 /**
  * This method returns a geonames Id by a country code.
  *
  * @param countryCode
  * @return
  * @throws CannotGetCountryIdException
  * @throws CantConnectWithExternalAPIException
  * @throws CantGetJSonObjectException
  */
 private static int getGeonamesIdByCountryCode(String countryCode)
     throws CannotGetCountryIdException, CantConnectWithExternalAPIException,
         CantGetJSonObjectException {
   int geonamesCountryId;
   // We request the country information to Geonames API
   String queryUrl =
       GeolocationConfiguration.GEONAMES_URL_COUNTRY
           + countryCode
           + "&username="******"The country code " + countryCode + " cannot be found in Geonames API");
 }
コード例 #2
0
ファイル: GeonamesProcessor.java プロジェクト: nattyco/fermat
 /**
  * This method creates a dependencies list by a given country Id and country code.
  *
  * @param countryId
  * @param countryCode
  * @return
  * @throws CantConnectWithExternalAPIException
  * @throws CantGetJSonObjectException
  */
 private static List<CountryDependency> getCountryDependenciesListByCountryId(
     int countryId, String countryCode)
     throws CantConnectWithExternalAPIException, CantGetJSonObjectException {
   // We request the country dependencies to Geonames API
   String queryUrl =
       GeolocationConfiguration.GEONAME_URL_COUNTRY_DEPENDENCIES
           + countryId
           + "&username="
           + GeolocationConfiguration.GEONAMES_USERNAME;
   JsonObject jsonObject = RemoteJSonProcessor.getJSonObject(queryUrl);
   JsonArray jsonArray =
       jsonObject.getAsJsonArray(GeonamesJsonAttNames.COUNTRY_GEONAMES_DEPENDENCIES_ARRAY);
   List<CountryDependency> dependencyList = new ArrayList<>();
   CountryDependency countryDependency;
   for (JsonElement dependencyJson : jsonArray) {
     countryDependency = getCountryDependency(dependencyJson, countryCode, countryId);
     if (countryDependency != null) {
       dependencyList.add(countryDependency);
     }
   }
   return dependencyList;
 }