Package com.ibm.icu.impl.personname
Class PersonNameFormatterImpl
java.lang.Object
com.ibm.icu.impl.personname.PersonNameFormatterImpl
Actual implementation class for PersonNameFormatter.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
private final PersonNameFormatter.DisplayOrder
private final String
private final PersonNameFormatter.Formality
private final PersonNamePattern[]
private final String
private final String
private final PersonNameFormatter.Length
private final Locale
private final String
private final PersonNamePattern[]
private final PersonNameFormatter.Usage
-
Constructor Summary
ConstructorsConstructorDescriptionPersonNameFormatterImpl
(Locale locale, PersonNameFormatter.Length length, PersonNameFormatter.Usage usage, PersonNameFormatter.Formality formality, PersonNameFormatter.DisplayOrder displayOrder, boolean surnameAllCaps) PersonNameFormatterImpl
(Locale locale, String[] gnFirstPatterns, String[] snFirstPatterns, String[] gnFirstLocales, String[] snFirstLocales) THIS IS A DUMMY CONSTRUCTOR JUST FOR THE USE OF THE UNIT TESTS TO CHECK SOME OF THE INTERNAL IMPLEMENTATION! -
Method Summary
Modifier and TypeMethodDescriptionprivate String[]
asStringArray
(ICUResourceBundle resource) Returns the value of the resource, as a string array.private boolean
formattingLocaleExists
(Locale formattingLocale) Returns true if there's actual name formatting data for the specified locale (i.e., when we fetch the resource data, we don't fall back to root).formatToString
(PersonName name) private PersonNamePattern
getBestPattern
(PersonNamePattern[] patterns, PersonName name) private Locale
getNameLocale
(PersonName name) Internal function to figure out the name's locale when the name doesn't specify it.private String
getNameScript
(PersonName name) Internal function to figure out the name's script by examining its characters.boolean
getUsage()
private boolean
localesMatch
(Locale nameLocale, Locale formatterLocale) Returns true if the two locales should be considered equivalent for space-replacement purposes.private boolean
nameIsGnFirst
(PersonName name) Returns the field order to use when formatting this name, taking into account the name's preferredOrder field, as well as the name and formatter's respective locales.private boolean
nameScriptMatchesLocale
(String nameScriptID, Locale formatterLocale) Returns true if the characters in the name match one of the scripts for the specified locale.private Locale
newLocaleWithScript
(Locale oldLocale, String scriptCode, String regionCode) boolean
toString()
-
Field Details
-
locale
-
gnFirstPatterns
-
snFirstPatterns
-
gnFirstLocales
-
snFirstLocales
-
initialPattern
-
initialSequencePattern
-
capitalizeSurname
private final boolean capitalizeSurname -
foreignSpaceReplacement
-
nativeSpaceReplacement
-
length
-
usage
-
formality
-
displayOrder
-
NON_DEFAULT_SCRIPTS
-
-
Constructor Details
-
PersonNameFormatterImpl
public PersonNameFormatterImpl(Locale locale, PersonNameFormatter.Length length, PersonNameFormatter.Usage usage, PersonNameFormatter.Formality formality, PersonNameFormatter.DisplayOrder displayOrder, boolean surnameAllCaps) -
PersonNameFormatterImpl
public PersonNameFormatterImpl(Locale locale, String[] gnFirstPatterns, String[] snFirstPatterns, String[] gnFirstLocales, String[] snFirstLocales) THIS IS A DUMMY CONSTRUCTOR JUST FOR THE USE OF THE UNIT TESTS TO CHECK SOME OF THE INTERNAL IMPLEMENTATION!
-
-
Method Details
-
toString
-
formatToString
-
getLocale
-
getLength
-
getUsage
-
getFormality
-
getDisplayOrder
-
getSurnameAllCaps
public boolean getSurnameAllCaps() -
getInitialPattern
-
getInitialSequencePattern
-
shouldCapitalizeSurname
public boolean shouldCapitalizeSurname() -
asStringArray
Returns the value of the resource, as a string array.- Parameters:
resource
- An ICUResourceBundle of type STRING or ARRAY. If ARRAY, this function just returns it as a string array. If STRING, it returns a one-element array containing that string.- Returns:
- The resource's value, as an array of Strings.
-
nameIsGnFirst
Returns the field order to use when formatting this name, taking into account the name's preferredOrder field, as well as the name and formatter's respective locales.- Parameters:
name
- The name to be formatted.- Returns:
- If true, use given-first order to format the name; if false, use surname-first order.
-
getBestPattern
-
getNameScript
Internal function to figure out the name's script by examining its characters.- Parameters:
name
- The name for which we need the script- Returns:
- The four-letter script code for the name.
-
newLocaleWithScript
-
getNameLocale
Internal function to figure out the name's locale when the name doesn't specify it. (Note that this code assumes that if the locale is specified, it includes a language code.)- Parameters:
name
- The name for which we need the locale- Returns:
- The name's (real or guessed) locale.
-
nameScriptMatchesLocale
Returns true if the characters in the name match one of the scripts for the specified locale. -
formattingLocaleExists
Returns true if there's actual name formatting data for the specified locale (i.e., when we fetch the resource data, we don't fall back to root). -
localesMatch
Returns true if the two locales should be considered equivalent for space-replacement purposes.
-