Java Code Examples for java.util.Locale.equals()

The following are Jave code examples for showing how to use equals() of the java.util.Locale class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: ResourceUtils.java   View Source Code Vote up 6 votes
private static Map <Locale, String> getBundleMessagesMapForKey(
        final String baseName,
        final String key,
        final ClassLoader loader) {
    Map <Locale, String> map = new HashMap <Locale, String> ();
    List <Locale> list = new ArrayList <Locale> ();
    list.add(new Locale(StringUtils.EMPTY_STRING));
    list.addAll(Arrays.asList(Locale.getAvailableLocales()));
    for(Locale locale : list) {
        ResourceBundle bundle = loadBundle(baseName, locale, loader);            
        if(bundle!=null && locale.equals(bundle.getLocale()) && !map.containsKey(bundle.getLocale())) {
            map.put(locale, getBundleMessage(baseName, locale, loader, key));
        }
    }
    return map;
}
 
Example 2
Project: jdk8u-jdk   File: ImageReader.java   View Source Code Vote up 6 votes
/**
 * Sets the current <code>Locale</code> of this
 * <code>ImageReader</code> to the given value.  A value of
 * <code>null</code> removes any previous setting, and indicates
 * that the reader should localize as it sees fit.
 *
 * @param locale the desired <code>Locale</code>, or
 * <code>null</code>.
 *
 * @exception IllegalArgumentException if <code>locale</code> is
 * non-<code>null</code> but is not one of the values returned by
 * <code>getAvailableLocales</code>.
 *
 * @see #getLocale
 */
public void setLocale(Locale locale) {
    if (locale != null) {
        Locale[] locales = getAvailableLocales();
        boolean found = false;
        if (locales != null) {
            for (int i = 0; i < locales.length; i++) {
                if (locale.equals(locales[i])) {
                    found = true;
                    break;
                }
            }
        }
        if (!found) {
            throw new IllegalArgumentException("Invalid locale!");
        }
    }
    this.locale = locale;
}
 
Example 3
Project: AOSP-Kayboard-7.1.2   File: RichInputMethodManager.java   View Source Code Vote up 6 votes
public boolean isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes() {
    final Locale systemLocale = mContext.getResources().getConfiguration().locale;
    final Set<InputMethodSubtype> enabledSubtypesOfEnabledImes = new HashSet<>();
    final InputMethodManager inputMethodManager = getInputMethodManager();
    final List<InputMethodInfo> enabledInputMethodInfoList =
            inputMethodManager.getEnabledInputMethodList();
    for (final InputMethodInfo info : enabledInputMethodInfoList) {
        final List<InputMethodSubtype> enabledSubtypes =
                inputMethodManager.getEnabledInputMethodSubtypeList(
                        info, true /* allowsImplicitlySelectedSubtypes */);
        if (enabledSubtypes.isEmpty()) {
            // An IME with no subtypes is found.
            return false;
        }
        enabledSubtypesOfEnabledImes.addAll(enabledSubtypes);
    }
    for (final InputMethodSubtype subtype : enabledSubtypesOfEnabledImes) {
        if (!subtype.isAuxiliary() && !subtype.getLocale().isEmpty()
                && !systemLocale.equals(SubtypeLocaleUtils.getSubtypeLocale(subtype))) {
            return false;
        }
    }
    return true;
}
 
Example 4
Project: firefox-tv   File: LocaleAwareFragment.java   View Source Code Vote up 6 votes
@Override
public void onResume() {
    super.onResume();

    LocaleManager.getInstance()
            .correctLocale(getContext(), getResources(), getResources().getConfiguration());

    if (cachedLocale == null) {
        cachedLocale = Locale.getDefault();
    } else {
        Locale newLocale = LocaleManager.getInstance().getCurrentLocale(getActivity().getApplicationContext());

        if (newLocale == null) {
            // Using system locale:
            newLocale = Locale.getDefault();
        }
        if (!newLocale.equals(cachedLocale)) {
            cachedLocale = newLocale;
            applyLocale();
        }
    }
}
 
