當前位置: 首頁>>代碼示例>>Java>>正文


Java Locale.getISOCountries方法代碼示例

本文整理匯總了Java中java.util.Locale.getISOCountries方法的典型用法代碼示例。如果您正苦於以下問題:Java Locale.getISOCountries方法的具體用法?Java Locale.getISOCountries怎麽用?Java Locale.getISOCountries使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.Locale的用法示例。


在下文中一共展示了Locale.getISOCountries方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getCountryList

import java.util.Locale; //導入方法依賴的package包/類
protected String[] getCountryList() {
  if (countryList == null) {
    String[] c = Locale.getISOCountries();
    ArrayList<String> sortedCountries = new ArrayList<String>();
    for (int i = 0; i < c.length; i++) {
      String country =
        (new Locale("en", c[i])).getDisplayCountry(Locale.getDefault());
      countries.put(country, c[i]);
      sortedCountries.add(country);
    }
    Collections.sort(sortedCountries,
                     Collator.getInstance(Locale.getDefault()));
    countries.put(ANY_COUNTRY, "");
    sortedCountries.add(0, ANY_COUNTRY);
    countryList = sortedCountries.toArray(new String[sortedCountries.size()]);
  }
  return countryList;
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:19,代碼來源:LocaleConfigurer.java

示例2: CountryList

import java.util.Locale; //導入方法依賴的package包/類
public CountryList() {
    // A collection to store our country object
    this.countries = new ArrayList<String>();

    // 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 name = locale.getDisplayCountry();

        if (!"".equals(name)) {
            this.countries.add(name);
        }
    }
    this.countryListSize = countries.size();
    this.random = new Random();
}
 
開發者ID:couchbaselabs,項目名稱:GitTalent,代碼行數:19,代碼來源:CountryList.java

示例3: Test4126880

import java.util.Locale; //導入方法依賴的package包/類
/**
 * @bug 4126880
 */
