ICU-11015 Check in API, marked as @internal for now. If the API proposal is accepted, would drop the @internal.

X-SVN-Rev: 36184
This commit is contained in:
Mark Davis 2014-08-17 19:09:21 +00:00
parent b741781903
commit b31ff49acf
2 changed files with 31 additions and 2 deletions

View file

@ -1177,7 +1177,7 @@ public class MeasureFormat extends UFormat {
*/
@Deprecated
public SimplePatternFormatter getRangeFormat(ULocale forLocale, FormatWidth width) {
public static SimplePatternFormatter getRangeFormat(ULocale forLocale, FormatWidth width) {
// TODO fix Hack for French
if (forLocale.getLanguage().equals("fr")) {
return getRangeFormat(ULocale.ROOT, width);
@ -1212,4 +1212,17 @@ public class MeasureFormat extends UFormat {
}
return result;
}
/**
* Return a simple pattern pattern for a range, such as "{0}{1}" or "{0}{1}".
* @param forLocale locale to get the range pattern for
* @param width the format width.
* @return range pattern
* @internal
* @deprecated This API is ICU internal only.
*/
@Deprecated
public static String getRangePattern(ULocale forLocale, FormatWidth width) {
return getRangeFormat(forLocale, width).toString();
}
}

View file

@ -6,6 +6,8 @@
*/
package com.ibm.icu.dev.test.format;
import java.util.Arrays;
import com.ibm.icu.dev.test.TestFmwk;
import com.ibm.icu.text.MeasureFormat;
import com.ibm.icu.text.MeasureFormat.FormatWidth;
@ -50,6 +52,20 @@ public class PluralRangesTest extends TestFmwk {
}
}
public void TestRangePattern() {
String[][] tests = {
{"de", "SHORT", "{0}{1}"},
{"ja", "NARROW", "{0}{1}"},
};
for (String[] test : tests) {
ULocale ulocale = new ULocale(test[0]);
FormatWidth width = FormatWidth.valueOf(test[1]);
String expected = test[2];
String actual = MeasureFormat.getRangePattern(ulocale, width);
assertEquals("range pattern " + Arrays.asList(test), expected, actual);
}
}
public void TestFormatting() {
Object[][] tests = {
{0.0, 1.0, ULocale.FRANCE, FormatWidth.WIDE, MeasureUnit.FAHRENHEIT, "01 degré Fahrenheit"},
@ -58,7 +74,7 @@ public class PluralRangesTest extends TestFmwk {
{3.1, 4.25, ULocale.ENGLISH, FormatWidth.SHORT, MeasureUnit.FAHRENHEIT, "3.14.25°F"},
{3.1, 4.25, ULocale.CHINESE, FormatWidth.WIDE, MeasureUnit.INCH, "3.1-4.25英寸"},
{0.0, 1.0, ULocale.ENGLISH, FormatWidth.WIDE, MeasureUnit.INCH, "01 inches"},
{0.0, 1.0, ULocale.ENGLISH, FormatWidth.NARROW, Currency.getInstance("EUR"), "€0.001.00"},
{0.0, 1.0, ULocale.FRENCH, FormatWidth.NARROW, Currency.getInstance("EUR"), "0,001,00 "},
{0.0, 100.0, ULocale.FRENCH, FormatWidth.NARROW, Currency.getInstance("JPY"), "0100\u00a0¥JP"},