@Override public NominatimResult mapRow(ResultSet rs, int rownum) throws SQLException { Geometry geometry = DBUtils.extractGeometry(rs, "linegeo"); PhotonDoc doc = new PhotonDoc( rs.getLong("place_id"), "W", rs.getLong("osm_id"), "place", "house_number", Collections.<String, String>emptyMap(), // no name (String) null, Collections.<String, String>emptyMap(), // no extratags (Envelope) null, rs.getLong("parent_place_id"), 0d, // importance CountryCode.getByCode(rs.getString("country_code")), (Point) null, // centroid 0, 30 ); doc.setPostcode(rs.getString("postcode")); doc.setCountry(getCountryNames(rs.getString("country_code"))); NominatimResult result = new NominatimResult(doc); result.addHouseNumbersFromInterpolation(rs.getLong("startnumber"), rs.getLong("endnumber"), rs.getString("interpolationtype"), geometry); return result; } };
rs.getLong("parent_place_id"), importance, CountryCode.getByCode(rs.getString("country_code")), (Point) DBUtils.extractGeometry(rs, "centroid"), rs.getLong("linked_place_id"),
/** * Get a {@code CountryCode} that corresponds to the given ISO 3166-1 * <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">alpha-2</a> or * <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-3">alpha-3</a> code. * * <p> * This method calls {@link #getByCode(String, boolean) getByCode}{@code (code, true)}. * Note that the behavior has changed since the version 1.13. In the older versions, * this method was an alias of {@code getByCode(code, false)}. * </p> * * @param code * An ISO 3166-1 <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2" * >alpha-2</a> or <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-3" * >alpha-3</a> code. * When {@code "UNDEFINED"} is given, {@link #UNDEFINED CountryCode.UNDEFINED} * is returned. * In addition, for backward compatibility, some 4-letter <a href= * "https://en.wikipedia.org/wiki/ISO_3166-3">ISO 3166-3</a> codes such * as {@code "ANHH"} are accepted. * * @return * A {@code CountryCode} instance, or {@code null} if not found. * * @see #getByCode(String, boolean) */ public static CountryCode getByCode(String code) { return getByCode(code, true); }
/** * Get a {@code CountryCode} that corresponds to the given ISO 3166-1 * <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">alpha-2</a> or * <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-3">alpha-3</a> code. * * <p> * This method calls {@link #getByCode(String, boolean) getByCode}{@code (code, true)}. * Note that the behavior has changed since the version 1.13. In the older versions, * this method was an alias of {@code getByCode(code, false)}. * </p> * * @param code * An ISO 3166-1 <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2" * >alpha-2</a> or <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-3" * >alpha-3</a> code. * When {@code "UNDEFINED"} is given, {@link #UNDEFINED CountryCode.UNDEFINED} * is returned. * In addition, for backward compatibility, some 4-letter <a href= * "https://en.wikipedia.org/wiki/ISO_3166-3">ISO 3166-3</a> codes such * as {@code "ANHH"} are accepted. * * @return * A {@code CountryCode} instance, or {@code null} if not found. * * @see #getByCode(String, boolean) */ public static CountryCode getByCode(String code) { return getByCode(code, true); }
/** * Get a {@code CountryCode} that corresponds to the given ISO 3166-1 * <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">alpha-2</a> or * <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-3">alpha-3</a> code. * * <p> * This method calls {@link #getByCode(String, boolean) getByCode}{@code (code, false)}. * </p> * * @param code * An ISO 3166-1 <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2" * >alpha-2</a> or <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-3" * >alpha-3</a> code. Or {@code "UNDEFINED"} (case insensitive). * In addition, for backward compatibility, some 4-letter <a href= * "https://en.wikipedia.org/wiki/ISO_3166-3">ISO 3166-3</a> codes such * as {@code "ANHH"} are accepted. * * @return * A {@code CountryCode} instance, or {@code null} if not found. * * @since 1.13 * * @see #getByCode(String, boolean) */ public static CountryCode getByCodeIgnoreCase(String code) { return getByCode(code, false); }
/** * Get a {@code CountryCode} that corresponds to the given ISO 3166-1 * <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">alpha-2</a> or * <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-3">alpha-3</a> code. * * <p> * This method calls {@link #getByCode(String, boolean) getByCode}{@code (code, false)}. * </p> * * @param code * An ISO 3166-1 <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2" * >alpha-2</a> or <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-3" * >alpha-3</a> code. Or {@code "UNDEFINED"} (case insensitive). * In addition, for backward compatibility, some 4-letter <a href= * "https://en.wikipedia.org/wiki/ISO_3166-3">ISO 3166-3</a> codes such * as {@code "ANHH"} are accepted. * * @return * A {@code CountryCode} instance, or {@code null} if not found. * * @since 1.13 * * @see #getByCode(String, boolean) */ public static CountryCode getByCodeIgnoreCase(String code) { return getByCode(code, false); }
public static CountryCode code(String countryId) { if (!UNKNOWN_ID.equals(countryId)) { String isoAlpha3 = OVERRIDES.getOrDefault(countryId, countryId); if (!UNKNOWN_ID.equals(isoAlpha3)) { CountryCode code = CountryCode.getByCode(isoAlpha3); if (code != null) return code; else throw new IllegalArgumentException("Unknown country ID: " + countryId); } } return null; }
public String validate() { final CountryCode shippingCountry = CountryCode.getByCode(countryShipping); if (shippingCountry == null || shippingCountry.equals(CountryCode.UNDEFINED)) { return "messages:checkout.address.invalidShippingCountry"; } if (billingAddressDifferentToBillingAddress) { final CountryCode billingCountry = CountryCode.getByCode(countryBilling); if (billingCountry == null || billingCountry.equals(CountryCode.UNDEFINED)) { return "messages:checkout.address.invalidBillingCountry"; } } return null; } }
private static Optional<CountryCode> findCurrentCountry(final Http.Context context) { return Optional.ofNullable(context.session().get(SESSION_COUNTRY)) .map(countryInSession -> CountryCode.getByCode(countryInSession, false)); }
public static String alpha3toAlpha2(String alpha3) throws UnknownCountryException { if(alpha3.length()==0) return " "; CountryCode countryCode = CountryCode.getByCode(alpha3); if(null==countryCode){ throw new UnknownCountryException("Can't find country "+alpha3, alpha3); } return countryCode.getAlpha2(); } }
/** * Get a list of {@code CurrencyCode} instances whose country * list contains the specified country. * * <p> * This method is an alias of {@link #getByCountry(CountryCode) * getByCountry}{@code (}{@link CountryCode}{@code .}{@link * CountryCode#getByCode(String, boolean) getByCode}{@code * (country, caseSensitive))}. * </p> * * @param country * Country code. ISO 3166-1 alpha-2 or alpha-3. * * @param caseSensitive * If {@code true}, the given code should consist of uppercase * letters only. If {@code false}, case is ignored. * * @return * List of {@code CurrencyCode} instances. If there is no * {@code CurrencyCode} instance whose country list contains * the specified country, the size of the returned list is zero. */ public static List<CurrencyCode> getByCountry(String country, boolean caseSensitive) { return getByCountry(CountryCode.getByCode(country, caseSensitive)); }
/** * Get a list of {@code CurrencyCode} instances whose country * list contains the specified country. * * <p> * This method is an alias of {@link #getByCountry(CountryCode) * getByCountry}{@code (}{@link CountryCode}{@code .}{@link * CountryCode#getByCode(String, boolean) getByCode}{@code * (country, caseSensitive))}. * </p> * * @param country * Country code. ISO 3166-1 alpha-2 or alpha-3. * * @param caseSensitive * If {@code true}, the given code should consist of uppercase * letters only. If {@code false}, case is ignored. * * @return * List of {@code CurrencyCode} instances. If there is no * {@code CurrencyCode} instance whose country list contains * the specified country, the size of the returned list is zero. */ public static List<CurrencyCode> getByCountry(String country, boolean caseSensitive) { return getByCountry(CountryCode.getByCode(country, caseSensitive)); }
/** * Get a list of {@code LocaleCode} instances whose country matches the given one. * * <p> * This method is an alias of {@link #getByCountry(CountryCode) * getByCountry}{@code (}{@link CountryCode}{@code .}{@link * CountryCode#getByCode(String, boolean) getByCode}{@code * (country, caseSensitive))}. * </p> * * @param country * Country code. ISO 3166-1 alpha-2 or alpha-3. * * @param caseSensitive * If {@code true}, the given code should consist of uppercase letters only. * If {@code false}, case is ignored. * * @return * List of {@code LocaleCode} instances. If there is no {@code LocaleCode} * instance whose country matches the given one, the size of the returned * list is zero. * * @since 1.3 */ public static List<LocaleCode> getByCountry(String country, boolean caseSensitive) { return getByCountry(CountryCode.getByCode(country, caseSensitive)); }
/** * Get a list of {@code LocaleCode} instances whose country matches the given one. * * <p> * This method is an alias of {@link #getByCountry(CountryCode) * getByCountry}{@code (}{@link CountryCode}{@code .}{@link * CountryCode#getByCode(String, boolean) getByCode}{@code * (country, caseSensitive))}. * </p> * * @param country * Country code. ISO 3166-1 alpha-2 or alpha-3. * * @param caseSensitive * If {@code true}, the given code should consist of uppercase letters only. * If {@code false}, case is ignored. * * @return * List of {@code LocaleCode} instances. If there is no {@code LocaleCode} * instance whose country matches the given one, the size of the returned * list is zero. * * @since 1.3 */ public static List<LocaleCode> getByCountry(String country, boolean caseSensitive) { return getByCountry(CountryCode.getByCode(country, caseSensitive)); }
/** * The language code setter. * * @param locale Optional. The desired language, consisting of an ISO 639 language code and an ISO 3166-1 alpha-2 * country code, joined by an underscore. For example: es_MX, meaning "Spanish (Mexico)". Provide this * parameter if you want the category metadata returned in a particular language. Note that, if locale * is not supplied, or if the specified language is not available, all strings will be returned in the * Spotify default language (American English). The locale parameter, combined with the country * parameter, may give odd results if not carefully matched. For example * {@code country=SE&locale=de_DE} will return a list of categories relevant to Sweden but as German * language strings. * @return A {@link GetCategoryRequest.Builder} * @see <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">Wikipedia: ISO 3166-1 alpha-2 country codes</a> * @see <a href="https://en.wikipedia.org/wiki/ISO_639">Wikipedia: ISO 639 language code</a> */ public Builder locale(final String locale) { assert (locale != null); assert (locale.contains("_")); String[] localeParts = locale.split("_"); assert (localeParts.length == 2); assert (LanguageCode.getByCode(localeParts[0]) != null); assert (CountryCode.getByCode(localeParts[1]) != null); return setQueryParameter("locale", locale); }
/** * The language code setter. * * @param locale Optional. The desired language, consisting of an ISO 639 language code and an ISO 3166-1 alpha-2 * country code, joined by an underscore. For example: es_MX, meaning "Spanish (Mexico)". Provide this * parameter if you want the category metadata returned in a particular language. Note that, if locale * is not supplied, or if the specified language is not available, all strings will be returned in the * Spotify default language (American English). The locale parameter, combined with the country * parameter, may give odd results if not carefully matched. For example * {@code country=SE&locale=de_DE} will return a list of categories relevant to Sweden but as German * language strings. * @return A {@link GetListOfFeaturedPlaylistsRequest.Builder}. * @see <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">Wikipedia: ISO 3166-1 alpha-2 country codes</a> * @see <a href="https://en.wikipedia.org/wiki/ISO_639">Wikipedia: ISO 639 language code</a> */ public Builder locale(final String locale) { assert (locale != null); assert (locale.contains("_")); String[] localeParts = locale.split("_"); assert (localeParts.length == 2); assert (LanguageCode.getByCode(localeParts[0]) != null); assert (CountryCode.getByCode(localeParts[1]) != null); return setQueryParameter("locale", locale); }
/** * The language code setter. * * @param locale Optional. The desired language, consisting of an ISO 639 language code and an ISO 3166-1 alpha-2 * country code, joined by an underscore. For example: es_MX, meaning "Spanish (Mexico)". Provide this * parameter if you want the category metadata returned in a particular language. Note that, if locale * is not supplied, or if the specified language is not available, all strings will be returned in the * Spotify default language (American English). The locale parameter, combined with the country * parameter, may give odd results if not carefully matched. For example * {@code country=SE&locale=de_DE} will return a list of categories relevant to Sweden but as German * language strings. * @return A {@link GetListOfCategoriesRequest.Builder} * @see <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">Wikipedia: ISO 3166-1 alpha-2 country codes</a> * @see <a href="https://en.wikipedia.org/wiki/ISO_639">Wikipedia: ISO 639 language code</a> */ public Builder locale(final String locale) { assert (locale != null); assert (locale.contains("_")); String[] localeParts = locale.split("_"); assert (localeParts.length == 2); assert (LanguageCode.getByCode(localeParts[0]) != null); assert (CountryCode.getByCode(localeParts[1]) != null); return setQueryParameter("locale", locale); }
if (optionalCountry.isPresent()) { Country country = optionalCountry.get(); CountryCode code = CountryCode.getByCode(country.getIsoCode()); if (code != null) countryId = code.getAlpha3();
@Override @Nullable public Address toBillingAddress() { if (isBillingAddressDifferentToBillingAddress()) { final CountryCode country = CountryCode.getByCode(countryBilling); return AddressBuilder.of(country) .title(titleBilling) .firstName(firstNameBilling) .lastName(lastNameBilling) .streetName(streetNameBilling) .additionalStreetInfo(additionalStreetInfoBilling) .city(cityBilling) .postalCode(postalCodeBilling) .region(regionBilling) .phone(phoneBilling) .email(emailBilling) .build(); } else { return null; } }
@Override public Address toShippingAddress() { final CountryCode country = CountryCode.getByCode(countryShipping); return AddressBuilder.of(country) .title(titleShipping) .firstName(firstNameShipping) .lastName(lastNameShipping) .streetName(streetNameShipping) .additionalStreetInfo(additionalStreetInfoShipping) .city(cityShipping) .postalCode(postalCodeShipping) .region(regionShipping) .phone(phoneShipping) .email(emailShipping) .build(); }