+++ /dev/null
-/*
- *******************************************************************************
- * Copyright (C) 2012-2012, Google, International Business Machines Corporation and *
- * others. All Rights Reserved. *
- *******************************************************************************
- */
-package com.ibm.icu.util;
-
-class ListFormatData {
- static void load() {
- ListFormat.add("af", "{0} en {1}", "{0}, {1}", "{0}, {1}", "{0} en {1}");
- ListFormat.add("am", "{0} እና {1}", "{0}, {1}", "{0}, {1}", "{0}, እና {1}");
- ListFormat.add("ar", "{0} و {1}", "{0}، {1}", "{0}، {1}", "{0}، و {1}");
- ListFormat.add("bg", "{0} и {1}", "{0}, {1}", "{0}, {1}", "{0} и {1}");
- ListFormat.add("bn", "{0} এবং {1}", "{0}, {1}", "{0}, {1}", "{0}, এবং {1}");
- ListFormat.add("bs", "{0} i {1}", "{0}, {1}", "{0}, {1}", "{0} i {1}");
- ListFormat.add("ca", "{0} i {1}", "{0}, {1}", "{0}, {1}", "{0} i {1}");
- ListFormat.add("cs", "{0} a {1}", "{0}, {1}", "{0}, {1}", "{0} a {1}");
- ListFormat.add("da", "{0} og {1}", "{0}, {1}", "{0}, {1}", "{0} og {1}");
- ListFormat.add("de", "{0} und {1}", "{0}, {1}", "{0}, {1}", "{0} und {1}");
- ListFormat.add("ee", "{0} kple {1}", "{0}, {1}", "{0}, {1}", "{0}, kple {1}");
- ListFormat.add("el", "{0} και {1}", "{0}, {1}", "{0}, {1}", "{0} και {1}");
- ListFormat.add("en", "{0} and {1}", "{0}, {1}", "{0}, {1}", "{0}, and {1}");
- ListFormat.add("es", "{0} y {1}", "{0}, {1}", "{0}, {1}", "{0} y {1}");
- ListFormat.add("et", "{0} ja {1}", "{0}, {1}", "{0}, {1}", "{0} ja {1}");
- ListFormat.add("eu", "{0} eta {1}", "{0}, {1}", "{0}, {1}", "{0} eta {1}");
- ListFormat.add("fa", "{0} و {1}", "{0}، {1}", "{0}، {1}", "{0}، و {1}");
- ListFormat.add("fi", "{0} ja {1}", "{0}, {1}", "{0}, {1}", "{0} ja {1}");
- ListFormat.add("fil", "{0} at {1}", "{0}, {1}", "{0}, {1}", "{0} at {1}");
- ListFormat.add("fo", "{0} og {1}", "{0}, {1}", "{0}, {1}", "{0} og {1}");
- ListFormat.add("fr", "{0} et {1}", "{0}, {1}", "{0}, {1}", "{0} et {1}");
- ListFormat.add("fur", "{0} e {1}", "{0}, {1}", "{0}, {1}", "{0} e {1}");
- ListFormat.add("gd", "{0} agus {1}", "{0}, {1}", "{0}, {1}", "{0}, agus {1}");
- ListFormat.add("gl", "{0} e {1}", "{0}, {1}", "{0}, {1}", "{0} e {1}");
- ListFormat.add("gsw", "{0} und {1}", "{0}, {1}", "{0}, {1}", "{0} und {1}");
- ListFormat.add("gu", "{0} અને {1}", "{0}, {1}", "{0}, {1}", "{0} અને {1}");
- ListFormat.add("he", "{0} ו-{1}", "{0}, {1}", "{0}, {1}", "{0} ו-{1}");
- ListFormat.add("hi", "{0} और {1}", "{0}, {1}", "{0}, {1}", "{0}, और {1}");
- ListFormat.add("hr", "{0} i {1}", "{0}, {1}", "{0}, {1}", "{0} i {1}");
- ListFormat.add("hu", "{0} és {1}", "{0}, {1}", "{0}, {1}", "{0} és {1}");
- ListFormat.add("id", "{0} dan {1}", "{0}, {1}", "{0}, {1}", "{0}, dan {1}");
- ListFormat.add("is", "{0} og {1}", "{0}, {1}", "{0}, {1}", "{0} og {1}");
- ListFormat.add("it", "{0} e {1}", "{0}, {1}", "{0}, {1}", "{0}, e {1}");
- ListFormat.add("ja", "{0}、{1}", "{0}、{1}", "{0}、{1}", "{0}、{1}");
- ListFormat.add("ka", "{0} და {1}", "{0}, {1}", "{0}, {1}", "{0} და {1}");
- ListFormat.add("kea", "{0} y {1}", "{0}, {1}", "{0}, {1}", "{0} y {1}");
- ListFormat.add("kl", "{0} aamma {1}", "{0} aamma {1}", "{0}, {1}", "{0}, {1}");
- ListFormat.add("kn", "{0} ಮತ್ತು {1}", "{0}, {1}", "{0}, {1}", "{0}, ಮತ್ತು {1}");
- ListFormat.add("ko", "{0} 및 {1}", "{0}, {1}", "{0}, {1}", "{0} 및 {1}");
- ListFormat.add("ksh", "{0} un {1}", "{0}, {1}", "{0}, {1}", "{0} un {1}");
- ListFormat.add("lt", "{0} ir {1}", "{0}, {1}", "{0}, {1}", "{0} ir {1}");
- ListFormat.add("lv", "{0} un {1}", "{0}, {1}", "{0}, {1}", "{0} un {1}");
- ListFormat.add("ml", "{0} കൂടാതെ {1}", "{0}, {1}", "{0}, {1}", "{0}, {1} എന്നിവ");
- ListFormat.add("mr", "{0} आणि {1}", "{0}, {1}", "{0}, {1}", "{0} आणि {1}");
- ListFormat.add("ms", "{0} dan {1}", "{0}, {1}", "{0}, {1}", "{0}, dan {1}");
- ListFormat.add("nb", "{0} og {1}", "{0}, {1}", "{0}, {1}", "{0} og {1}");
- ListFormat.add("nl", "{0} en {1}", "{0}, {1}", "{0}, {1}", "{0} en {1}");
- ListFormat.add("nn", "{0} og {1}", "{0}, {1}", "{0}, {1}", "{0} og {1}");
- ListFormat.add("pl", "{0} i {1}", "{0}; {1}", "{0}; {1}", "{0} i {1}");
- ListFormat.add("pt", "{0} e {1}", "{0}, {1}", "{0}, {1}", "{0} e {1}");
- ListFormat.add("ro", "{0} şi {1}", "{0}, {1}", "{0}, {1}", "{0} şi {1}");
- ListFormat.add("", "{0}, {1}", "{0}, {1}", "{0}, {1}", "{0}, {1}"); // root
- ListFormat.add("ru", "{0} и {1}", "{0}, {1}", "{0}, {1}", "{0} и {1}");
- ListFormat.add("se", "{0} ja {1}", "{0}, {1}", "{0}, {1}", "{0} ja {1}");
- ListFormat.add("sk", "{0} a {1}", "{0}, {1}", "{0}, {1}", "{0} a {1}");
- ListFormat.add("sl", "{0} in {1}", "{0}, {1}", "{0}, {1}", "{0} in {1}");
- ListFormat.add("sr", "{0} и {1}", "{0}, {1}", "{0}, {1}", "{0} и {1}");
- ListFormat.add("sr_Cyrl", "{0} и {1}", "{0}, {1}", "{0}, {1}", "{0} и {1}");
- ListFormat.add("sr_Latn", "{0} i {1}", "{0}, {1}", "{0}, {1}", "{0} i {1}");
- ListFormat.add("sv", "{0} och {1}", "{0}, {1}", "{0}, {1}", "{0} och {1}");
- ListFormat.add("sw", "{0} na {1}", "{0}, {1}", "{0}, {1}", "{0}, na {1}");
- ListFormat.add("ta", "{0} மற்றும் {1}", "{0}, {1}", "{0}, {1}", "{0} மற்றும் {1}");
- ListFormat.add("te", "{0} మరియు {1}", "{0}, {1}", "{0}, {1}", "{0} మరియు {1}");
- ListFormat.add("th", "{0}และ{1}", "{0} {1}", "{0} {1}", "{0} และ{1}");
- ListFormat.add("tr", "{0} ve {1}", "{0}, {1}", "{0}, {1}", "{0} ve {1}");
- ListFormat.add("uk", "{0} та {1}", "{0}, {1}", "{0}, {1}", "{0} та {1}");
- ListFormat.add("ur", "{0} اور {1}", "{0}، {1}", "{0}، {1}", "{0}، اور {1}");
- ListFormat.add("vi", "{0} và {1}", "{0}, {1}", "{0}, {1}", "{0} và {1}");
- ListFormat.add("wae", "{0} und {1}", "{0}, {1}", "{0}, {1}", "{0} und {1}");
- ListFormat.add("zh", "{0}和{1}", "{0}、{1}", "{0}、{1}", "{0}和{1}");
- ListFormat.add("zh", "{0}和{1}", "{0}、{1}", "{0}、{1}", "{0}和{1}");
- ListFormat.add("zu", "I-{0} ne-{1}", "{0}, {1}", "{0}, {1}", "{0}, no-{1}");
- }
-}
/*
*******************************************************************************
* Copyright (C) 2012-2012, Google, International Business Machines Corporation and
- * others. All Rights Reserved. *
+ * others. All Rights Reserved.
*******************************************************************************
*/
package com.ibm.icu.util;
import java.util.Locale;
import java.util.Map;
-import com.ibm.icu.text.Transform;
-
/**
* Immutable class for formatting a list, using data from CLDR (or supplied
* separately). The class is not subclassable.
*
* @author markdavis
- * @internal
+ * @draft ICU 50
+ * @provisional This API might change or be removed in a future release.
*/
-final public class ListFormat implements Transform<Collection<String>, String> {
+final public class ListFormatter {
private final String two;
private final String start;
private final String middle;
private final String end;
/**
- * Create a ListFormatter from component strings, with definitions as in
- * LDML.
+ * <b>Internal:</b> Create a ListFormatter from component strings,
+ * with definitions as in LDML.
*
* @param two
* string for two items, containing {0} for the first, and {1}
* first part of the list, and {1} for the last item.
* @internal
*/
- public ListFormat(String two, String start, String middle, String end) {
+ public ListFormatter(String two, String start, String middle, String end) {
this.two = two;
this.start = start;
this.middle = middle;
* @param locale
* the locale in question.
* @return ListFormatter
- * @internal
+ * @draft ICU 50
+ * @provisional This API might change or be removed in a future release.
*/
- public static ListFormat getInstance(ULocale locale) {
+ public static ListFormatter getInstance(ULocale locale) {
// These can be cached, since they are read-only
// poor-man's locale lookup, for hardcoded data
while (true) {
- ListFormat data = localeToData.get(locale);
+ ListFormatter data = localeToData.get(locale);
if (data != null) {
return data;
}
* @param locale
* the locale in question.
* @return ListFormatter
- * @internal
+ * @draft ICU 50
+ * @provisional This API might change or be removed in a future release.
*/
- public static ListFormat getInstance(Locale locale) {
+ public static ListFormatter getInstance(Locale locale) {
return getInstance(ULocale.forLocale(locale));
}
* @param items
* items to format. The toString() method is called on each.
* @return items formatted into a string
- * @internal
+ * @draft ICU 50
+ * @provisional This API might change or be removed in a future release.
*/
public String format(Object... items) {
return format(Arrays.asList(items));
}
/**
- * Format a collation of objects. The toString() method is called on each.
+ * Format a collection of objects. The toString() method is called on each.
*
* @param items
* items to format. The toString() method is called on each.
* @return items formatted into a string
- * @internal
+ * @draft ICU 50
+ * @provisional This API might change or be removed in a future release.
*/
public String format(Collection<Object> items) {
// TODO optimize this for the common case that the patterns are all of the
: pattern.substring(0, i1) + a + pattern.substring(i1+3, i0) + b + pattern.substring(i0+3);
}
- /**
- * @internal
- */
- public String transform(Collection<String> source) {
- return format(source);
- }
-
/** JUST FOR DEVELOPMENT */
// For use with the hard-coded data
// TODO Replace by use of RB
// Verify in building that all of the patterns contain {0}, {1}.
- static Map<ULocale, ListFormat> localeToData = new HashMap<ULocale, ListFormat>();
+ static Map<ULocale, ListFormatter> localeToData = new HashMap<ULocale, ListFormatter>();
static void add(String locale, String...data) {
- localeToData.put(new ULocale(locale), new ListFormat(data[0], data[1], data[2], data[3]));
+ localeToData.put(new ULocale(locale), new ListFormatter(data[0], data[1], data[2], data[3]));
}
static {
- ListFormatData.load();
+ ListFormatterData.load();
}
}
--- /dev/null
+/*
+ *******************************************************************************
+ * Copyright (C) 2012-2012, Google, International Business Machines Corporation and
+ * others. All Rights Reserved.
+ *******************************************************************************
+ */
+package com.ibm.icu.util;
+
+class ListFormatterData {
+ static void load() {
+ ListFormatter.add("af", "{0} en {1}", "{0}, {1}", "{0}, {1}", "{0} en {1}");
+ ListFormatter.add("am", "{0} እና {1}", "{0}, {1}", "{0}, {1}", "{0}, እና {1}");
+ ListFormatter.add("ar", "{0} و {1}", "{0}، {1}", "{0}، {1}", "{0}، و {1}");
+ ListFormatter.add("bg", "{0} и {1}", "{0}, {1}", "{0}, {1}", "{0} и {1}");
+ ListFormatter.add("bn", "{0} এবং {1}", "{0}, {1}", "{0}, {1}", "{0}, এবং {1}");
+ ListFormatter.add("bs", "{0} i {1}", "{0}, {1}", "{0}, {1}", "{0} i {1}");
+ ListFormatter.add("ca", "{0} i {1}", "{0}, {1}", "{0}, {1}", "{0} i {1}");
+ ListFormatter.add("cs", "{0} a {1}", "{0}, {1}", "{0}, {1}", "{0} a {1}");
+ ListFormatter.add("da", "{0} og {1}", "{0}, {1}", "{0}, {1}", "{0} og {1}");
+ ListFormatter.add("de", "{0} und {1}", "{0}, {1}", "{0}, {1}", "{0} und {1}");
+ ListFormatter.add("ee", "{0} kple {1}", "{0}, {1}", "{0}, {1}", "{0}, kple {1}");
+ ListFormatter.add("el", "{0} και {1}", "{0}, {1}", "{0}, {1}", "{0} και {1}");
+ ListFormatter.add("en", "{0} and {1}", "{0}, {1}", "{0}, {1}", "{0}, and {1}");
+ ListFormatter.add("es", "{0} y {1}", "{0}, {1}", "{0}, {1}", "{0} y {1}");
+ ListFormatter.add("et", "{0} ja {1}", "{0}, {1}", "{0}, {1}", "{0} ja {1}");
+ ListFormatter.add("eu", "{0} eta {1}", "{0}, {1}", "{0}, {1}", "{0} eta {1}");
+ ListFormatter.add("fa", "{0} و {1}", "{0}، {1}", "{0}، {1}", "{0}، و {1}");
+ ListFormatter.add("fi", "{0} ja {1}", "{0}, {1}", "{0}, {1}", "{0} ja {1}");
+ ListFormatter.add("fil", "{0} at {1}", "{0}, {1}", "{0}, {1}", "{0} at {1}");
+ ListFormatter.add("fo", "{0} og {1}", "{0}, {1}", "{0}, {1}", "{0} og {1}");
+ ListFormatter.add("fr", "{0} et {1}", "{0}, {1}", "{0}, {1}", "{0} et {1}");
+ ListFormatter.add("fur", "{0} e {1}", "{0}, {1}", "{0}, {1}", "{0} e {1}");
+ ListFormatter.add("gd", "{0} agus {1}", "{0}, {1}", "{0}, {1}", "{0}, agus {1}");
+ ListFormatter.add("gl", "{0} e {1}", "{0}, {1}", "{0}, {1}", "{0} e {1}");
+ ListFormatter.add("gsw", "{0} und {1}", "{0}, {1}", "{0}, {1}", "{0} und {1}");
+ ListFormatter.add("gu", "{0} અને {1}", "{0}, {1}", "{0}, {1}", "{0} અને {1}");
+ ListFormatter.add("he", "{0} ו-{1}", "{0}, {1}", "{0}, {1}", "{0} ו-{1}");
+ ListFormatter.add("hi", "{0} और {1}", "{0}, {1}", "{0}, {1}", "{0}, और {1}");
+ ListFormatter.add("hr", "{0} i {1}", "{0}, {1}", "{0}, {1}", "{0} i {1}");
+ ListFormatter.add("hu", "{0} és {1}", "{0}, {1}", "{0}, {1}", "{0} és {1}");
+ ListFormatter.add("id", "{0} dan {1}", "{0}, {1}", "{0}, {1}", "{0}, dan {1}");
+ ListFormatter.add("is", "{0} og {1}", "{0}, {1}", "{0}, {1}", "{0} og {1}");
+ ListFormatter.add("it", "{0} e {1}", "{0}, {1}", "{0}, {1}", "{0}, e {1}");
+ ListFormatter.add("ja", "{0}、{1}", "{0}、{1}", "{0}、{1}", "{0}、{1}");
+ ListFormatter.add("ka", "{0} და {1}", "{0}, {1}", "{0}, {1}", "{0} და {1}");
+ ListFormatter.add("kea", "{0} y {1}", "{0}, {1}", "{0}, {1}", "{0} y {1}");
+ ListFormatter.add("kl", "{0} aamma {1}", "{0} aamma {1}", "{0}, {1}", "{0}, {1}");
+ ListFormatter.add("kn", "{0} ಮತ್ತು {1}", "{0}, {1}", "{0}, {1}", "{0}, ಮತ್ತು {1}");
+ ListFormatter.add("ko", "{0} 및 {1}", "{0}, {1}", "{0}, {1}", "{0} 및 {1}");
+ ListFormatter.add("ksh", "{0} un {1}", "{0}, {1}", "{0}, {1}", "{0} un {1}");
+ ListFormatter.add("lt", "{0} ir {1}", "{0}, {1}", "{0}, {1}", "{0} ir {1}");
+ ListFormatter.add("lv", "{0} un {1}", "{0}, {1}", "{0}, {1}", "{0} un {1}");
+ ListFormatter.add("ml", "{0} കൂടാതെ {1}", "{0}, {1}", "{0}, {1}", "{0}, {1} എന്നിവ");
+ ListFormatter.add("mr", "{0} आणि {1}", "{0}, {1}", "{0}, {1}", "{0} आणि {1}");
+ ListFormatter.add("ms", "{0} dan {1}", "{0}, {1}", "{0}, {1}", "{0}, dan {1}");
+ ListFormatter.add("nb", "{0} og {1}", "{0}, {1}", "{0}, {1}", "{0} og {1}");
+ ListFormatter.add("nl", "{0} en {1}", "{0}, {1}", "{0}, {1}", "{0} en {1}");
+ ListFormatter.add("nn", "{0} og {1}", "{0}, {1}", "{0}, {1}", "{0} og {1}");
+ ListFormatter.add("pl", "{0} i {1}", "{0}; {1}", "{0}; {1}", "{0} i {1}");
+ ListFormatter.add("pt", "{0} e {1}", "{0}, {1}", "{0}, {1}", "{0} e {1}");
+ ListFormatter.add("ro", "{0} şi {1}", "{0}, {1}", "{0}, {1}", "{0} şi {1}");
+ ListFormatter.add("", "{0}, {1}", "{0}, {1}", "{0}, {1}", "{0}, {1}"); // root
+ ListFormatter.add("ru", "{0} и {1}", "{0}, {1}", "{0}, {1}", "{0} и {1}");
+ ListFormatter.add("se", "{0} ja {1}", "{0}, {1}", "{0}, {1}", "{0} ja {1}");
+ ListFormatter.add("sk", "{0} a {1}", "{0}, {1}", "{0}, {1}", "{0} a {1}");
+ ListFormatter.add("sl", "{0} in {1}", "{0}, {1}", "{0}, {1}", "{0} in {1}");
+ ListFormatter.add("sr", "{0} и {1}", "{0}, {1}", "{0}, {1}", "{0} и {1}");
+ ListFormatter.add("sr_Cyrl", "{0} и {1}", "{0}, {1}", "{0}, {1}", "{0} и {1}");
+ ListFormatter.add("sr_Latn", "{0} i {1}", "{0}, {1}", "{0}, {1}", "{0} i {1}");
+ ListFormatter.add("sv", "{0} och {1}", "{0}, {1}", "{0}, {1}", "{0} och {1}");
+ ListFormatter.add("sw", "{0} na {1}", "{0}, {1}", "{0}, {1}", "{0}, na {1}");
+ ListFormatter.add("ta", "{0} மற்றும் {1}", "{0}, {1}", "{0}, {1}", "{0} மற்றும் {1}");
+ ListFormatter.add("te", "{0} మరియు {1}", "{0}, {1}", "{0}, {1}", "{0} మరియు {1}");
+ ListFormatter.add("th", "{0}และ{1}", "{0} {1}", "{0} {1}", "{0} และ{1}");
+ ListFormatter.add("tr", "{0} ve {1}", "{0}, {1}", "{0}, {1}", "{0} ve {1}");
+ ListFormatter.add("uk", "{0} та {1}", "{0}, {1}", "{0}, {1}", "{0} та {1}");
+ ListFormatter.add("ur", "{0} اور {1}", "{0}، {1}", "{0}، {1}", "{0}، اور {1}");
+ ListFormatter.add("vi", "{0} và {1}", "{0}, {1}", "{0}, {1}", "{0} và {1}");
+ ListFormatter.add("wae", "{0} und {1}", "{0}, {1}", "{0}, {1}", "{0} und {1}");
+ ListFormatter.add("zh", "{0}和{1}", "{0}、{1}", "{0}、{1}", "{0}和{1}");
+ ListFormatter.add("zh", "{0}和{1}", "{0}、{1}", "{0}、{1}", "{0}和{1}");
+ ListFormatter.add("zu", "I-{0} ne-{1}", "{0}, {1}", "{0}, {1}", "{0}, no-{1}");
+ }
+}
package com.ibm.icu.dev.test.util;
import com.ibm.icu.dev.test.TestFmwk;
-import com.ibm.icu.util.ListFormat;
+import com.ibm.icu.util.ListFormatter;
import com.ibm.icu.util.ULocale;
-public class ListFormatTest extends TestFmwk {
+public class ListFormatterTest extends TestFmwk {
public static void main(String[] args) {
- new ListFormatTest().run(args);
+ new ListFormatterTest().run(args);
}
String[] HardcodedTestData = {
};
public void TestBasic() {
- ListFormat formatter = new ListFormat("{0} and {1}", "{0}; {1}", "{0}, {1}", "{0}, and {1}");
+ ListFormatter formatter = new ListFormatter("{0} and {1}", "{0}; {1}", "{0}, {1}", "{0}, and {1}");
checkData(formatter, HardcodedTestData);
}
};
public void TestEnglish() {
- checkData(ListFormat.getInstance(ULocale.ENGLISH), EnglishTestData);
- checkData(ListFormat.getInstance(ULocale.US), EnglishTestData);
+ checkData(ListFormatter.getInstance(ULocale.ENGLISH), EnglishTestData);
+ checkData(ListFormatter.getInstance(ULocale.US), EnglishTestData);
}
String[] JapaneseTestData = {
};
public void TestJapanese() {
- checkData(ListFormat.getInstance(ULocale.JAPANESE), JapaneseTestData);
+ checkData(ListFormatter.getInstance(ULocale.JAPANESE), JapaneseTestData);
}
String[] RootTestData = {
};
public void TestSpecial() {
- checkData(ListFormat.getInstance(ULocale.ROOT), RootTestData);
- checkData(ListFormat.getInstance(new ULocale("xxx")), RootTestData);
+ checkData(ListFormatter.getInstance(ULocale.ROOT), RootTestData);
+ checkData(ListFormatter.getInstance(new ULocale("xxx")), RootTestData);
}
- public void checkData(ListFormat listFormat, String[] strings) {
+ public void checkData(ListFormatter listFormat, String[] strings) {
assertEquals("0", strings[0], listFormat.format());
assertEquals("1", strings[1], listFormat.format("A"));
assertEquals("2", strings[2], listFormat.format("A", "B"));
"Trie2Test",
"LocaleDataTest",
"GenderInfoTest",
- "ListFormatTest",
+ "ListFormatterTest",
"ULocaleTest",
"LocaleAliasTest",
"DebugUtilitiesTest",