Package com.ibm.icu.text
Class PersonNameFormatter
- java.lang.Object
-
- com.ibm.icu.text.PersonNameFormatter
-
public class PersonNameFormatter extends java.lang.Object
A class for formatting names of people. Takes raw name data for a person and renders it into a string according to the caller's specifications, taking into account how people's names are rendered in the caller's locale. The Length, Usage, and Formality options can be used to get a wide variety of results. In English, they would produce results along these lines:REFERRING ADDRESSING MONOGRAM FORMAL INFORMAL FORMAL INFORMAL FORMAL INFORMAL LONG James Earl Carter Jr. Jimmy Carter Mr. Carter Jimmy JEC JC MEDIUM James E. Carter Jr. Jimmy Carter Mr. Carter Jimmy C J SHORT J. E. Carter Jimmy Carter Mr. Carter Jimmy C J
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PersonNameFormatter.Builder
A utility class that can be used to construct a PersonNameFormatter.static class
PersonNameFormatter.DisplayOrder
An enum indicating the desired display order for a formatted name.static class
PersonNameFormatter.Formality
Specifies the intended formality of the formatted name.static class
PersonNameFormatter.Length
Specifies the desired length of the formatted name.static class
PersonNameFormatter.Usage
Specifies the intended usage of the formatted name.
-
Field Summary
Fields Modifier and Type Field Description private PersonNameFormatterImpl
impl
-
Constructor Summary
Constructors Modifier Constructor Description private
PersonNameFormatter(java.util.Locale locale, PersonNameFormatter.Length length, PersonNameFormatter.Usage usage, PersonNameFormatter.Formality formality, PersonNameFormatter.DisplayOrder displayOrder, boolean surnameAllCaps)
PersonNameFormatter(java.util.Locale locale, java.lang.String[] gnFirstPatterns, java.lang.String[] snFirstPatterns, java.lang.String[] gnFirstLocales, java.lang.String[] snFirstLocales)
Deprecated.This API is for unit testing only.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static PersonNameFormatter.Builder
builder()
Returns a Builder object that can be used to construct a new PersonNameFormatter.java.lang.String
formatToString(PersonName name)
Formats a name.PersonNameFormatter.Builder
toBuilder()
Returns a Builder object whose fields match those used to construct this formatter, allowing a new formatter to be created based on this one.java.lang.String
toString()
Deprecated.This API is for debugging only.
-
-
-
Field Detail
-
impl
private final PersonNameFormatterImpl impl
-
-
Constructor Detail
-
PersonNameFormatter
private PersonNameFormatter(java.util.Locale locale, PersonNameFormatter.Length length, PersonNameFormatter.Usage usage, PersonNameFormatter.Formality formality, PersonNameFormatter.DisplayOrder displayOrder, boolean surnameAllCaps)
-
PersonNameFormatter
@Deprecated public PersonNameFormatter(java.util.Locale locale, java.lang.String[] gnFirstPatterns, java.lang.String[] snFirstPatterns, java.lang.String[] gnFirstLocales, java.lang.String[] snFirstLocales)
Deprecated.This API is for unit testing only.
-
-
Method Detail
-
builder
public static PersonNameFormatter.Builder builder()
Returns a Builder object that can be used to construct a new PersonNameFormatter.- Returns:
- A new Builder.
-
toBuilder
public PersonNameFormatter.Builder toBuilder()
Returns a Builder object whose fields match those used to construct this formatter, allowing a new formatter to be created based on this one.- Returns:
- A new Builder that can be used to create a new formatter based on this formatter.
-
formatToString
public java.lang.String formatToString(PersonName name)
Formats a name.- Parameters:
name
- A PersonName object that supplies individual field values (optionally, with modifiers applied) to the formatter for formatting.- Returns:
- The name, formatted according to the locale and other parameters passed to the formatter's constructor.
-
toString
@Deprecated public java.lang.String toString()
Deprecated.This API is for debugging only.- Overrides:
toString
in classjava.lang.Object
-
-