Top Description Fields Constructors Methods
com.ibm.icu.impl.personname

public Class PersonNameFormatterImpl

extends Object
Class Inheritance
Static Imports
com.ibm.icu.util.UResourceBundle.ARRAY, .UResourceBundle.STRING

Actual implementation class for PersonNameFormatter.

Field Summary

Modifier and TypeField and Description
private final boolean
private final PersonNameFormatter.DisplayOrder
private final String
private final PersonNameFormatter.Formality
private final Set<String>
private final PersonNamePattern[]
private final String
private final String
private final PersonNameFormatter.Length
private final Locale
private final String
pack-priv static final Set<String>
private final Set<String>
private final PersonNamePattern[]
private final PersonNameFormatter.Usage

Constructor Summary

AccessConstructor and Description
public
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 Summary

Modifier and TypeMethod and Description
private String[]

Returns:

The resource's value, as an array of Strings.
asStringArray
(ICUResourceBundle
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.
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).

public String
private PersonNamePattern
public PersonNameFormatter.DisplayOrder
public PersonNameFormatter.Formality
public String
public String
public PersonNameFormatter.Length
public Locale
private Locale

Returns:

The name's (real or guessed) locale.
getNameLocale
(PersonName
The name for which we need the locale
name
)

Internal function to figure out the name's locale when the name doesn't specify it.

private String

Returns:

The four-letter script code for the name.
getNameScript
(PersonName
The name for which we need the script
name
)

Internal function to figure out the name's script by examining its characters.

public boolean
public PersonNameFormatter.Usage
private boolean
localesMatch(Locale nameLocale, Locale formatterLocale)

Returns true if the two locales should be considered equivalent for space-replacement purposes.

private boolean

Returns:

If true, use given-first order to format the name; if false, use surname-first order.
nameIsGnFirst
(PersonName
The name to be formatted.
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)

public boolean
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

capitalizeSurnameback to summary
private final boolean capitalizeSurname
displayOrderback to summary
private final PersonNameFormatter.DisplayOrder displayOrder
foreignSpaceReplacementback to summary
private final String foreignSpaceReplacement
formalityback to summary
private final PersonNameFormatter.Formality formality
gnFirstLocalesback to summary
private final Set<String> gnFirstLocales
gnFirstPatternsback to summary
private final PersonNamePattern[] gnFirstPatterns
initialPatternback to summary
private final String initialPattern
initialSequencePatternback to summary
private final String initialSequencePattern
lengthback to summary
private final PersonNameFormatter.Length length
localeback to summary
private final Locale locale
nativeSpaceReplacementback to summary
private final String nativeSpaceReplacement
NON_DEFAULT_SCRIPTSback to summary
pack-priv static final Set<String> NON_DEFAULT_SCRIPTS
snFirstLocalesback to summary
private final Set<String> snFirstLocales
snFirstPatternsback to summary
private final PersonNamePattern[] snFirstPatterns
usageback to summary
private final PersonNameFormatter.Usage usage

Constructor Detail

PersonNameFormatterImplback to summary
public PersonNameFormatterImpl(Locale locale, PersonNameFormatter.Length length, PersonNameFormatter.Usage usage, PersonNameFormatter.Formality formality, PersonNameFormatter.DisplayOrder displayOrder, boolean surnameAllCaps)
PersonNameFormatterImplback to summary
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 Detail

asStringArrayback to summary
private String[] asStringArray(ICUResourceBundle resource)

Returns the value of the resource, as a string array.

Parameters
resource:ICUResourceBundle

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:String[]

The resource's value, as an array of Strings.

formattingLocaleExistsback to summary
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).

formatToStringback to summary
public String formatToString(PersonName name)
getBestPatternback to summary
private PersonNamePattern getBestPattern(PersonNamePattern[] patterns, PersonName name)
getDisplayOrderback to summary
public PersonNameFormatter.DisplayOrder getDisplayOrder()
getFormalityback to summary
public PersonNameFormatter.Formality getFormality()
getInitialPatternback to summary
public String getInitialPattern()
getInitialSequencePatternback to summary
public String getInitialSequencePattern()
getLengthback to summary
public PersonNameFormatter.Length getLength()
getLocaleback to summary
public Locale getLocale()
getNameLocaleback to summary
private Locale getNameLocale(PersonName name)

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:PersonName

The name for which we need the locale

Returns:Locale

The name's (real or guessed) locale.

getNameScriptback to summary
private String getNameScript(PersonName name)

Internal function to figure out the name's script by examining its characters.

Parameters
name:PersonName

The name for which we need the script

Returns:String

The four-letter script code for the name.

getSurnameAllCapsback to summary
public boolean getSurnameAllCaps()
getUsageback to summary
public PersonNameFormatter.Usage getUsage()
localesMatchback to summary
private boolean localesMatch(Locale nameLocale, Locale formatterLocale)

Returns true if the two locales should be considered equivalent for space-replacement purposes.

nameIsGnFirstback to summary
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.

Parameters
name:PersonName

The name to be formatted.

Returns:boolean

If true, use given-first order to format the name; if false, use surname-first order.

nameScriptMatchesLocaleback to summary
private boolean nameScriptMatchesLocale(String nameScriptID, Locale formatterLocale)

Returns true if the characters in the name match one of the scripts for the specified locale.

newLocaleWithScriptback to summary
private Locale newLocaleWithScript(Locale oldLocale, String scriptCode, String regionCode)
shouldCapitalizeSurnameback to summary
public boolean shouldCapitalizeSurname()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override