CountryCode cc = CountryCode.getByCode("JP"); System.out.println("Country name = " + cc.getName()); // "Japan" System.out.println("ISO 3166-1 alpha-2 code = " + cc.getAlpha2()); // "JP" System.out.println("ISO 3166-1 alpha-3 code = " + cc.getAlpha3()); // "JPN" System.out.println("ISO 3166-1 numeric code = " + cc.getNumeric()); // 392
@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; } };
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; } }
/** The optional country where this price applies, used in price calculations. * * @return The ISO 3166-1 (alpha-2) string representation of the country. If country is not defined, returns "" (empty string). * */ public String getCountryString() { return country == null ? "" : country.getAlpha2(); }
public static String getCountry(String countryCode) { CountryCode code = CountryCode.getByCodeIgnoreCase(countryCode); return (code != null) ? code.getName() : null; }
private static boolean checkCountryCode(CountryCode countryCode) { try{ return CountryCodeList.valueOf(countryCode.name()) != null; } catch (java.lang.IllegalArgumentException e) { return false; } }
public static String getLanguage(String languageCode) { LanguageCode code = LanguageCode.getByCodeIgnoreCase(languageCode); return (code != null) ? code.getName() : null; }
/** * Validate the given code. * * @param stringCode * the string code * @return true, if successful */ public static boolean validate(final String stringCode) { return LocaleCode.getByCode(stringCode) != null; }
/** * Determines if a string is a valid language code. * @param languageCode A language code. * @return <code>true</code> if the string is a valid 3-letter language code; * otherwise <code>false</code>. */ public static boolean validate(String languageCode) { LanguageCode code = LanguageCode.getByCodeIgnoreCase(languageCode); if(code == null) { return false; } else { return true; } }
@Override public Locale toLocale() { return LocaleCode.undefined.toLocale(); } },
@Override public int hashCode() { return country != null ? country.hashCode() : 0; }
rs.getLong("parent_place_id"), importance, CountryCode.getByCode(rs.getString("country_code")), (Point) DBUtils.extractGeometry(rs, "centroid"), rs.getLong("linked_place_id"),
/** * Get the <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2" * >ISO 3166-1 alpha-2</a> code. * * @return * The <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2" * >ISO 3166-1 alpha-2</a> code. * {@link CountryCode#UNDEFINED} returns {@code "UNDEFINED"} * which is not an official ISO 3166-1 alpha-2 code. */ public String getAlpha2() { return name(); }
@Override public Locale toLocale() { return LocaleCode.undefined.toLocale(); } },
/** * Get the <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2" * >ISO 3166-1 alpha-2</a> code. * * @return * The <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2" * >ISO 3166-1 alpha-2</a> code. * {@link CountryCode#UNDEFINED} returns {@code "UNDEFINED"} * which is not an official ISO 3166-1 alpha-2 code. */ public String getAlpha2() { return name(); }