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 4 /* 5 ******************************************************************************* 6 * Copyright (C) 2003-2015, International Business Machines Corporation and 7 * others. All Rights Reserved. 8 ******************************************************************************* 9 */ 10 package android.icu.text; 11 12 import java.text.Format; 13 14 import android.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 android.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 Only a subset of ICU is exposed in Android 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 * android.icu.util.ULocale#VALID_LOCALE} or {@link 68 * android.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 android.icu.util.ULocale 72 * @see android.icu.util.ULocale#VALID_LOCALE 73 * @see android.icu.util.ULocale#ACTUAL_LOCALE 74 * @hide draft / provisional / internal are hidden on Android 75 */ 76 @android.compat.annotation.UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553) getLocale(ULocale.Type type)77 public final ULocale getLocale(ULocale.Type type) { 78 return type == ULocale.ACTUAL_LOCALE ? 79 this.actualLocale : this.validLocale; 80 } 81 82 /** 83 * Set information about the locales that were used to create this 84 * object. If the object was not constructed from locale data, 85 * both arguments should be set to null. Otherwise, neither 86 * should be null. The actual locale must be at the same level or 87 * less specific than the valid locale. This method is intended 88 * for use by factories or other entities that create objects of 89 * this class. 90 * @param valid the most specific locale containing any resource 91 * data, or null 92 * @param actual the locale containing data used to construct this 93 * object, or null 94 * @see android.icu.util.ULocale 95 * @see android.icu.util.ULocale#VALID_LOCALE 96 * @see android.icu.util.ULocale#ACTUAL_LOCALE 97 */ setLocale(ULocale valid, ULocale actual)98 final void setLocale(ULocale valid, ULocale actual) { 99 // Change the following to an assertion later 100 if ((valid == null) != (actual == null)) { 101 ///CLOVER:OFF 102 throw new IllegalArgumentException(); 103 ///CLOVER:ON 104 } 105 // Another check we could do is that the actual locale is at 106 // the same level or less specific than the valid locale. 107 this.validLocale = valid; 108 this.actualLocale = actual; 109 } 110 111 /** 112 * The most specific locale containing any resource data, or null. 113 * @see android.icu.util.ULocale 114 */ 115 private ULocale validLocale; 116 117 /** 118 * The locale containing data used to construct this object, or 119 * null. 120 * @see android.icu.util.ULocale 121 */ 122 private ULocale actualLocale; 123 124 // -------- END ULocale boilerplate -------- 125 } 126