List of usage examples for java.util Locale getISOCountries
public static String[] getISOCountries()
From source file:com.redhat.rhn.common.localization.LocalizationService.java
/** * Get a SortedMap containing NAME/CODE value pairs. The reason we key the * Map based on the NAME is that we desire to maintain a localized sort * order based on the display value and not the code. * * <pre>// w ww . jav a 2 s . c o m * {name=Spain, code=ES} * {name=Sri Lanka, code=LK} * {name=Sudan, code=SD} * {name=Suriname, code=SR, } * etc ... * </pre> * * @return SortedMap sorted map of available countries. */ public SortedMap<String, String> availableCountries() { List<String> validCountries = new LinkedList<String>(Arrays.asList(Locale.getISOCountries())); String[] excluded = Config.get().getStringArray(ConfigDefaults.WEB_EXCLUDED_COUNTRIES); if (excluded != null) { validCountries.removeAll(new LinkedList<String>(Arrays.asList(excluded))); } SortedMap<String, String> ret = new TreeMap<String, String>(); for (Iterator<String> iter = validCountries.iterator(); iter.hasNext();) { String isoCountry = iter.next(); ret.put(this.getMessage(isoCountry), isoCountry); } return ret; }
From source file:org.mobicents.servlet.restcomm.provisioning.number.nexmo.NexmoPhoneNumberProvisioningManager.java
@Override public List<String> getAvailableCountries() { List<String> countries = new ArrayList<String>(); String[] locales = Locale.getISOCountries(); for (String countryCode : locales) { countries.add(countryCode);/*from w w w. ja v a2 s. com*/ } return countries; }
From source file:org.mifosplatform.infrastructure.core.serialization.JsonParserHelper.java
private static Locale localeFrom(final String languageCode, final String courntryCode, final String variantCode) { final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>(); final List<String> allowedLanguages = Arrays.asList(Locale.getISOLanguages()); if (!allowedLanguages.contains(languageCode.toLowerCase())) { final ApiParameterError error = ApiParameterError.parameterError("validation.msg.invalid.locale.format", "The parameter locale has an invalid language value " + languageCode + " .", "locale", languageCode);/*from ww w . j ava 2s . com*/ dataValidationErrors.add(error); } if (StringUtils.isNotBlank(courntryCode.toUpperCase())) { final List<String> allowedCountries = Arrays.asList(Locale.getISOCountries()); if (!allowedCountries.contains(courntryCode)) { final ApiParameterError error = ApiParameterError.parameterError( "validation.msg.invalid.locale.format", "The parameter locale has an invalid country value " + courntryCode + " .", "locale", courntryCode); dataValidationErrors.add(error); } } if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors); } return new Locale(languageCode.toLowerCase(), courntryCode.toUpperCase(), variantCode); }
From source file:eu.apenet.dpt.standalone.gui.eaccpf.EacCpfDescriptionPanel.java
/** * Fill all list used into main-frame panel *//*from w w w.j a v a 2 s .c o m*/ private void fillListModels() { //fill countries String[] locales = Locale.getISOCountries(); countriesListWithEmpty = new ArrayList<String>(); countriesListWithEmpty.add(TextFieldWithComboBoxEacCpf.DEFAULT_VALUE); countriesMap = new HashMap<String, String>(); for (String countryCode : locales) { Locale obj = new Locale("", countryCode); countriesListWithEmpty.add(obj.getDisplayCountry(Locale.ENGLISH)); countriesMap.put(obj.getDisplayCountry(Locale.ENGLISH), obj.getISO3Country()); } //DATES this.placesDates = new HashMap<Integer, List<TextFieldsWithRadioButtonForDates>>(); this.functionsDates = new HashMap<Integer, List<TextFieldsWithRadioButtonForDates>>(); this.occupationsDates = new HashMap<Integer, List<TextFieldsWithRadioButtonForDates>>(); }
From source file:edu.uchicago.duo.web.DuoEnrollController.java
/** * ********************************************************************* * Below are ALL FOR creating the International Dial Code Drop Down list * * Used in: DuoEnrollStep3.jsp/*from w w w.j a va2 s. c om*/ * ********************************************************************* */ @ModelAttribute("countryDialList") public Map<String, String> populatecountryDialList() { List<DuoEnrollController.Country> countries = new ArrayList<>(); Map<String, String> dialCodes = new LinkedHashMap<>(); Map<String, String> sortedDialCodes = new LinkedHashMap<>(); PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance(); // // Get ISO countries, create Country object and // store in the collection. // String[] isoCountries = Locale.getISOCountries(); for (String country : isoCountries) { Locale locale = new Locale("en", country); String code = locale.getCountry(); String name = locale.getDisplayCountry(); if (!"".equals(code) && !"".equals(name)) { try { int dialCode = phoneUtil.parse("1112223333", code).getCountryCode(); countries.add(new DuoEnrollController.Country(code, name, dialCode)); } catch (Exception e) { } } } Collections.sort(countries, new DuoEnrollController.CountryComparator()); for (DuoEnrollController.Country country : countries) { dialCodes.put("+" + String.valueOf(country.dialCode), country.name); //dialCodes.put("+"+String.valueOf(country.code), country.name); } sortedDialCodes = sortByValue(dialCodes); return sortedDialCodes; }
From source file:com.gst.infrastructure.core.serialization.JsonParserHelper.java
private static Locale localeFrom(final String languageCode, final String courntryCode, final String variantCode) { final List<ApiParameterError> dataValidationErrors = new ArrayList<>(); final List<String> allowedLanguages = Arrays.asList(Locale.getISOLanguages()); if (!allowedLanguages.contains(languageCode.toLowerCase())) { final ApiParameterError error = ApiParameterError.parameterError("validation.msg.invalid.locale.format", "The parameter locale has an invalid language value " + languageCode + " .", "locale", languageCode);/* w w w . ja v a 2 s . c om*/ dataValidationErrors.add(error); } if (StringUtils.isNotBlank(courntryCode.toUpperCase())) { final List<String> allowedCountries = Arrays.asList(Locale.getISOCountries()); if (!allowedCountries.contains(courntryCode)) { final ApiParameterError error = ApiParameterError.parameterError( "validation.msg.invalid.locale.format", "The parameter locale has an invalid country value " + courntryCode + " .", "locale", courntryCode); dataValidationErrors.add(error); } } if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors); } return new Locale(languageCode.toLowerCase(), courntryCode.toUpperCase(), variantCode); }
From source file:org.adamkrajcik.gui.MainForm.java
private void createWineMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createWineMenuItemActionPerformed JTextField name = new JTextField(); SpinnerNumberModel model = new SpinnerNumberModel((short) Calendar.getInstance().get(Calendar.YEAR), (short) 1700, (short) Calendar.getInstance().get(Calendar.YEAR), (short) 1); JSpinner vintage = new JSpinner(model); SpinnerNumberModel model2 = new SpinnerNumberModel(1, 1, Integer.MAX_VALUE, 1); JSpinner quantity = new JSpinner(model2); String[] wineTypes = { "RED", "WHITE", "ROSE" }; JComboBox type = new JComboBox(wineTypes); List<String> myList = new ArrayList<String>(); for (String countryCode : Locale.getISOCountries()) { Locale obj = new Locale("", countryCode); myList.add(obj.getDisplayCountry(Locale.ENGLISH)); }/* ww w . j a v a2 s.co m*/ String[] x = new String[myList.size()]; myList.toArray(x); JComboBox countryList = new JComboBox(x); Object[] message = { "Name:", name, "Country:", countryList, "Vintage:", vintage, "Quantity", quantity, "Type", type, }; int option = JOptionPane.showConfirmDialog(null, message, "New Wine", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (option == JOptionPane.OK_OPTION) { if (name.getText().length() == 0) { JOptionPane.showConfirmDialog(null, langResource.getString("errorName"), langResource.getString("errorName"), JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE); createWineMenuItemActionPerformed(null); return; } new CreateWineSwingWorker(newWine(name.getText(), (String) countryList.getSelectedItem(), (short) ((int) vintage.getValue()), (int) quantity.getValue(), WineType.valueOf((String) type.getSelectedItem()))).execute(); } }
From source file:edu.virginia.iath.snac.helpers.GeoNamesHelper.java
/** * Creates a hashmap of countries of the world as full name -> ISO standard abbreviation * /*from w w w. j a v a 2 s . c o m*/ * @return Hashmap of all countries */ public HashMap<String, String> getCountries() { HashMap<String, String> countries = new HashMap<String, String>(); for (String iso : Locale.getISOCountries()) { Locale l = new Locale("", iso); countries.put(l.getDisplayCountry().toLowerCase(), iso); } // Fix for United Kingdom being called Great Britain or England countries.put("england", "gb"); countries.put("great britain", "gb"); // Fix for U.S.S.R., which does exist in geonames, but only as a political entity countries.put("ussr", "ru"); // Since we seem to have issues matching the united states and mexico, let's add it! countries.put("united states", "us"); countries.put("mexico", "mx"); return countries; }
From source file:org.openehealth.pors.core.PorsCoreBean.java
/** * @see IPorsCore#validateAddress(Address) *///from w w w.j ava 2 s. c om public void validateAddress(Address address) throws MissingFieldsException, WrongValueException { if (isEmpty(address.getStreet())) { throw new MissingFieldsException("Street is missing in address"); } if (isEmpty(address.getHouseNumber())) { throw new MissingFieldsException("House number is missing in address"); } else if (address.getHouseNumber().length() > 7) { throw new WrongValueException("House number is too long, only 7 characters allowed!"); } if (isEmpty(address.getCity())) { throw new MissingFieldsException("City is missing in address"); } if (isEmpty(address.getCountry())) { throw new MissingFieldsException("Country is missing in address"); } else { String[] countries = Locale.getISOCountries(); boolean countryOk = false; for (String c : countries) { if (address.getCountry().equalsIgnoreCase(c)) { countryOk = true; } } if (!countryOk) { throw new WrongValueException( "Country must be valid to ISO 639, value was: " + address.getCountry()); } } }
From source file:org.oscm.ui.services.MockService.java
@Override public List<String> getSupportedCountryCodes() { return Arrays.asList(Locale.getISOCountries()); }