public final class LocaleUtils extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
LocaleUtils.LocaleExtractor<T> |
Constructor and Description |
---|
LocaleUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> void |
filterByLanguage(List<T> sources,
LocaleUtils.LocaleExtractor<T> extractor,
LocaleList preferredLanguages,
ArrayList<T> dest)
Filters the given items based on language preferences.
|
public static <T> void filterByLanguage(List<T> sources, LocaleUtils.LocaleExtractor<T> extractor, LocaleList preferredLanguages, ArrayList<T> dest)
For each language found in preferredLanguages
, this method tries to copy at most
one best-match item from source
to dest
. For example, if
"en-GB", "ja", "en-AU", "fr-CA", "en-IN"
is specified to preferredLanguages
,
this method tries to copy at most one English locale, at most one Japanese, and at most one
French locale from source
to dest
. Here the best matching English locale
will be searched from source
based on matching score. For the score design, see
calculateMatchingScore(ULocale, LocaleList, byte[])
T
- Type of the data items.sources
- Source items to be filtered.extractor
- Type converter from the source items to Locale
object.preferredLanguages
- Ordered list of locales with which the input items will be
filtered.dest
- Destination into which the filtered items will be added.