Package com.ibm.icu.text
Class PersonNameFormatter.Builder
java.lang.Object
com.ibm.icu.text.PersonNameFormatter.Builder
- Enclosing class:
PersonNameFormatter
A utility class that can be used to construct a PersonNameFormatter.
Use PersonNameFormatter.builder() to get a new instance.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Returns a new PersonNameFormatter with the values that were passed to this builder.Specifies the desired display order for the formatted names.setFormality
(PersonNameFormatter.Formality formality) Sets the name formality for the formatter to be constructed.setLength
(PersonNameFormatter.Length length) Sets the name length for the formatter to be constructed.Sets the locale for the formatter to be constructed.setSurnameAllCaps
(boolean allCaps) Requests that the surname in the formatted result be rendered in ALL CAPS.Sets the name usage for the formatter to be constructed.
-
Method Details
-
setLocale
Sets the locale for the formatter to be constructed.- Parameters:
locale
- The new formatter locale. May not be null.- Returns:
- This builder.
-
setLength
Sets the name length for the formatter to be constructed.- Parameters:
length
- The new name length.- Returns:
- This builder.
-
setUsage
Sets the name usage for the formatter to be constructed.- Parameters:
usage
- The new name length.- Returns:
- This builder.
-
setFormality
Sets the name formality for the formatter to be constructed.- Parameters:
formality
- The new name length.- Returns:
- This builder.
-
setDisplayOrder
Specifies the desired display order for the formatted names. This can be either SORTING, which requests that names be formatted in a manner suitable for inclusion in a sorted list (e.g., in English, "Smith, John"), or DEFAULT, which gives the standard field order suitable for most contexts (e.g., in English, "John Smith").- Parameters:
order
- The desired display order for formatted names.- Returns:
- This builder.
-
setSurnameAllCaps
Requests that the surname in the formatted result be rendered in ALL CAPS. This is often done with Japanese names to highlight which name is the surname.- Parameters:
allCaps
- If true, the surname in the formatted result will be rendered in ALL CAPS.- Returns:
- This builder.
-
build
Returns a new PersonNameFormatter with the values that were passed to this builder. This method doesn't freeze or delete the builder; you can call build() more than once (presumably after calling the other methods to change the parameter) to create more than one PersonNameFormatter; you don't need a new Builder for each PersonNameFormatter.- Returns:
- A new PersonNameFormatter.
-