当前位置: 首页>>代码示例>>Java>>正文


Java Locale.getISO3Country方法代码示例

本文整理汇总了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);
}
 
开发者ID:GrenderG,项目名称:Protestr,代码行数:17,代码来源:LocaleUtils.java

示例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) { }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:LocaleTest.java

示例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) {
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:LocaleTest.java

示例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);
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:37,代码来源:TextToSpeech.java

示例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);
    }
}
 
开发者ID:berniejenny,项目名称:MapAnalyst,代码行数:59,代码来源:GUIUtil.java


注:本文中的java.util.Locale.getISO3Country方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。