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 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 * Default constructor. 31 */ 32 public UFormat() {} 33 34 // -------- BEGIN ULocale boilerplate -------- 35 36 /** 37 * Return the locale that was used to create this object, or null. 38 * This may may differ from the locale requested at the time of 39 * this object's creation. For example, if an object is created 40 * for locale <tt>en_US_CALIFORNIA</tt>, the actual data may be 41 * drawn from <tt>en</tt> (the <i>actual</i> locale), and 42 * <tt>en_US</tt> may be the most specific locale that exists (the 43 * <i>valid</i> locale). 44 * 45 * <p>Note: This method will be implemented in ICU 3.0; ICU 2.8 46 * contains a partial preview implementation. The <i>actual</i> 47 * locale is returned correctly, but the <i>valid</i> locale is 48 * not, in most cases. 49 * @param type type of information requested, either {@link 50 * android.icu.util.ULocale#VALID_LOCALE} or {@link 51 * android.icu.util.ULocale#ACTUAL_LOCALE}. 52 * @return the information specified by <i>type</i>, or null if 53 * this object was not constructed from locale data. 54 * @see android.icu.util.ULocale 55 * @see android.icu.util.ULocale#VALID_LOCALE 56 * @see android.icu.util.ULocale#ACTUAL_LOCALE 57 * @hide draft / provisional / internal are hidden on Android 58 */ 59 public final ULocale getLocale(ULocale.Type type) { 60 return type == ULocale.ACTUAL_LOCALE ? 61 this.actualLocale : this.validLocale; 62 } 63 64 /** 65 * Set information about the locales that were used to create this 66 * object. If the object was not constructed from locale data, 67 * both arguments should be set to null. Otherwise, neither 68 * should be null. The actual locale must be at the same level or 69 * less specific than the valid locale. This method is intended 70 * for use by factories or other entities that create objects of 71 * this class. 72 * @param valid the most specific locale containing any resource 73 * data, or null 74 * @param actual the locale containing data used to construct this 75 * object, or null 76 * @see android.icu.util.ULocale 77 * @see android.icu.util.ULocale#VALID_LOCALE 78 * @see android.icu.util.ULocale#ACTUAL_LOCALE 79 */ 80 final void setLocale(ULocale valid, ULocale actual) { 81 // Change the following to an assertion later 82 if ((valid == null) != (actual == null)) { 83 ///CLOVER:OFF 84 throw new IllegalArgumentException(); 85 ///CLOVER:ON 86 } 87 // Another check we could do is that the actual locale is at 88 // the same level or less specific than the valid locale. 89 this.validLocale = valid; 90 this.actualLocale = actual; 91 } 92 93 /** 94 * The most specific locale containing any resource data, or null. 95 * @see android.icu.util.ULocale 96 */ 97 private ULocale validLocale; 98 99 /** 100 * The locale containing data used to construct this object, or 101 * null. 102 * @see android.icu.util.ULocale 103 */ 104 private ULocale actualLocale; 105 106 // -------- END ULocale boilerplate -------- 107 } 108