Package com.ibm.icu.text
Class ListFormatter
- java.lang.Object
-
- com.ibm.icu.text.ListFormatter
-
public final class ListFormatter extends Object
Immutable class for formatting a list, using data from CLDR (or supplied separately). The class is not subclassable.- Author:
- Mark Davis
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ListFormatter.Style
Deprecated.This API is ICU internal only.
-
Constructor Summary
Constructors Constructor Description ListFormatter(String two, String start, String middle, String end)
Deprecated.This API is ICU internal only.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description String
format(Object... items)
Format a list of objects.String
format(Collection<?> items)
Format a collection of objects.static ListFormatter
getInstance()
Create a list formatter that is appropriate for the default FORMAT locale.static ListFormatter
getInstance(ULocale locale)
Create a list formatter that is appropriate for a locale.static ListFormatter
getInstance(ULocale locale, ListFormatter.Style style)
Deprecated.This API is ICU internal only.static ListFormatter
getInstance(Locale locale)
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.
-
-
-
Constructor Detail
-
ListFormatter
@Deprecated public ListFormatter(String two, String start, String middle, String end)
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.
-
-
Method Detail
-
getInstance
public static ListFormatter getInstance(ULocale locale)
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)
Create a list formatter that is appropriate for a locale.- Parameters:
locale
- the locale in question.- Returns:
- ListFormatter
-
getInstance
@Deprecated public static ListFormatter getInstance(ULocale locale, ListFormatter.Style style)
Deprecated.This API is ICU internal only.Create a list formatter that is appropriate for a locale and style.- Parameters:
locale
- the locale in question.style
- the style- Returns:
- ListFormatter
-
getInstance
public static ListFormatter getInstance()
Create a list formatter that is appropriate for the default FORMAT locale.- Returns:
- ListFormatter
-
format
public String format(Object... items)
Format a list of objects.- Parameters:
items
- items to format. The toString() method is called on each.- Returns:
- items formatted into a string
-
format
public String format(Collection<?> items)
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
-
getPatternForNumItems
public String getPatternForNumItems(int count)
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 public ULocale getLocale()
Deprecated.This API is ICU internal only.Returns the locale of this object.
-
-