Package com.ibm.icu.text
Class SimplePersonName
- java.lang.Object
-
- com.ibm.icu.text.SimplePersonName
-
- All Implemented Interfaces:
PersonName
public class SimplePersonName extends java.lang.Object implements PersonName
A concrete implementation of PersonNameFormatter.PersonName that simply stores the field values in a Map. A caller can store both raw field values (such as "given") and modified field values (such as "given-informal") in a SimplePersonName. But beyond storing and returning modified field values provided to it by the caller, SimplePersonName relies on the PersonNameFormatter's default handling of field modifiers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SimplePersonName.Builder
A utility class for constructing a SimplePersonName.-
Nested classes/interfaces inherited from interface com.ibm.icu.text.PersonName
PersonName.FieldModifier, PersonName.NameField, PersonName.PreferredOrder
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.lang.String>
fieldValues
private java.util.Locale
nameLocale
private PersonName.PreferredOrder
preferredOrder
-
Constructor Summary
Constructors Modifier Constructor Description private
SimplePersonName(java.util.Locale nameLocale, PersonName.PreferredOrder preferredOrder, java.util.Map<java.lang.String,java.lang.String> fieldValues)
Internal constructor used by the Builder object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static SimplePersonName.Builder
builder()
Returns a Builder object that can be used to construct a new SimplePersonName object.java.lang.String
getFieldValue(PersonName.NameField nameField, java.util.Set<PersonName.FieldModifier> modifiers)
Returns one field of the name, possibly in a modified form.java.util.Locale
getNameLocale()
Returns the locale of the name-- that is, the language or country of origin for the person being named.PersonName.PreferredOrder
getPreferredOrder()
Returns the preferred field order for the name.private static java.lang.String
makeModifiedFieldName(PersonName.NameField fieldName, java.util.Collection<PersonName.FieldModifier> modifiers)
private static java.util.Set<PersonName.FieldModifier>
makeModifiersFromName(java.lang.String modifiedName)
java.lang.String
toString()
Deprecated.This API is ICU internal only.
-
-
-
Field Detail
-
nameLocale
private final java.util.Locale nameLocale
-
preferredOrder
private final PersonName.PreferredOrder preferredOrder
-
fieldValues
private final java.util.Map<java.lang.String,java.lang.String> fieldValues
-
-
Constructor Detail
-
SimplePersonName
private SimplePersonName(java.util.Locale nameLocale, PersonName.PreferredOrder preferredOrder, java.util.Map<java.lang.String,java.lang.String> fieldValues)
Internal constructor used by the Builder object.
-
-
Method Detail
-
builder
public static SimplePersonName.Builder builder()
Returns a Builder object that can be used to construct a new SimplePersonName object.- Returns:
- A Builder object that can be used to construct a new SimplePersonName object.
-
getNameLocale
public java.util.Locale getNameLocale()
Returns the locale of the name-- that is, the language or country of origin for the person being named.- Specified by:
getNameLocale
in interfacePersonName
- Returns:
- The name's locale, or null if it's unknown.
-
getPreferredOrder
public PersonName.PreferredOrder getPreferredOrder()
Returns the preferred field order for the name. This will be DEFAULT, unless the caller sets it to something else using the builder.- Specified by:
getPreferredOrder
in interfacePersonName
- Returns:
- The name's preferred field order.
-
getFieldValue
public java.lang.String getFieldValue(PersonName.NameField nameField, java.util.Set<PersonName.FieldModifier> modifiers)
Returns one field of the name, possibly in a modified form. This class can store modified versions of fields, provided at construction time, and this function will return them. Otherwise, it ignores modifiers and relies on PersonNameFormat's default modifier handling.- Specified by:
getFieldValue
in interfacePersonName
- Parameters:
nameField
- The identifier of the requested field.modifiers
- An IN/OUT parameter that specifies modifiers to apply to the basic field value. On return, this list will contain any modifiers that this object didn't handle. This class will always return this set unmodified, unless a modified version of the requested field was provided at construction time.- Returns:
- The value of the requested field, optionally modified by some or all of the requested modifiers, or null if the requested field isn't present in the name.
-
toString
@Deprecated public java.lang.String toString()
Deprecated.This API is ICU internal only.- Overrides:
toString
in classjava.lang.Object
-
makeModifiedFieldName
private static java.lang.String makeModifiedFieldName(PersonName.NameField fieldName, java.util.Collection<PersonName.FieldModifier> modifiers)
-
makeModifiersFromName
private static java.util.Set<PersonName.FieldModifier> makeModifiersFromName(java.lang.String modifiedName)
-
-