com.ibm.icu.util
Class ListFormat

java.lang.Object
  extended by com.ibm.icu.util.ListFormat
All Implemented Interfaces:
Transform<Collection<String>,String>

public final class ListFormat
extends Object
implements Transform<Collection<String>,String>

Immutable class for formatting a list, using data from CLDR (or supplied separately). The class is not subclassable.

Author:
markdavis
Status:
Internal. This API is ICU internal only.

Constructor Summary
ListFormat(String two, String start, String middle, String end)
          Create a ListFormatter from component strings, with definitions as in LDML.
 
Method Summary
 String format(Collection<Object> items)
          Format a collation of objects.
 String format(Object... items)
          Format a list of objects.
static ListFormat getInstance(Locale locale)
          Create a list formatter that is appropriate for a locale.
static ListFormat getInstance(ULocale locale)
          Create a list formatter that is appropriate for a locale.
 String transform(Collection<String> source)
          Transform the input in some way, to be determined by the subclass.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListFormat

public ListFormat(String two,
                  String start,
                  String middle,
                  String end)
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.
Status:
Internal. This API is ICU internal only.
Method Detail

getInstance

public static ListFormat getInstance(ULocale locale)
Create a list formatter that is appropriate for a locale.

Parameters:
locale - the locale in question.
Returns:
ListFormatter
Status:
Internal. This API is ICU internal only.

getInstance

public static ListFormat getInstance(Locale locale)
Create a list formatter that is appropriate for a locale.

Parameters:
locale - the locale in question.
Returns:
ListFormatter
Status:
Internal. This API is ICU internal only.

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
Status:
Internal. This API is ICU internal only.

format

public String format(Collection<Object> items)
Format a collation 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
Status:
Internal. This API is ICU internal only.

transform

public String transform(Collection<String> source)
Description copied from interface: Transform
Transform the input in some way, to be determined by the subclass.

Specified by:
transform in interface Transform<Collection<String>,String>
Parameters:
source - to be transformed (eg lowercased)
Returns:
result
Status:
Internal. This API is ICU internal only.


Copyright (c) 2012 IBM Corporation and others.