Example 5
Project: openjdk-jdk10   File: Main.java   View Source Code Vote up 6 votes
public static void main(String[] args) throws Exception {
    int errors = 0;

    for (String loctag : args) {
        Locale locale = Locale.forLanguageTag(loctag);
        if (locale.equals(Locale.ROOT)) {
            continue;
        }
        ResourceBundle rb = ResourceBundle.getBundle("jdk.test.resources.MyResources", locale);
        String tag = locale.toLanguageTag(); // normalized
        String value = rb.getString("key");
        System.out.println("locale = " + tag + ", value = " + value);
        if (!value.startsWith(tag + ':')) {
            errors++;
        }
    }
    if (errors > 0) {
        throw new RuntimeException(errors + " errors");
    }
}
 
Example 6
Project: oscm   File: PartnerRevenueDao.java   View Source Code Vote up 6 votes
public Map<String, String> readMarketplaceNames(Locale locale,
        long periodEnd) {
    SqlQuery sqlQuery = new SqlQuery(QUERY_MARKETPLACE_NAMES);
    sqlQuery.setDate(1, new Date(periodEnd));
    DataSet dataSet = ds.executeQueryForRawData(sqlQuery);
    HashMap<String, String> marketplaceIdMap = new HashMap<String, String>();
    while (dataSet.next()) {
        Locale loc = new Locale(dataSet.getString("locale"));
        String mpId = dataSet.getString("marketplaceid");
        String mpName = dataSet.getString("value");
        if (null != locale && locale.equals(loc)) {
            marketplaceIdMap.put(mpId, mpName);
        } else if (defaultLocale.equals(loc)
                && null == marketplaceIdMap.get(mpId)) {
            marketplaceIdMap.put(mpId, mpName);
        }
    }
    return marketplaceIdMap;
}
 
Example 7
Project: oscm   File: PartnerRevenueDao.java   View Source Code Vote up 6 votes
public Map<String, String> readServiceNames(Locale locale, long periodEnd) {
    SqlQuery sqlQuery = new SqlQuery(QUERY_SERVICE_NAMES);
    sqlQuery.setDate(1, new Date(periodEnd));
    DataSet dataSet = ds.executeQueryForRawData(sqlQuery);
    HashMap<String, String> marketplaceIdMap = new HashMap<String, String>();
    while (dataSet.next()) {
        Locale loc = new Locale(dataSet.getString("locale"));
        String servId = dataSet.getString("productid");
        String servName = dataSet.getString("value");
        if (null != locale && locale.equals(loc)) {
            marketplaceIdMap.put(servId, servName);
        } else if (defaultLocale.equals(loc)
                && null == marketplaceIdMap.get(servId)) {
            marketplaceIdMap.put(servId, servName);
        }
    }
    return marketplaceIdMap;
}
 
Example 8
Project: openjdk-jdk10   File: Main.java   View Source Code Vote up 5 votes
public static void main(String[] args) throws Exception {
    int errors = 0;
    for (String loctag : args) {
        Locale locale = Locale.forLanguageTag(loctag);
        if (locale.equals(Locale.ROOT)) {
            continue;
        }
        ResourceBundle rb = ResourceBundle.getBundle("jdk.test.resources.MyResources",
                                                     locale);
        String tag = locale.toLanguageTag(); // normalized
        String value = rb.getString("key");
        System.out.println(rb.getBaseBundleName() + ": locale = " + tag + ", value = " + value);
        if (!value.startsWith(tag + ':')) {
            System.out.println("ERROR: " + value + " expected: " + tag);
            errors++;
        }

        // inaccessible bundles
        try {
            ResourceBundle.getBundle("jdk.test.internal.resources.Foo", locale);
            System.out.println("ERROR: jdk.test.internal.resources.Foo should not be accessible");
            errors++;
        } catch (MissingResourceException e) {
            e.printStackTrace();

            Throwable cause = e.getCause();
            System.out.println("Expected: " +
                (cause != null ? cause.getMessage() : e.getMessage()));
        }
    }
    if (errors > 0) {
        throw new RuntimeException(errors + " errors");
    }
}
 
