Class PersonNameFormatterImpl

java.lang.Object
com.ibm.icu.impl.personname.PersonNameFormatterImpl

public class PersonNameFormatterImpl extends Object
Actual implementation class for PersonNameFormatter.
  • Field Details

  • Constructor Details

  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • formatToString

      public String formatToString(PersonName name)
    • getLocale

      public Locale getLocale()
    • getLength

      public PersonNameFormatter.Length getLength()
    • getUsage

      public PersonNameFormatter.Usage getUsage()
    • getFormality

      public PersonNameFormatter.Formality getFormality()
    • getDisplayOrder

      public PersonNameFormatter.DisplayOrder getDisplayOrder()
    • getSurnameAllCaps

      public boolean getSurnameAllCaps()
    • getInitialPattern

      public String getInitialPattern()
    • getInitialSequencePattern

      public String getInitialSequencePattern()
    • shouldCapitalizeSurname

      public boolean shouldCapitalizeSurname()
    • asStringArray

      private String[] asStringArray(ICUResourceBundle resource)
      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

      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 - The name to be formatted.
      Returns:
      If true, use given-first order to format the name; if false, use surname-first order.
    • getBestPattern

      private PersonNamePattern getBestPattern(PersonNamePattern[] patterns, PersonName name)
    • getNameScript

      private String getNameScript(PersonName name)
      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

      private Locale newLocaleWithScript(Locale oldLocale, String scriptCode, String regionCode)
    • getNameLocale

      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 - The name for which we need the locale
      Returns:
      The name's (real or guessed) locale.
    • nameScriptMatchesLocale

      private boolean nameScriptMatchesLocale(String nameScriptID, Locale formatterLocale)
      Returns true if the characters in the name match one of the scripts for the specified locale.
    • formattingLocaleExists

      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).
    • localesMatch

      private boolean localesMatch(Locale nameLocale, Locale formatterLocale)
      Returns true if the two locales should be considered equivalent for space-replacement purposes.