1 /* GENERATED SOURCE. DO NOT MODIFY. */ 2 // © 2018 and later: Unicode, Inc. and others. 3 // License & terms of use: http://www.unicode.org/copyright.html#License 4 package ohos.global.icu.number; 5 6 import java.util.Locale; 7 8 import ohos.global.icu.util.ULocale; 9 10 /** 11 * A NumberRangeFormatter that does not yet have a locale. In order to format, a locale must be specified. 12 * 13 * Instances of this class are immutable and thread-safe. 14 * 15 * @author sffc 16 * @see NumberRangeFormatter 17 * @hide exposed on OHOS 18 */ 19 public class UnlocalizedNumberRangeFormatter extends NumberRangeFormatterSettings<UnlocalizedNumberRangeFormatter> { 20 21 /** Base constructor; called during startup only. */ UnlocalizedNumberRangeFormatter()22 UnlocalizedNumberRangeFormatter() { 23 super(null, KEY_MACROS, null); 24 } 25 UnlocalizedNumberRangeFormatter(NumberRangeFormatterSettings<?> parent, int key, Object value)26 UnlocalizedNumberRangeFormatter(NumberRangeFormatterSettings<?> parent, int key, Object value) { 27 super(parent, key, value); 28 } 29 30 /** 31 * Associate the given locale with the number range formatter. The locale is used for picking the 32 * appropriate symbols, formats, and other data for number display. 33 * 34 * <p> 35 * To use the Java default locale, call Locale.getDefault(): 36 * 37 * <pre> 38 * NumberFormatter.with(). ... .locale(Locale.getDefault()) 39 * </pre> 40 * 41 * @param locale 42 * The locale to use when loading data for number range formatting. 43 * @return The fluent chain 44 */ locale(Locale locale)45 public LocalizedNumberRangeFormatter locale(Locale locale) { 46 return new LocalizedNumberRangeFormatter(this, KEY_LOCALE, ULocale.forLocale(locale)); 47 } 48 49 /** 50 * ULocale version of the {@link #locale(Locale)} setter above. 51 * 52 * @param locale 53 * The locale to use when loading data for number range formatting. 54 * @return The fluent chain 55 * @see #locale(Locale) 56 */ locale(ULocale locale)57 public LocalizedNumberRangeFormatter locale(ULocale locale) { 58 return new LocalizedNumberRangeFormatter(this, KEY_LOCALE, locale); 59 } 60 61 @Override create(int key, Object value)62 UnlocalizedNumberRangeFormatter create(int key, Object value) { 63 return new UnlocalizedNumberRangeFormatter(this, key, value); 64 } 65 } 66