Example 9
Project: openjdk-jdk10   File: TimeZoneNameUtility.java   View Source Code Vote up 5 votes
private static String[][] loadZoneStrings(Locale locale) {
    // If the provider is a TimeZoneNameProviderImpl, call its getZoneStrings
    // in order to avoid per-ID retrieval.
    LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(TimeZoneNameProvider.class, locale);
    TimeZoneNameProvider provider = adapter.getTimeZoneNameProvider();
    if (provider instanceof TimeZoneNameProviderImpl) {
        String[][] zoneStrings = ((TimeZoneNameProviderImpl)provider).getZoneStrings(locale);

        if (zoneStrings.length == 0 && locale.equals(Locale.ROOT)) {
            // Unlike other *Name provider, zoneStrings search won't do the fallback
            // name search. If the ResourceBundle found for the root locale contains no
            // zoneStrings, just use the one for English, assuming English bundle
            // contains all the tzids and their names.
            zoneStrings= getZoneStrings(Locale.ENGLISH);
        }

        return zoneStrings;
    }

    // Performs per-ID retrieval.
    Set<String> zoneIDs = LocaleProviderAdapter.forJRE().getLocaleResources(locale).getZoneIDs();
    List<String[]> zones = new LinkedList<>();
    for (String key : zoneIDs) {
        String[] names = retrieveDisplayNamesImpl(key, locale);
        if (names != null) {
            zones.add(names);
        }
    }

    String[][] zonesArray = new String[zones.size()][];
    return zones.toArray(zonesArray);
}
 
Example 10
Project: letv   File: TextUtilsCompat.java   View Source Code Vote up 5 votes
public int getLayoutDirectionFromLocale(@Nullable Locale locale) {
    if (!(locale == null || locale.equals(TextUtilsCompat.ROOT))) {
        String scriptSubtag = ICUCompat.maximizeAndGetScript(locale);
        if (scriptSubtag == null) {
            return getLayoutDirectionFromFirstChar(locale);
        }
        if (scriptSubtag.equalsIgnoreCase(TextUtilsCompat.ARAB_SCRIPT_SUBTAG) || scriptSubtag.equalsIgnoreCase(TextUtilsCompat.HEBR_SCRIPT_SUBTAG)) {
            return 1;
        }
    }
    return 0;
}
 
Example 11
Project: yadaframework   File: YadaLocaleDao.java   View Source Code Vote up 5 votes
/**
   * Get the localized value of an entity's attribute
   * @param entityId the id of the entity
   * @param entityClass the class of the entity
   * @param attributeName the name of the attribute that must be defined as Map<Locale, String>
   * @param locale the locale for the value, use null for the current request locale
   * @param returnNull (optional) true if null must be returned when no value is present instead of the empty string
   * @return the localized value in the specified locale, or in the default configured locale if the value is not set for that locale, 
   * or an empty string if no value is found or null if no value is found and returnNull is true.
   */
  public String getLocalValue(long entityId, Class<?> entityClass, String attributeName, Locale locale, Boolean... returnNull) {
  	// select color from YadaArticle_color where YadaArticle_id=123 and locale="en_US"
if (locale==null) {
	locale = LocaleContextHolder.getLocale();
}
  	String className = entityClass.getSimpleName();
  	String tableName = className + "_" + attributeName;
  	String idColumn = className + "_id";
  	YadaSql yadaSql = YadaSql.instance().selectFrom("select " + attributeName + " from " + tableName)
  		.where(idColumn + " = :entityId").and()
  		.where("locale = :localeString").and()
  		.setParameter("entityId", entityId)
  		.setParameter("localeString", locale.toString());
  	List<?> result = yadaSql.nativeQuery(em).getResultList();
  	if (result.isEmpty()) {
  		// Try with the default locale
  		Locale defaultLocale = config.getDefaultLocale();
  		if (defaultLocale!=null && !defaultLocale.equals(locale)) {
  			yadaSql.setParameter("localeString", defaultLocale.toString());
  			result = yadaSql.nativeQuery(em).getResultList();
  		}
  	}
  	if (result.isEmpty()) {
  		if (returnNull!=null && returnNull.length>0 && Boolean.TRUE.equals(returnNull[0])) {
  			return null;
  		}
  		return "";
  	}
  	return (String) result.get(0);
  }
 
Example 12
Project: OpenJSharp   File: X11InputMethod.java   View Source Code Vote up 5 votes
/**
 * Set locale to input. If input method doesn't support specified locale,
 * false will be returned and its behavior is not changed.
 *
 * @param lang locale to input
 * @return the true is returned when specified locale is supported.
 */
