本文整理汇总了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;
}
示例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();
}
示例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!");
}
示例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;
}
}
示例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!");
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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;
}
}
示例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);
}
}
示例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);
}
}