public static final class LocaleMatcher.Builder extends Object
LocaleMatcher.builder()
Modifier and Type | Method and Description |
---|---|
LocaleMatcher.Builder |
addSupportedLocale(Locale locale)
Adds another supported locale.
|
LocaleMatcher.Builder |
addSupportedULocale(ULocale locale)
Adds another supported locale.
|
LocaleMatcher |
build()
Builds and returns a new locale matcher.
|
LocaleMatcher.Builder |
internalSetThresholdDistance(int thresholdDistance)
Deprecated.
This API is ICU internal only.
|
LocaleMatcher.Builder |
setDefaultLocale(Locale defaultLocale)
Sets the default locale; if null, or if it is not set explicitly,
then the first supported locale is used as the default locale.
|
LocaleMatcher.Builder |
setDefaultULocale(ULocale defaultLocale)
Sets the default locale; if null, or if it is not set explicitly,
then the first supported locale is used as the default locale.
|
LocaleMatcher.Builder |
setDemotionPerDesiredLocale(LocaleMatcher.Demotion demotion)
Option for whether all desired locales are treated equally or
earlier ones are preferred (this is the default).
|
LocaleMatcher.Builder |
setDirection(LocaleMatcher.Direction direction)
Option for whether to include or ignore one-way (fallback) match data.
|
LocaleMatcher.Builder |
setFavorSubtag(LocaleMatcher.FavorSubtag subtag)
If SCRIPT, then the language differences are smaller than script differences.
|
LocaleMatcher.Builder |
setMaxDistance(Locale desired,
Locale supported)
Sets the maximum distance for an acceptable match.
|
LocaleMatcher.Builder |
setMaxDistance(ULocale desired,
ULocale supported)
Sets the maximum distance for an acceptable match.
|
LocaleMatcher.Builder |
setNoDefaultLocale()
Sets no default locale.
|
LocaleMatcher.Builder |
setSupportedLocales(Collection<Locale> locales)
Copies the supported locales, preserving iteration order.
|
LocaleMatcher.Builder |
setSupportedLocales(String locales)
Parses the string like
LocalePriorityList does and
sets the supported locales accordingly. |
LocaleMatcher.Builder |
setSupportedULocales(Collection<ULocale> locales)
Copies the supported locales, preserving iteration order.
|
String |
toString() |
public LocaleMatcher.Builder setSupportedLocales(String locales)
LocalePriorityList
does and
sets the supported locales accordingly.
Clears any previously set/added supported locales first.locales
- the string of locales to set, to be parsed like LocalePriorityList doespublic LocaleMatcher.Builder setSupportedULocales(Collection<ULocale> locales)
locales
- the list of localespublic LocaleMatcher.Builder setSupportedLocales(Collection<Locale> locales)
locales
- the list of localepublic LocaleMatcher.Builder addSupportedULocale(ULocale locale)
locale
- another localepublic LocaleMatcher.Builder addSupportedLocale(Locale locale)
locale
- another localepublic LocaleMatcher.Builder setNoDefaultLocale()
public LocaleMatcher.Builder setDefaultULocale(ULocale defaultLocale)
setNoDefaultLocale()
is called.defaultLocale
- the default localepublic LocaleMatcher.Builder setDefaultLocale(Locale defaultLocale)
setNoDefaultLocale()
is called.defaultLocale
- the default localepublic LocaleMatcher.Builder setFavorSubtag(LocaleMatcher.FavorSubtag subtag)
subtag
- the subtag to favorpublic LocaleMatcher.Builder setDemotionPerDesiredLocale(LocaleMatcher.Demotion demotion)
demotion
- the demotion per desired locale to set.public LocaleMatcher.Builder setDirection(LocaleMatcher.Direction direction)
direction
- the match direction to set.public LocaleMatcher.Builder setMaxDistance(Locale desired, Locale supported)
For example, setMaxDistance(en-US, en-GB) limits matches to ones where the (desired, support) locales have a distance no greater than a region subtag difference. This is much stricter than the CLDR default.
The details of locale matching are subject to changes in CLDR data and in the algorithm. Specifying a maximum distance in relative terms via a sample pair of locales insulates from changes that affect all distance metrics similarly, but some changes will necessarily affect relative distances between different pairs of locales.
desired
- the desired locale for distance comparison.supported
- the supported locale for distance comparison.public LocaleMatcher.Builder setMaxDistance(ULocale desired, ULocale supported)
For example, setMaxDistance(en-US, en-GB) limits matches to ones where the (desired, support) locales have a distance no greater than a region subtag difference. This is much stricter than the CLDR default.
The details of locale matching are subject to changes in CLDR data and in the algorithm. Specifying a maximum distance in relative terms via a sample pair of locales insulates from changes that affect all distance metrics similarly, but some changes will necessarily affect relative distances between different pairs of locales.
desired
- the desired locale for distance comparison.supported
- the supported locale for distance comparison.@Deprecated public LocaleMatcher.Builder internalSetThresholdDistance(int thresholdDistance)
thresholdDistance
- the thresholdDistance to set, with -1 = defaultpublic LocaleMatcher build()
Copyright © 2016 Unicode, Inc. and others.