public boolean setLocale(Locale lang) {
    if (lang.equals(locale)) {
        return true;
    }
    // special compatibility rule for Japanese and Korean
    if (locale.equals(Locale.JAPAN) && lang.equals(Locale.JAPANESE) ||
            locale.equals(Locale.KOREA) && lang.equals(Locale.KOREAN)) {
        return true;
    }
    return false;
}
 
Example 13
Project: Yidu   File: SetLanguageInterceptor.java   View Source Code Vote up 5 votes
@Override
public String intercept(final ActionInvocation invocation) throws Exception {

    HttpServletRequest request = ServletActionContext.getRequest();
    HttpSession session = request.getSession(true);

    Locale locale = (Locale) session.getAttribute(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE);
    // Locale adminpagelocale = (Locale)
    // session.getAttribute(ADMIN_PAGE_LOCALE);
    // if (locale == null && adminpagelocale == null) {
    if (locale == null) {
        if (request.getLocale().equals(Locale.CHINA) || request.getLocale().equals(Locale.CHINESE)) {
            session.setAttribute(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE, Locale.CHINA);
            logger.debug("Language is set to Chinese. from IP <" + request.getRemoteAddr() + ">");
        } else if (request.getLocale().equals(Locale.JAPAN) || request.getLocale().equals(Locale.JAPANESE)) {
            session.setAttribute(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE, Locale.JAPAN);
            logger.debug("Language is set to Japanese. from IP <" + request.getRemoteAddr() + ">");
        } else {
            session.setAttribute(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE, Locale.US);
            logger.debug("Language is set to English.from IP <" + request.getRemoteAddr() + ">");
        }
    }
    // else if (adminpagelocale != null) {
    // session.setAttribute(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE,
    // adminpagelocale);
    // }
    if (invocation.getAction() instanceof AbstractAdminBaseAction
            && (locale == null || !locale.equals(Locale.CHINA))) {
        // 使用中文界面
        // session.setAttribute(ADMIN_PAGE_LOCALE,
        // session.getAttribute(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE));
        session.setAttribute(I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE, Locale.CHINA);
        logger.debug("because access page is admin page. Language is set to Chinese. from IP <"
                + request.getRemoteAddr() + ">");
    }
    return invocation.invoke();
}
 
Example 14
Project: simple-keyboard   File: LanguageOnSpacebarUtils.java   View Source Code Vote up 5 votes
public static void onSubtypeChanged(@NonNull final RichInputMethodSubtype subtype,
       final boolean implicitlyEnabledSubtype, @NonNull final Locale systemLocale) {
    final Locale newLocale = subtype.getLocale();
    if (systemLocale.equals(newLocale)) {
        sIsSystemLanguageSameAsInputLanguage = true;
        return;
    }
    if (!systemLocale.getLanguage().equals(newLocale.getLanguage())) {
        sIsSystemLanguageSameAsInputLanguage = false;
        return;
    }
    // If the subtype is enabled explicitly, the language name should be displayed even when
    // the keyboard language and the system language are equal.
    sIsSystemLanguageSameAsInputLanguage = implicitlyEnabledSubtype;
}
 
Example 15
Project: apache-tomcat-7.0.73-with-comment   File: StringManager.java   View Source Code Vote up 5 votes
/**
 * Creates a new StringManager for a given package. This is a
 * private method and all access to it is arbitrated by the
 * static getManager method call so that only one StringManager
 * per package will be created.
 *
 * @param packageName Name of package to create StringManager for.
 */
private StringManager(String packageName, Locale locale) {
    String bundleName = packageName + ".LocalStrings";
    ResourceBundle bnd = null;
    try {
        bnd = ResourceBundle.getBundle(bundleName, locale);
    } catch (MissingResourceException ex) {
        // Try from the current loader (that's the case for trusted apps)
        // Should only be required if using a TC5 style classloader structure
        // where common != shared != server
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        if (cl != null) {
            try {
                bnd = ResourceBundle.getBundle(bundleName, locale, cl);
            } catch (MissingResourceException ex2) {
                // Ignore
            }
        }
    }
    bundle = bnd;
    // Get the actual locale, which may be different from the requested one
    if (bundle != null) {
        Locale bundleLocale = bundle.getLocale();
        if (bundleLocale.equals(Locale.ROOT)) {
            this.locale = Locale.ENGLISH;
        } else {
            this.locale = bundleLocale;
        }
    } else {
        this.locale = null;
    }
}
 
