/** * Returns a list of locales for which BreakIterators can be used. * @return An array of Locales. All of the locales in the array can * be used when creating a BreakIterator. * @stable ICU 2.6 */ public static synchronized Locale[] getAvailableLocales() { // to avoid linking ICULocaleData return getShim().getAvailableLocales(); }
/** * {@icu} Returns a list of locales for which BreakIterators can be used. * @return An array of Locales. All of the locales in the array can * be used when creating a BreakIterator. * @draft ICU 3.2 (retain) * @provisional This API might change or be removed in a future release. */ public static synchronized ULocale[] getAvailableULocales() { // to avoid linking ICULocaleData return getShim().getAvailableULocales(); }
/** * {@icu} Registers a new break iterator of the indicated kind, to use in the given * locale. Clones of the iterator will be returned if a request for a break iterator * of the given kind matches or falls back to this locale. * * <p>Because ICU may choose to cache BreakIterator objects internally, this must * be called at application startup, prior to any calls to * BreakIterator.getInstance to avoid undefined behavior. * * @param iter the BreakIterator instance to adopt. * @param locale the Locale for which this instance is to be registered * @param kind the type of iterator for which this instance is to be registered * @return a registry key that can be used to unregister this instance * @stable ICU 3.2 */ public static Object registerInstance(BreakIterator iter, ULocale locale, int kind) { // If the registered object matches the one in the cache, then // flush the cached object. if (iterCache[kind] != null) { BreakIteratorCache cache = (BreakIteratorCache) iterCache[kind].get(); if (cache != null) { if (cache.getLocale().equals(locale)) { iterCache[kind] = null; } } } return getShim().registerInstance(iter, locale, kind); }
/** * Returns a particular kind of BreakIterator for a locale. * Avoids writing a switch statement with getXYZInstance(where) calls. * @internal * @deprecated This API is ICU internal only. */ @Deprecated public static BreakIterator getBreakInstance(ULocale where, int kind) { if (where == null) { throw new NullPointerException("Specified locale is null"); } if (iterCache[kind] != null) { BreakIteratorCache cache = (BreakIteratorCache)iterCache[kind].get(); if (cache != null) { if (cache.getLocale().equals(where)) { return cache.createBreakInstance(); } } } // sigh, all to avoid linking in ICULocaleData... BreakIterator result = getShim().createBreakIterator(where, kind); BreakIteratorCache cache = new BreakIteratorCache(where, result); iterCache[kind] = CacheValue.getInstance(cache); if (result instanceof RuleBasedBreakIterator) { RuleBasedBreakIterator rbbi = (RuleBasedBreakIterator)result; rbbi.setBreakType(kind); } return result; }