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