1 /* GENERATED SOURCE. DO NOT MODIFY. */ 2 // © 2017 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 NumberFormatter that does not yet have a locale. In order to format numbers, a locale must be 12 * specified. 13 * 14 * Instances of this class are immutable and thread-safe. 15 * 16 * @see NumberFormatter 17 * @hide exposed on OHOS 18 */ 19 public class UnlocalizedNumberFormatter extends NumberFormatterSettings<UnlocalizedNumberFormatter> { 20 21 /** Base constructor; called during startup only. Sets the threshold to the default value of 3. */ UnlocalizedNumberFormatter()22 UnlocalizedNumberFormatter() { 23 super(null, KEY_THRESHOLD, new Long(3)); 24 } 25 UnlocalizedNumberFormatter(NumberFormatterSettings<?> parent, int key, Object value)26 UnlocalizedNumberFormatter(NumberFormatterSettings<?> parent, int key, Object value) { 27 super(parent, key, value); 28 } 29 30 /** 31 * Associate the given locale with the number 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 formatting. 43 * @return The fluent chain 44 */ locale(Locale locale)45 public LocalizedNumberFormatter locale(Locale locale) { 46 return new LocalizedNumberFormatter(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 formatting. 54 * @return The fluent chain 55 * @see #locale(Locale) 56 */ locale(ULocale locale)57 public LocalizedNumberFormatter locale(ULocale locale) { 58 return new LocalizedNumberFormatter(this, KEY_LOCALE, locale); 59 } 60 61 @Override create(int key, Object value)62 UnlocalizedNumberFormatter create(int key, Object value) { 63 return new UnlocalizedNumberFormatter(this, key, value); 64 } 65 }