1 /* GENERATED SOURCE. DO NOT MODIFY. */ 2 // © 2016 and later: Unicode, Inc. and others. 3 // License & terms of use: http://www.unicode.org/copyright.html#License 4 /* 5 ******************************************************************************* 6 * Copyright (C) 2003-2015, International Business Machines Corporation and 7 * others. All Rights Reserved. 8 ******************************************************************************* 9 */ 10 package ohos.global.icu.text; 11 12 import java.text.Format; 13 14 import ohos.global.icu.util.ULocale; 15 16 /** 17 * An abstract class that extends {@link java.text.Format} to provide 18 * additional ICU protocol, specifically, the <tt>getLocale()</tt> 19 * API. All ICU format classes are subclasses of this class. 20 * 21 * @see ohos.global.icu.util.ULocale 22 * @author weiv 23 * @author Alan Liu 24 */ 25 public abstract class UFormat extends Format { 26 // jdk1.4.2 serialver 27 private static final long serialVersionUID = -4964390515840164416L; 28 29 /** 30 * A field that represents a span of text that may be composed with other fields. 31 * SpanField classes usually have an associated value. 32 * 33 * @hide exposed on OHOS 34 */ 35 public static abstract class SpanField extends Format.Field { 36 private static final long serialVersionUID = -4732719509273350606L; 37 38 /** 39 * Construct a new instance. 40 */ SpanField(String name)41 protected SpanField(String name) { 42 super(name); 43 } 44 } 45 46 /** 47 * Default constructor. 48 */ UFormat()49 public UFormat() {} 50 51 // -------- BEGIN ULocale boilerplate -------- 52 53 /** 54 * Return the locale that was used to create this object, or null. 55 * This may may differ from the locale requested at the time of 56 * this object's creation. For example, if an object is created 57 * for locale <tt>en_US_CALIFORNIA</tt>, the actual data may be 58 * drawn from <tt>en</tt> (the <i>actual</i> locale), and 59 * <tt>en_US</tt> may be the most specific locale that exists (the 60 * <i>valid</i> locale). 61 * 62 * <p>Note: This method will be implemented in ICU 3.0; ICU 2.8 63 * contains a partial preview implementation. The <i>actual</i> 64 * locale is returned correctly, but the <i>valid</i> locale is 65 * not, in most cases. 66 * @param type type of information requested, either {@link 67 * ohos.global.icu.util.ULocale#VALID_LOCALE} or {@link 68 * ohos.global.icu.util.ULocale#ACTUAL_LOCALE}. 69 * @return the information specified by <i>type</i>, or null if 70 * this object was not constructed from locale data. 71 * @see ohos.global.icu.util.ULocale 72 * @see ohos.global.icu.util.ULocale#VALID_LOCALE 73 * @see ohos.global.icu.util.ULocale#ACTUAL_LOCALE 74 * @hide draft / provisional / internal are hidden on OHOS 75 */ getLocale(ULocale.Type type)76 public final ULocale getLocale(ULocale.Type type) { 77 return type == ULocale.ACTUAL_LOCALE ? 78 this.actualLocale : this.validLocale; 79 } 80 81 /** 82 * Set information about the locales that were used to create this 83 * object. If the object was not constructed from locale data, 84 * both arguments should be set to null. Otherwise, neither 85 * should be null. The actual locale must be at the same level or 86 * less specific than the valid locale. This method is intended 87 * for use by factories or other entities that create objects of 88 * this class. 89 * @param valid the most specific locale containing any resource 90 * data, or null 91 * @param actual the locale containing data used to construct this 92 * object, or null 93 * @see ohos.global.icu.util.ULocale 94 * @see ohos.global.icu.util.ULocale#VALID_LOCALE 95 * @see ohos.global.icu.util.ULocale#ACTUAL_LOCALE 96 */ setLocale(ULocale valid, ULocale actual)97 final void setLocale(ULocale valid, ULocale actual) { 98 // Change the following to an assertion later 99 if ((valid == null) != (actual == null)) { 100 ///CLOVER:OFF 101 throw new IllegalArgumentException(); 102 ///CLOVER:ON 103 } 104 // Another check we could do is that the actual locale is at 105 // the same level or less specific than the valid locale. 106 this.validLocale = valid; 107 this.actualLocale = actual; 108 } 109 110 /** 111 * The most specific locale containing any resource data, or null. 112 * @see ohos.global.icu.util.ULocale 113 */ 114 private ULocale validLocale; 115 116 /** 117 * The locale containing data used to construct this object, or 118 * null. 119 * @see ohos.global.icu.util.ULocale 120 */ 121 private ULocale actualLocale; 122 123 // -------- END ULocale boilerplate -------- 124 } 125