void Test4126880() {
    String[] test;

    test = Locale.getISOCountries();
    test[0] = "SUCKER!!!";
    test = Locale.getISOCountries();
    if (test[0].equals("SUCKER!!!"))
        errln("Changed internal country code list!");

    test = Locale.getISOLanguages();
    test[0] = "HAHAHAHA!!!";
    test = Locale.getISOLanguages();
    if (test[0].equals("HAHAHAHA!!!")) // Fixed typo
        errln("Changes internal language code list!");
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:19,代碼來源:LocaleTest.java

示例4: listAll

import java.util.Locale; //導入方法依賴的package包/類
public static ArrayList<Country> listAll(Context context, final String filter) {
    ArrayList<Country> list = new ArrayList<>();

    for (String countryCode : Locale.getISOCountries()) {
        Country country = getCountry(countryCode, context);

        list.add(country);
    }

    sortList(list);

    if (filter != null && filter.length() > 0) {
        return new ArrayList<>(Collections2.filter(list, new Predicate<Country>() {
            @Override
            public boolean apply(Country input) {
                return input.getName().toLowerCase().contains(filter.toLowerCase());
            }
        }));
    } else {
        return list;
    }
}
 
開發者ID:Scrounger,項目名稱:CountryCurrencyPicker,代碼行數:23,代碼來源:Country.java

示例5: Test4126880

import java.util.Locale; //導入方法依賴的package包/類
/**
 * @bug 4126880
 */
void Test4126880() {
    String[] test;

    test = Locale.getISOCountries();
    test[0] = "SUCKER!!!";
    test = Locale.getISOCountries();
    if (test[0].equals("SUCKER!!!")) {
        errln("Changed internal country code list!");
    }

    test = Locale.getISOLanguages();
    test[0] = "HAHAHAHA!!!";
    test = Locale.getISOLanguages();
    if (test[0].equals("HAHAHAHA!!!")) { // Fixed typo
        errln("Changes internal language code list!");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:LocaleTest.java

示例6: getCountriesList

import java.util.Locale; //導入方法依賴的package包/類
public static List<String> getCountriesList() {
    List<String> countriesList = new ArrayList<>();

    String[] locales = Locale.getISOCountries();

    for (String countryCode : locales) {

        Locale obj = new Locale("", countryCode);
        countriesList.add(obj.getDisplayCountry(Locale.ENGLISH));

    }
    Collections.sort(countriesList);
    return countriesList;
}
 
開發者ID:Elbehiry,項目名稱:Viajes,代碼行數:15,代碼來源:Utils.java

示例7: createAllSupportedCountries

import java.util.Locale; //導入方法依賴的package包/類
/**
 * Creates all SupportedCountry objects. Normally all SupportedCountry
 * objects are created during DB setup. Creating all countries is slow and
 * should be done only if needed.
 */
public static void createAllSupportedCountries(DataService mgr)
        throws NonUniqueBusinessKeyException {
    for (String countryCode : Locale.getISOCountries()) {
        findOrCreate(mgr, countryCode);
    }
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:12,代碼來源:SupportedCountries.java

示例8: supportAllCountries

import java.util.Locale; //導入方法依賴的package包/類
public static void supportAllCountries(DataService mgr, Organization org) {
    for (String countryCode : Locale.getISOCountries()) {
        SupportedCountry country = SupportedCountries
                .find(mgr, countryCode);
        if (country != null) {
            org.setSupportedCountry(country);
        }
    }
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:10,代碼來源:Organizations.java

示例9: getDisplayCountries

import java.util.Locale; //導入方法依賴的package包/類
/**
 * Returns a mapping from country codes in ISO 3166 to localized country
 * names.
 */
public Map<String, String> getDisplayCountries() {
    if (hasLocaleChanged()) {
        reset();
    }
    if (displayCountries.isEmpty()) {
        Locale userLocale = getCurrentUserLocale();
        for (String code : Locale.getISOCountries()) {
            String country = getDisplayCountry(code, userLocale);
            displayCountries.put(code, country);
        }
    }
    return displayCountries;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:18,代碼來源:CountryBean.java

示例10: getTagsForProperty

import java.util.Locale; //導入方法依賴的package包/類
@Override
public String[] getTagsForProperty(String propertyName) {
	if(propertyName.equals("outputLocale") || propertyName.equals("inputLocale")){
		return Locale.getISOCountries();
	}
	return super.getTagsForProperty(propertyName);
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:8,代碼來源:XMLDateTimeStep.java

示例11: getTagsForProperty

import java.util.Locale; //導入方法依賴的package包/類
@Override
public String[] getTagsForProperty(String propertyName) {
	if(propertyName.equals("inputLocale") ||
		propertyName.equals("outputLocale")) {
		return Locale.getISOCountries();
	}
	return super.getTagsForProperty(propertyName);
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:9,代碼來源:XMLGenerateDatesStep.java

示例12: convertToIso2

import java.util.Locale; //導入方法依賴的package包/類
public static String convertToIso2(String iso3code) {

        String[] countries = Locale.getISOCountries();

        HashMap<String, Locale> localeMap = new HashMap<>(countries.length);
        for (String country : countries) {
            Locale locale = new Locale("", country);
            localeMap.put(locale.getISO3Country().toUpperCase(), locale);
        }

        return localeMap.get(iso3code).getCountry();
    }
 
開發者ID:Code4SocialGood,項目名稱:c4sg-services,代碼行數:13,代碼來源:CountryCodeConverterUtil.java

示例13: listAllWithCurrencies

import java.util.Locale; //導入方法依賴的package包/類
public static ArrayList<Country> listAllWithCurrencies(Context context, final String filter) {
    ArrayList<Country> list = new ArrayList<>();

    for (String countryCode : Locale.getISOCountries()) {
        Country country = getCountryWithCurrency(countryCode, context);

        if (country != null) {
            //z.B. Antarktis is null -> keine Währung
            list.add(country);
        }
    }

    sortList(list);

    if (filter != null && filter.length() > 0) {
        return new ArrayList<>(Collections2.filter(list, new Predicate<Country>() {
            @Override
            public boolean apply(Country input) {
                return input.getName().toLowerCase().contains(filter.toLowerCase()) ||
                        input.getCurrency().getName().toLowerCase().contains(filter.toLowerCase()) ||
                        input.getCurrency().getSymbol().toLowerCase().contains(filter.toLowerCase());
            }
        }));
    } else {
        return list;
    }
}
 
開發者ID:Scrounger,項目名稱:CountryCurrencyPicker,代碼行數:28,代碼來源:Country.java

示例14: checkISO3166_3Codes

import java.util.Locale; //導入方法依賴的package包/類
/**
 * This method checks that ISO3166-3 country codes which are PART3 of
 * IsoCountryCode enum, are retrieved correctly.
 */
private static void checkISO3166_3Codes() {
    Set<String> iso3166_3Codes = Locale.getISOCountries(IsoCountryCode.PART3);
    if (!iso3166_3Codes.equals(ISO3166_3EXPECTED)) {
        reportDifference(iso3166_3Codes, ISO3166_3EXPECTED);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:Bug8071929.java

示例15: checkISO3166_1_Alpha3Codes

import java.util.Locale; //導入方法依賴的package包/類
/**
 * This method checks that ISO3166-1 alpha-3 country codes which are
 * PART1_ALPHA3 of IsoCountryCode enum, are retrieved correctly.
 */
private static void checkISO3166_1_Alpha3Codes() {
    Set<String> iso3166_1_Alpha3Codes = Locale.getISOCountries(IsoCountryCode.PART1_ALPHA3);
    if (!iso3166_1_Alpha3Codes.equals(ISO3166_1_ALPHA3_EXPECTED)) {
        reportDifference(iso3166_1_Alpha3Codes, ISO3166_1_ALPHA3_EXPECTED);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:Bug8071929.java


注:本文中的java.util.Locale.getISOCountries方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。