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; } };
/** 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(); }
private List<FormSelectableOptionBean> createCountryFormOptions() { final List<FormSelectableOptionBean> countrySelector = projectContext.countries().stream() .map(countryCode -> { final FormSelectableOptionBean bean = new FormSelectableOptionBean(); bean.setLabel(countryCode.getName()); bean.setValue(countryCode.getAlpha2()); bean.setSelected(countryCode.equals(userContext.country())); return bean; }).collect(toList()); return (countrySelector.size() > 1) ? countrySelector : emptyList(); }
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(); } }
/** * Looks up the locations and checks if the country is present. It does not matter if the location has a state specified. * * @param countryCode the country to search for * @return true if the country is somehow in the locations. */ default boolean contains(final CountryCode countryCode) { return getLocations().stream().anyMatch(location -> location.getCountry().equals(countryCode)); }
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; } }
protected final void initializeFormSelectableOption(final FormSelectableOptionBean bean, final CountryCode country, final @Nullable String selectedCountryCode) { final String countryCode = country.getAlpha2(); bean.setLabel(country.toLocale().getDisplayCountry(userContext.locale())); bean.setValue(countryCode); bean.setSelected(countryCode.equals(selectedCountryCode)); }
private static boolean checkCountryCode(CountryCode countryCode) { try{ return CountryCodeList.valueOf(countryCode.name()) != null; } catch (java.lang.IllegalArgumentException e) { return false; } }
public static String getCountry(String countryCode) { CountryCode code = CountryCode.getByCodeIgnoreCase(countryCode); return (code != null) ? code.getName() : null; }
public String getName() { CountryCode code = code(countryId); return code != null ? code.getName() : UNKNOWN_NAME; }
public static String getCountryCode(String displayCountry) { List<CountryCode> codes = CountryCode.findByName(displayCountry); return (!codes.isEmpty()) ? codes.get(0).name() : null; }
return findByName(pattern);
public PriceSelectionBuilder priceCountry(@Nullable final CountryCode priceCountry) { this.priceCountry = Optional.ofNullable(priceCountry).map(c -> c.getAlpha2()).orElse(null); return this; }
/** * Looks up the locations and checks if the country is present. It does not matter if the location has a state specified. * * @param countryCode the country to search for * @return true if the country is somehow in the locations. */ default boolean contains(final CountryCode countryCode) { return getLocations().stream().anyMatch(location -> location.getCountry().equals(countryCode)); } }
/** * 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(); }
public static String getCountryNameFromPattern(String localeString) { CountryCode code = CountryCode.getByCodeIgnoreCase(extractCountry(localeString)); if (code != null) { return code.getName(); } else { System.err.println("Could not get the Country name for " + localeString); return Locale.forLanguageTag(extractLanguage(localeString)).getDisplayCountry(); } }