Package com.ibm.icu.text
Class ListFormatter
java.lang.Object
com.ibm.icu.text.ListFormatter
Immutable class for formatting a list, using data from CLDR (or supplied
separately). The class is not subclassable.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static final classstatic final classField selectors for format fields defined by ListFormatter.static final classAn immutable class containing the result of a list formatting operation.(package private) static classprivate static interfacestatic final classClass for span fields in FormattedList.private static final classstatic enumType of meaning expressed by the list.static enumVerbosity level of the list patterns. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static ListFormatter.Cacheprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate final ULocaleprivate final Stringprivate final ListFormatter.PatternHandlerprivate final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static StringcompilePattern(String pattern, StringBuilder sb) private ListFormatter.PatternHandlercreatePatternHandler(String two, String end) Format a list of objects.format(Collection<?> items) Format a collection of objects.(package private) ListFormatter.FormattedListBuilderformatImpl(Collection<?> items, boolean needsFields) formatToValue(Object... items) Format a list of objects to a FormattedList.formatToValue(Collection<?> items) Format a collection of objects to a FormattedList.static ListFormatterCreate a list formatter that is appropriate for the default FORMAT locale.static ListFormattergetInstance(ULocale locale) Create a list formatter that is appropriate for a locale.static ListFormattergetInstance(ULocale locale, ListFormatter.Type type, ListFormatter.Width width) Create a list formatter that is appropriate for a locale.static ListFormattergetInstance(Locale locale) Create a list formatter that is appropriate for a locale.static ListFormattergetInstance(Locale locale, ListFormatter.Type type, ListFormatter.Width width) Create a list formatter that is appropriate for a locale.Deprecated.This API is ICU internal only.getPatternForNumItems(int count) Returns the pattern to use for a particular item count.(package private) static StringtypeWidthToStyleString(ListFormatter.Type type, ListFormatter.Width width)
-
Field Details
-
start
-
middle
-
locale
-
patternHandler
-
compiledY
-
compiledE
-
compiledO
-
compiledU
-
changeToE
-
changeToU
-
compiledVav
-
compiledVavDash
-
changeToVavDash
-
cache
-
-
Constructor Details
-
ListFormatter
Deprecated.This API is ICU internal only.Internal: Create a ListFormatter from component strings, with definitions as in LDML.- Parameters:
two- string for two items, containing {0} for the first, and {1} for the second.start- string for the start of a list items, containing {0} for the first, and {1} for the rest.middle- string for the start of a list items, containing {0} for the first part of the list, and {1} for the rest of the list.end- string for the end of a list items, containing {0} for the first part of the list, and {1} for the last item.
-
ListFormatter
-
-
Method Details
-
compilePattern
-
getInstance
public static ListFormatter getInstance(ULocale locale, ListFormatter.Type type, ListFormatter.Width width) Create a list formatter that is appropriate for a locale.- Parameters:
locale- the locale in question.- Returns:
- ListFormatter
-
getInstance
public static ListFormatter getInstance(Locale locale, ListFormatter.Type type, ListFormatter.Width width) Create a list formatter that is appropriate for a locale.- Parameters:
locale- the locale in question.- Returns:
- ListFormatter
-
getInstance
Create a list formatter that is appropriate for a locale.- Parameters:
locale- the locale in question.- Returns:
- ListFormatter
-
getInstance
Create a list formatter that is appropriate for a locale.- Parameters:
locale- the locale in question.- Returns:
- ListFormatter
-
getInstance
Create a list formatter that is appropriate for the default FORMAT locale.- Returns:
- ListFormatter
-
format
Format a list of objects.- Parameters:
items- items to format. The toString() method is called on each.- Returns:
- items formatted into a string
-
format
Format a collection of objects. The toString() method is called on each.- Parameters:
items- items to format. The toString() method is called on each.- Returns:
- items formatted into a string
-
formatToValue
Format a list of objects to a FormattedList. You can access the offsets of each element from the FormattedList.- Parameters:
items- items to format. The toString() method is called on each.- Returns:
- items formatted into a FormattedList
-
formatToValue
Format a collection of objects to a FormattedList. You can access the offsets of each element from the FormattedList.- Parameters:
items- items to format. The toString() method is called on each.- Returns:
- items formatted into a FormattedList
-
formatImpl
-
createPatternHandler
-
getPatternForNumItems
Returns the pattern to use for a particular item count.- Parameters:
count- the item count.- Returns:
- the pattern with {0}, {1}, {2}, etc. For English, getPatternForNumItems(3) == "{0}, {1}, and {2}"
- Throws:
IllegalArgumentException- when count is 0 or negative.
-
getLocale
Deprecated.This API is ICU internal only.Returns the locale of this object. -
typeWidthToStyleString
-