本文整理匯總了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);
}
}