Package com.ibm.icu.text
Class PersonNameFormatter.Builder
- java.lang.Object
-
- com.ibm.icu.text.PersonNameFormatter.Builder
-
- Enclosing class:
- PersonNameFormatter
public static class PersonNameFormatter.Builder extends java.lang.Object
A utility class that can be used to construct a PersonNameFormatter. Use PersonNameFormatter.builder() to get a new instance.
-
-
Field Summary
Fields Modifier and Type Field Description private PersonNameFormatter.DisplayOrder
displayOrder
private PersonNameFormatter.Formality
formality
private PersonNameFormatter.Length
length
private java.util.Locale
locale
private boolean
surnameAllCaps
private PersonNameFormatter.Usage
usage
-
Constructor Summary
Constructors Modifier Constructor Description private
Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PersonNameFormatter
build()
Returns a new PersonNameFormatter with the values that were passed to this builder.PersonNameFormatter.Builder
setDisplayOrder(PersonNameFormatter.DisplayOrder order)
Specifies the desired display order for the formatted names.PersonNameFormatter.Builder
setFormality(PersonNameFormatter.Formality formality)
Sets the name formality for the formatter to be constructed.PersonNameFormatter.Builder
setLength(PersonNameFormatter.Length length)
Sets the name length for the formatter to be constructed.PersonNameFormatter.Builder
setLocale(java.util.Locale locale)
Sets the locale for the formatter to be constructed.PersonNameFormatter.Builder
setSurnameAllCaps(boolean allCaps)
Requests that the surname in the formatted result be rendered in ALL CAPS.PersonNameFormatter.Builder
setUsage(PersonNameFormatter.Usage usage)
Sets the name usage for the formatter to be constructed.
-
-
-
Field Detail
-
locale
private java.util.Locale locale
-
length
private PersonNameFormatter.Length length
-
usage
private PersonNameFormatter.Usage usage
-
formality
private PersonNameFormatter.Formality formality
-
displayOrder
private PersonNameFormatter.DisplayOrder displayOrder
-
surnameAllCaps
private boolean surnameAllCaps
-
-
Method Detail
-
setLocale
public PersonNameFormatter.Builder setLocale(java.util.Locale locale)
Sets the locale for the formatter to be constructed.- Parameters:
locale
- The new formatter locale. May not be null.- Returns:
- This builder.
-
setLength
public PersonNameFormatter.Builder setLength(PersonNameFormatter.Length length)
Sets the name length for the formatter to be constructed.- Parameters:
length
- The new name length.- Returns:
- This builder.
-
setUsage
public PersonNameFormatter.Builder setUsage(PersonNameFormatter.Usage usage)
Sets the name usage for the formatter to be constructed.- Parameters:
usage
- The new name length.- Returns:
- This builder.
-
setFormality
public PersonNameFormatter.Builder setFormality(PersonNameFormatter.Formality formality)
Sets the name formality for the formatter to be constructed.- Parameters:
formality
- The new name length.- Returns:
- This builder.
-
setDisplayOrder
public PersonNameFormatter.Builder setDisplayOrder(PersonNameFormatter.DisplayOrder order)
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
public PersonNameFormatter.Builder setSurnameAllCaps(boolean allCaps)
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
public PersonNameFormatter 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.
-
-