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 * Copyright (C) 2000-2014, International Business Machines Corporation and 6 * others. All Rights Reserved. 7 **************************************************************************** 8 */ 9 10 package ohos.global.icu.text; 11 12 import java.util.Locale; 13 14 import ohos.global.icu.impl.ICUResourceBundle; 15 import ohos.global.icu.util.Calendar; 16 import ohos.global.icu.util.ChineseCalendar; 17 import ohos.global.icu.util.ULocale; 18 import ohos.global.icu.util.ULocale.Category; 19 20 /** 21 * A subclass of {@link DateFormatSymbols} for {@link ChineseDateFormat}. 22 * This class contains additional symbols corresponding to the 23 * <code>ChineseCalendar.IS_LEAP_MONTH</code> field. 24 * 25 * @see ChineseDateFormat 26 * @see ohos.global.icu.util.ChineseCalendar 27 * @author Alan Liu 28 * @deprecated ICU 50 29 * @hide exposed on OHOS 30 */ 31 @Deprecated 32 public class ChineseDateFormatSymbols extends DateFormatSymbols { 33 // Generated by serialver from JDK 1.4.1_01 34 static final long serialVersionUID = 6827816119783952890L; 35 36 /* 37 * Package-private array that ChineseDateFormat needs to be able to 38 * read. 39 */ 40 String[] isLeapMonth; 41 42 /** 43 * Construct a ChineseDateFormatSymbols for the default <code>FORMAT</code> locale. 44 * @see Category#FORMAT 45 * @deprecated ICU 50 46 */ 47 @Deprecated ChineseDateFormatSymbols()48 public ChineseDateFormatSymbols() { 49 this(ULocale.getDefault(Category.FORMAT)); 50 } 51 52 /** 53 * Construct a ChineseDateFormatSymbols for the provided locale. 54 * @param locale the locale 55 * @deprecated ICU 50 56 */ 57 @Deprecated ChineseDateFormatSymbols(Locale locale)58 public ChineseDateFormatSymbols(Locale locale) { 59 super(ChineseCalendar.class, ULocale.forLocale(locale)); 60 } 61 62 /** 63 * Construct a ChineseDateFormatSymbols for the provided locale. 64 * @param locale the locale 65 * @deprecated ICU 50 66 */ 67 @Deprecated ChineseDateFormatSymbols(ULocale locale)68 public ChineseDateFormatSymbols(ULocale locale) { 69 super(ChineseCalendar.class, locale); 70 } 71 72 /** 73 * Construct a ChineseDateFormatSymbols for the provided calendar and locale. 74 * @param cal the Calendar 75 * @param locale the locale 76 * @deprecated ICU 50 77 */ 78 @Deprecated ChineseDateFormatSymbols(Calendar cal, Locale locale)79 public ChineseDateFormatSymbols(Calendar cal, Locale locale) { 80 // NPE is thrown here when cal is null, like the super class does 81 super(cal.getClass(), locale); 82 } 83 84 /** 85 * Construct a ChineseDateFormatSymbols for the provided calendar and locale. 86 * @param cal the Calendar 87 * @param locale the locale 88 * @deprecated ICU 50 89 */ 90 @Deprecated ChineseDateFormatSymbols(Calendar cal, ULocale locale)91 public ChineseDateFormatSymbols(Calendar cal, ULocale locale) { 92 // NPE is thrown here when cal is null, like the super class does 93 super(cal.getClass(), locale); 94 } 95 96 // New API 97 /** 98 * @deprecated ICU 50 99 */ 100 @Deprecated getLeapMonth(int leap)101 public String getLeapMonth(int leap) { 102 return isLeapMonth[leap]; 103 } 104 105 /** 106 * {@inheritDoc} 107 * @deprecated ICU 50 108 */ 109 @Deprecated 110 @Override initializeData(ULocale loc, ICUResourceBundle b, String calendarType)111 protected void initializeData(ULocale loc, ICUResourceBundle b, String calendarType) { 112 super.initializeData(loc, b, calendarType); 113 initializeIsLeapMonth(); 114 } 115 116 @Override initializeData(DateFormatSymbols dfs)117 void initializeData(DateFormatSymbols dfs) { 118 super.initializeData(dfs); 119 if (dfs instanceof ChineseDateFormatSymbols) { 120 // read-only array, no need to clone 121 this.isLeapMonth = ((ChineseDateFormatSymbols)dfs).isLeapMonth; 122 } else { 123 initializeIsLeapMonth(); 124 } 125 } 126 initializeIsLeapMonth()127 private void initializeIsLeapMonth() { 128 // The old way, obsolete: 129 //isLeapMonth = calData.getStringArray("isLeapMonth"); 130 // The new way to fake this for backward compatibility (no longer used to format/parse): 131 132 isLeapMonth = new String[2]; 133 isLeapMonth[0] = ""; 134 isLeapMonth[1] = (leapMonthPatterns != null)? leapMonthPatterns[DT_LEAP_MONTH_PATTERN_FORMAT_WIDE].replace("{0}", ""): ""; 135 } 136 } 137