本文整理匯總了Java中java.util.Locale.getISO3Country方法的典型用法代碼示例。如果您正苦於以下問題:Java Locale.getISO3Country方法的具體用法?Java Locale.getISO3Country怎麽用?Java Locale.getISO3Country使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.Locale
的用法示例。
在下文中一共展示了Locale.getISO3Country方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initIso3Locales
import java.util.Locale; //導入方法依賴的package包/類
private static void initIso3Locales() {
filteredIso3Locales = new HashMap<>();
for (Locale locale : LOCALES) {
final String country = locale.getDisplayCountry();
if (country.length() == 0)
continue;
final String iso3Locale;
try {
iso3Locale = locale.getISO3Country();
} catch (MissingResourceException mre) {
continue;
}
filteredIso3Locales.put(iso3Locale, country);
}
filteredIso3Locales = sortHashMapByValues(filteredIso3Locales);
}
示例2: Test4147315
import java.util.Locale; //導入方法依賴的package包/類
/**
* @bug 4147315
* java.util.Locale.getISO3Country() works wrong for non ISO-3166 codes.
* Should throw an exception for unknown locales
*/
public void Test4147315() {
// Try with codes that are the wrong length but happen to match text
// at a valid offset in the mapping table
Locale locale = new Locale("aaa", "CCC");
try {
String result = locale.getISO3Country();
errln("ERROR: getISO3Country() returns: " + result +
" for locale '" + locale + "' rather than exception" );
} catch(MissingResourceException e) { }
}
示例3: Test4147315
import java.util.Locale; //導入方法依賴的package包/類
/**
* @bug 4147315
* java.util.Locale.getISO3Country() works wrong for non ISO-3166 codes.
* Should throw an exception for unknown locales
*/
public void Test4147315() {
// Try with codes that are the wrong length but happen to match text
// at a valid offset in the mapping table
Locale locale = new Locale("aaa", "CCC");
try {
String result = locale.getISO3Country();
errln("ERROR: getISO3Country() returns: " + result
+ " for locale '" + locale + "' rather than exception");
} catch (MissingResourceException e) {
}
}
示例4: getLanguageAndCountryLists
import java.util.Locale; //導入方法依賴的package包/類
/**
* Get list of available languages for TextToSpeech. Do not call unless the TTS
* engine is initialized.
*
*/
private void getLanguageAndCountryLists() {
// We do compute these lists pre-Donut. We probably could
// arrange to also do this in earlier releases, but that would be
// relying on the use of an external textToSpeech application and those
// old releases are obsolete anyway.
if (SdkLevel.getLevel() >= SdkLevel.LEVEL_DONUT) {
String tempLang;
String tempCountry;
for (Locale locale : Locale.getAvailableLocales()) {
// isLanguageAvailable requires tts to be initialized
int res = tts.isLanguageAvailable(locale);
if (!(res == android.speech.tts.TextToSpeech.LANG_NOT_SUPPORTED)){
tempLang = locale.getLanguage();
// We record only the ISO3 country codes for now. We should update the TTS control
// to use voices, and then we can straighten this out, maybe getting rid of
// country modifiers in TTS altogether.
tempCountry = locale.getISO3Country();
if (!tempLang.equals("") && (!languageList.contains(tempLang))){
languageList.add(tempLang);
}
if (!tempCountry.equals("") && (!countryList.contains(tempCountry))){
countryList.add(tempCountry);
}
}
}
Collections.sort(languageList);
Collections.sort(countryList);
allLanguages = YailList.makeList(languageList);
allCountries = YailList.makeList(countryList);
}
}
示例5: zoomMenuCommands
import java.util.Locale; //導入方法依賴的package包/類
/**
* Adds support for plus and minus menu commands, typically for zooming in
* and out. This is designed for menu items with key accelerators using
* KeyEvent.VK_ADD and KeyEvent.VK_SUBTRACT (which are typically on the
* numerical key pad). It adds support for KeyEvent.VK_MINUS and
* KeyEvent.VK_PLUS, and KeyEvent.VK_EQUALS for keyboard layouts with the
* plus sign as secondary key for the equals.
*
* @param inputMap add key event to this InputMap
* @param actionMap add action to this ActionMap
* @param zoomInAction action to call when the + key and the menu shortcut
* key are pressed
* @param zoomOutAction action to call when the - key and the menu shortcut
* key are pressed
*/
public static void zoomMenuCommands(InputMap inputMap, ActionMap actionMap, Action zoomInAction, Action zoomOutAction) {
int menuKeyMask = java.awt.Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
// add support for minus key
KeyStroke minusMenueKeyStroke = KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_MINUS, menuKeyMask);
inputMap.put(minusMenueKeyStroke, "zoomOutWithMinusKey");
actionMap.put("zoomOutWithMinusKey", zoomOutAction);
// add support for plus key to zoom in. This only works if the keyboard
// layout allows access to the plus character without pressing the shift
// key, which is not the case for US and UK keyboards.
KeyStroke plusMenuKeyStroke = KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_PLUS, menuKeyMask);
inputMap.put(plusMenuKeyStroke, "zoomInWithPlusKey");
actionMap.put("zoomInWithPlusKey", zoomInAction);
// add support for cases where the plus character is the secondary
// character for the equal sign key. That is, plus is accessed by pressing
// the shift key and the equal key. This is the case for US and UK
// keyboard layouts, which are also used in Ireland, India, Australia, Canada,
// Hong Kong, New Zealand, South Africa, Malaysia, Singapore and Philippines.
// See https://stackoverflow.com/questions/15605109/java-keybinding-plus-key
// and https://en.wikipedia.org/wiki/QWERTY
// The French Canadian keyboard also has = and + on the same key.
Locale locale = InputContext.getInstance().getLocale();
String isoCountry = locale.getISO3Country();
// https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
if ("USA".equals(isoCountry)
|| "GBR".equals(isoCountry)
|| "IRL".equals(isoCountry)
|| "IND".equals(isoCountry)
|| "AUS".equals(isoCountry)
|| "CAN".equals(isoCountry)
|| "HKG".equals(isoCountry)
|| "NZL".equals(isoCountry)
|| "ZAF".equals(isoCountry)
|| "MYS".equals(isoCountry)
|| "SGP".equals(isoCountry)
|| "PHL".equals(isoCountry)) {
KeyStroke euqalsMenuKeyStroke = KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_EQUALS, menuKeyMask);
inputMap.put(euqalsMenuKeyStroke, "zoomInWithEqualsKey");
actionMap.put("zoomInWithEqualsKey", zoomInAction);
}
}