Example 16
Project: AOSP-Kayboard-7.1.2   File: SubtypeLocaleUtils.java   View Source Code Vote up 5 votes
@Nonnull
private static String getSubtypeLocaleDisplayNameInternal(@Nonnull final String localeString,
        @Nonnull final Locale displayLocale) {
    if (NO_LANGUAGE.equals(localeString)) {
        // No language subtype should be displayed in system locale.
        return sResources.getString(R.string.subtype_no_language);
    }
    final Integer exceptionalNameResId;
    if (displayLocale.equals(Locale.ROOT)
            && sExceptionalLocaleDisplayedInRootLocale.containsKey(localeString)) {
        exceptionalNameResId = sExceptionalLocaleDisplayedInRootLocale.get(localeString);
    } else if (sExceptionalLocaleToNameIdsMap.containsKey(localeString)) {
        exceptionalNameResId = sExceptionalLocaleToNameIdsMap.get(localeString);
    } else {
        exceptionalNameResId = null;
    }

    final String displayName;
    if (exceptionalNameResId != null) {
        final RunInLocale<String> getExceptionalName = new RunInLocale<String>() {
            @Override
            protected String job(final Resources res) {
                return res.getString(exceptionalNameResId);
            }
        };
        displayName = getExceptionalName.runInLocale(sResources, displayLocale);
    } else {
        displayName = LocaleUtils.constructLocaleFromString(localeString)
                .getDisplayName(displayLocale);
    }
    return StringUtils.capitalizeFirstCodePoint(displayName, displayLocale);
}
 
Example 17
Project: openjdk-jdk10   File: LocaleTest.java   View Source Code Vote up 5 votes
public void TestSimpleObjectStuff() {
    Locale test1 = new Locale("aa", "AA");
    Locale test2 = new Locale("aa", "AA");
    Locale test3 = (Locale) test1.clone();
    Locale test4 = new Locale("zz", "ZZ");

    if (test1 == test2 || test1 == test3 || test1 == test4 || test2 == test3) {
        errln("Some of the test variables point to the same locale!");
    }

    if (test3 == null) {
        errln("clone() failed to produce a valid object!");
    }

    if (!test1.equals(test2) || !test1.equals(test3) || !test2.equals(test3)) {
        errln("clone() or equals() failed: objects that should compare equal don't");
    }

    if (test1.equals(test4) || test2.equals(test4) || test3.equals(test4)) {
        errln("equals() failed: objects that shouldn't compare equal do");
    }

    int hash1 = test1.hashCode();
    int hash2 = test2.hashCode();
    int hash3 = test3.hashCode();

    if (hash1 != hash2 || hash1 != hash3 || hash2 != hash3) {
        errln("hashCode() failed: objects that should have the same hash code don't");
    }
}
 
Example 18
Project: OpenJSharp   File: ImageWriter.java   View Source Code Vote up 4 votes
/**
 * Sets the current <code>Locale</code> of this
 * <code>ImageWriter</code> to the given value.  A value of
 * <code>null</code> removes any previous setting, and indicates
 * that the writer should localize as it sees fit.
 *
 * <p> The default implementation checks <code>locale</code>
 * against the values returned by
 * <code>getAvailableLocales</code>, and sets the
 * <code>locale</code> instance variable if it is found.  If
 * <code>locale</code> is <code>null</code>, the instance variable
 * is set to <code>null</code> without any checking.
 *
 * @param locale the desired <code>Locale</code>, or
 * <code>null</code>.
 *
 * @exception IllegalArgumentException if <code>locale</code> is
 * non-<code>null</code> but is not one of the values returned by
 * <code>getAvailableLocales</code>.
 *
 * @see #getLocale
 */
public void setLocale(Locale locale) {
    if (locale != null) {
        Locale[] locales = getAvailableLocales();
        boolean found = false;
        if (locales != null) {
            for (int i = 0; i < locales.length; i++) {
                if (locale.equals(locales[i])) {
                    found = true;
                    break;
                }
            }
        }
        if (!found) {
            throw new IllegalArgumentException("Invalid locale!");
        }
    }
    this.locale = locale;
}
 
