Package com.ibm.icu.util
Class LocalePriorityList.Builder
java.lang.Object
com.ibm.icu.util.LocalePriorityList.Builder
- Enclosing class:
LocalePriorityList
Class used for building LocalePriorityLists.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate LocalePriorityList
The builder is reusable but rarely reused.private boolean
These store the input languages and weights, in chronological order, where later additions override previous ones. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Builder()
Private constructor, only used by LocalePriorityListprivate
Builder
(LocalePriorityList list) -
Method Summary
Modifier and TypeMethodDescriptionadd
(LocalePriorityList list) Adds locales with weights.Adds a locale with weight 1.0.Adds locales, each with weight 1.0.Adds a locale with a specified weight.Parses the RFC 2616 string, and adds locales with weights accordingly.build()
Creates a LocalePriorityList.build
(boolean preserveWeights) Creates a LocalePriorityList.
-
Field Details
-
languageToWeight
These store the input languages and weights, in chronological order, where later additions override previous ones. -
built
The builder is reusable but rarely reused. Avoid cloning the map when not needed. Exactly one of languageToWeight and built is null. -
hasWeights
private boolean hasWeights
-
-
Constructor Details
-
Builder
private Builder()Private constructor, only used by LocalePriorityList -
Builder
-
-
Method Details
-
build
Creates a LocalePriorityList. This is equivalent toBuilder.build(false)
.- Returns:
- A LocalePriorityList
-
build
Creates a LocalePriorityList.- Parameters:
preserveWeights
- when true, each locale's given weight is preserved.- Returns:
- A LocalePriorityList
-
add
Adds locales with weights.- Parameters:
list
- list of locales with weights- Returns:
- this, for chaining
-
add
Adds a locale with weight 1.0.- Parameters:
locale
- to add with weight 1.0- Returns:
- this, for chaining
-
add
Adds locales, each with weight 1.0.- Parameters:
locales
- locales/languages to be added- Returns:
- this, for chaining.
-
add
Adds a locale with a specified weight. Overrides any previous weight for the locale. A zero or negative weight leads to removing the locale. A weight greater than 1 is pinned to 1.- Parameters:
locale
- language/locale to addweight
- value between 0.0 and 1.1- Returns:
- this, for chaining.
-
add
Parses the RFC 2616 string, and adds locales with weights accordingly.- Parameters:
acceptLanguageList
- in RFC 2616 format (leniently parsed)- Returns:
- this, for chaining.
-