Top Description Inners Fields Constructors Methods
com.ibm.icu.text

public final Class ListFormatter

extends Object
Class Inheritance
Imports
java.io.InvalidObjectException, java.text.AttributedCharacterIterator, .Format, java.util.ArrayList, .Arrays, .Collection, .Iterator, .Locale, java.util.regex.Pattern, com.ibm.icu.impl.FormattedStringBuilder, .FormattedValueStringBuilderImpl, .FormattedValueStringBuilderImpl.SpanFieldPlaceholder, .ICUCache, .ICUData, .ICUResourceBundle, .SimpleCache, .SimpleFormatterImpl, .SimpleFormatterImpl.IterInternal, .Utility, com.ibm.icu.util.ULocale, .UResourceBundle

Immutable class for formatting a list, using data from CLDR (or supplied separately). The class is not subclassable.
Author
Mark Davis
ICU Status
Stable since ICU 50.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
public static class
ListFormatter.Field

Field selectors for format fields defined by ListFormatter.

public static class
ListFormatter.FormattedList

An immutable class containing the result of a list formatting operation.

pack-priv static class
private static interface
public static class
ListFormatter.SpanField

Class for span fields in FormattedList.

private static class
public static enum
ListFormatter.Type

Type of meaning expressed by the list.

public static enum
ListFormatter.Width

Verbosity level of the list patterns.

Field Summary

Modifier and TypeField and Description
pack-priv static ListFormatter.Cache
private static final Pattern
private static final Pattern
private static final Pattern
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private final ULocale
private final String
private final ListFormatter.PatternHandler
private final String

Constructor Summary

AccessConstructor and Description
public
ListFormatter(String
string for two items, containing {0} for the first, and {1} for the second.
two
,
String
string for the start of a list items, containing {0} for the first, and {1} for the rest.
start
,
String
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.
middle
,
String
string for the end of a list items, containing {0} for the first part of the list, and {1} for the last item.
end
)

Deprecated This API is ICU internal only.
Internal: Create a ListFormatter from component strings, with definitions as in LDML.
private
ListFormatter(String two, String start, String middle, String end, ULocale locale)

Method Summary

Modifier and TypeMethod and Description
private static String
private ListFormatter.PatternHandler
public String

Returns:

items formatted into a string
format
(Object...
items to format. The toString() method is called on each.
items
)

Format a list of objects.

public String

Returns:

items formatted into a string
format
(Collection<?>
items to format. The toString() method is called on each.
items
)

Format a collection of objects.

pack-priv ListFormatter.FormattedListBuilder
formatImpl(Collection<?> items, boolean needsFields)

public ListFormatter.FormattedList

Returns:

items formatted into a FormattedList
formatToValue
(Object...
items to format. The toString() method is called on each.
items
)

Format a list of objects to a FormattedList.

public ListFormatter.FormattedList

Returns:

items formatted into a FormattedList
formatToValue
(Collection<?>
items to format. The toString() method is called on each.
items
)

Format a collection of objects to a FormattedList.

public static ListFormatter

Returns:

ListFormatter
getInstance
(ULocale
the locale in question.
locale
,
ListFormatter.Type type, ListFormatter.Width width)

Create a list formatter that is appropriate for a locale.

public static ListFormatter

Returns:

ListFormatter
getInstance
(Locale
the locale in question.
locale
,
ListFormatter.Type type, ListFormatter.Width width)

Create a list formatter that is appropriate for a locale.

public static ListFormatter

Returns:

ListFormatter
getInstance
(ULocale
the locale in question.
locale
)

Create a list formatter that is appropriate for a locale.

public static ListFormatter

Returns:

ListFormatter
getInstance
(Locale
the locale in question.
locale
)

Create a list formatter that is appropriate for a locale.

public static ListFormatter

Returns:

ListFormatter
getInstance
()

Create a list formatter that is appropriate for the default FORMAT locale.

public ULocale
getLocale()

Deprecated This API is ICU internal only.
Returns the locale of this object.
public String

Returns:

the pattern with {0}, {1}, {2}, etc. For English, getPatternForNumItems(3) == "{0}, {1}, and {2}"
getPatternForNumItems
(int
the item count.
count
)

Returns the pattern to use for a particular item count.

pack-priv static String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait