public final class ListFormatter extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ListFormatter.Field
Field selectors for format fields defined by ListFormatter.
|
static class |
ListFormatter.FormattedList
An immutable class containing the result of a list formatting operation.
|
static class |
ListFormatter.SpanField
Class for span fields in FormattedList.
|
static class |
ListFormatter.Type
Type of meaning expressed by the list.
|
static class |
ListFormatter.Width
Verbosity level of the list patterns.
|
Constructor and Description |
---|
ListFormatter(String two,
String start,
String middle,
String end)
Deprecated.
This API is ICU internal only.
|
Modifier and Type | Method and Description |
---|---|
String |
format(Collection<?> items)
Format a collection of objects.
|
String |
format(Object... items)
Format a list of objects.
|
ListFormatter.FormattedList |
formatToValue(Collection<?> items)
Format a collection of objects to a FormattedList.
|
ListFormatter.FormattedList |
formatToValue(Object... items)
Format a list of objects to a FormattedList.
|
static ListFormatter |
getInstance()
Create a list formatter that is appropriate for the default FORMAT locale.
|
static ListFormatter |
getInstance(Locale locale)
Create a list formatter that is appropriate for a locale.
|
static ListFormatter |
getInstance(Locale locale,
ListFormatter.Type type,
ListFormatter.Width width)
Create a list formatter that is appropriate for a locale.
|
static ListFormatter |
getInstance(ULocale locale)
Create a list formatter that is appropriate for a locale.
|
static ListFormatter |
getInstance(ULocale locale,
ListFormatter.Type type,
ListFormatter.Width width)
Create a list formatter that is appropriate for a locale.
|
ULocale |
getLocale()
Deprecated.
This API is ICU internal only.
|
String |
getPatternForNumItems(int count)
Returns the pattern to use for a particular item count.
|
@Deprecated public ListFormatter(String two, String start, String middle, String end)
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.public static ListFormatter getInstance(ULocale locale, ListFormatter.Type type, ListFormatter.Width width)
locale
- the locale in question.public static ListFormatter getInstance(Locale locale, ListFormatter.Type type, ListFormatter.Width width)
locale
- the locale in question.public static ListFormatter getInstance(ULocale locale)
locale
- the locale in question.public static ListFormatter getInstance(Locale locale)
locale
- the locale in question.public static ListFormatter getInstance()
public String format(Object... items)
items
- items to format. The toString() method is called on each.public String format(Collection<?> items)
items
- items to format. The toString() method is called on each.public ListFormatter.FormattedList formatToValue(Object... items)
items
- items to format. The toString() method is called on each.public ListFormatter.FormattedList formatToValue(Collection<?> items)
items
- items to format. The toString() method is called on each.public String getPatternForNumItems(int count)
count
- the item count.IllegalArgumentException
- when count is 0 or negative.@Deprecated public ULocale getLocale()
Copyright © 2016 Unicode, Inc. and others.