Example 19
Project: jdk8u-jdk   File: SunFontManager.java   View Source Code Vote up 4 votes
/**
 * Get a list of installed fonts in the requested {@link Locale}.
 * The list contains the fonts Family Names.
 * If Locale is null, the default locale is used.
 *
 * @param requestedLocale, if null the default locale is used.
 * @return list of installed fonts in the system.
 */
public String[] getInstalledFontFamilyNames(Locale requestedLocale) {
    if (requestedLocale == null) {
        requestedLocale = Locale.getDefault();
    }
    if (allFamilies != null && lastDefaultLocale != null &&
        requestedLocale.equals(lastDefaultLocale)) {
            String[] copyFamilies = new String[allFamilies.length];
            System.arraycopy(allFamilies, 0, copyFamilies,
                             0, allFamilies.length);
            return copyFamilies;
    }

    TreeMap<String,String> familyNames = new TreeMap<String,String>();
    //  these names are always there and aren't localised
    String str;
    str = Font.SERIF;         familyNames.put(str.toLowerCase(), str);
    str = Font.SANS_SERIF;    familyNames.put(str.toLowerCase(), str);
    str = Font.MONOSPACED;    familyNames.put(str.toLowerCase(), str);
    str = Font.DIALOG;        familyNames.put(str.toLowerCase(), str);
    str = Font.DIALOG_INPUT;  familyNames.put(str.toLowerCase(), str);

    /* Platform APIs may be used to get the set of available family
     * names for the current default locale so long as it is the same
     * as the start-up system locale, rather than loading all fonts.
     */
    if (requestedLocale.equals(getSystemStartupLocale()) &&
        getFamilyNamesFromPlatform(familyNames, requestedLocale)) {
        /* Augment platform names with JRE font family names */
        getJREFontFamilyNames(familyNames, requestedLocale);
    } else {
        loadFontFiles();
        Font2D[] physicalfonts = getPhysicalFonts();
        for (int i=0; i < physicalfonts.length; i++) {
            if (!(physicalfonts[i] instanceof NativeFont)) {
                String name =
                    physicalfonts[i].getFamilyName(requestedLocale);
                familyNames.put(name.toLowerCase(requestedLocale), name);
            }
        }
    }

    // Add any native font family names here
    addNativeFontFamilyNames(familyNames, requestedLocale);

    String[] retval =  new String[familyNames.size()];
    Object [] keyNames = familyNames.keySet().toArray();
    for (int i=0; i < keyNames.length; i++) {
        retval[i] = (String)familyNames.get(keyNames[i]);
    }
    if (requestedLocale.equals(Locale.getDefault())) {
        lastDefaultLocale = requestedLocale;
        allFamilies = new String[retval.length];
        System.arraycopy(retval, 0, allFamilies, 0, allFamilies.length);
    }
    return retval;
}
 
Example 20
Project: OpenJSharp   File: LocaleServiceProvider.java   View Source Code Vote up 3 votes
/**
     * Returns {@code true} if the given {@code locale} is supported by
     * this locale service provider. The given {@code locale} may contain
     * <a href="../Locale.html#def_extensions">extensions</a> that should be
     * taken into account for the support determination.
     *
     * <p>The default implementation returns {@code true} if the given {@code locale}
     * is equal to any of the available {@code Locale}s returned by
     * {@link #getAvailableLocales()} with ignoring any extensions in both the
     * given {@code locale} and the available locales. Concrete locale service
     * provider implementations should override this method if those
     * implementations are {@code Locale} extensions-aware. For example,
     * {@code DecimalFormatSymbolsProvider} implementations will need to check
     * extensions in the given {@code locale} to see if any numbering system is
     * specified and can be supported. However, {@code CollatorProvider}
     * implementations may not be affected by any particular numbering systems,
     * and in that case, extensions for numbering systems should be ignored.
     *
     * @param locale a {@code Locale} to be tested
     * @return {@code true} if the given {@code locale} is supported by this
     *         provider; {@code false} otherwise.
     * @throws NullPointerException
     *         if the given {@code locale} is {@code null}
     * @see Locale#hasExtensions()
     * @see Locale#stripExtensions()
     * @since 1.8
     */
    public boolean isSupportedLocale(Locale locale) {
        locale = locale.stripExtensions(); // throws NPE if locale == null
        for (Locale available : getAvailableLocales()) {
            if (locale.equals(available.stripExtensions())) {
                return true;
}
        }
        return false;
    }