Home | History | Annotate | Download | only in unicode
      1 /*
      2 ********************************************************************************
      3 *   Copyright (C) 1997-2015, International Business Machines
      4 *   Corporation and others.  All Rights Reserved.
      5 ********************************************************************************
      6 *
      7 * File DTFMTSYM.H
      8 *
      9 * Modification History:
     10 *
     11 *   Date        Name        Description
     12 *   02/19/97    aliu        Converted from java.
     13 *    07/21/98    stephen        Added getZoneIndex()
     14 *                            Changed to match C++ conventions
     15 ********************************************************************************
     16 */
     17 
     18 #ifndef DTFMTSYM_H
     19 #define DTFMTSYM_H
     20 
     21 #include "unicode/utypes.h"
     22 
     23 #if !UCONFIG_NO_FORMATTING
     24 
     25 #include "unicode/calendar.h"
     26 #include "unicode/uobject.h"
     27 #include "unicode/locid.h"
     28 #include "unicode/udat.h"
     29 #include "unicode/ures.h"
     30 
     31 /**
     32  * \file
     33  * \brief C++ API: Symbols for formatting dates.
     34  */
     35 
     36 U_NAMESPACE_BEGIN
     37 
     38 /* forward declaration */
     39 class SimpleDateFormat;
     40 class Hashtable;
     41 
     42 /**
     43  * DateFormatSymbols is a public class for encapsulating localizable date-time
     44  * formatting data -- including timezone data. DateFormatSymbols is used by
     45  * DateFormat and SimpleDateFormat.
     46  * <P>
     47  * Rather than first creating a DateFormatSymbols to get a date-time formatter
     48  * by using a SimpleDateFormat constructor, clients are encouraged to create a
     49  * date-time formatter using the getTimeInstance(), getDateInstance(), or
     50  * getDateTimeInstance() method in DateFormat. Each of these methods can return a
     51  * date/time formatter initialized with a default format pattern along with the
     52  * date-time formatting data for a given or default locale. After a formatter is
     53  * created, clients may modify the format pattern using the setPattern function
     54  * as so desired. For more information on using these formatter factory
     55  * functions, see DateFormat.
     56  * <P>
     57  * If clients decide to create a date-time formatter with a particular format
     58  * pattern and locale, they can do so with new SimpleDateFormat(aPattern,
     59  * new DateFormatSymbols(aLocale)).  This will load the appropriate date-time
     60  * formatting data from the locale.
     61  * <P>
     62  * DateFormatSymbols objects are clonable. When clients obtain a
     63  * DateFormatSymbols object, they can feel free to modify the date-time
     64  * formatting data as necessary. For instance, clients can
     65  * replace the localized date-time format pattern characters with the ones that
     66  * they feel easy to remember. Or they can change the representative cities
     67  * originally picked by default to using their favorite ones.
     68  * <P>
     69  * DateFormatSymbols are not expected to be subclassed. Data for a calendar is
     70  * loaded out of resource bundles.  The 'type' parameter indicates the type of
     71  * calendar, for example, "gregorian" or "japanese".  If the type is not gregorian
     72  * (or NULL, or an empty string) then the type is appended to the resource name,
     73  * for example,  'Eras_japanese' instead of 'Eras'.   If the resource 'Eras_japanese' did
     74  * not exist (even in root), then this class will fall back to just 'Eras', that is,
     75  * Gregorian data.  Therefore, the calendar implementor MUST ensure that the root
     76  * locale at least contains any resources that are to be particularized for the
     77  * calendar type.
     78  */
     79 class U_I18N_API DateFormatSymbols U_FINAL : public UObject  {
     80 public:
     81     /**
     82      * Construct a DateFormatSymbols object by loading format data from
     83      * resources for the default locale, in the default calendar (Gregorian).
     84      * <P>
     85      * NOTE: This constructor will never fail; if it cannot get resource
     86      * data for the default locale, it will return a last-resort object
     87      * based on hard-coded strings.
     88      *
     89      * @param status    Status code.  Failure
     90      *                  results if the resources for the default cannot be
     91      *                  found or cannot be loaded
     92      * @stable ICU 2.0
     93      */
     94     DateFormatSymbols(UErrorCode& status);
     95 
     96     /**
     97      * Construct a DateFormatSymbols object by loading format data from
     98      * resources for the given locale, in the default calendar (Gregorian).
     99      *
    100      * @param locale    Locale to load format data from.
    101      * @param status    Status code.  Failure
    102      *                  results if the resources for the locale cannot be
    103      *                  found or cannot be loaded
    104      * @stable ICU 2.0
    105      */
    106     DateFormatSymbols(const Locale& locale,
    107                       UErrorCode& status);
    108 
    109 #ifndef U_HIDE_INTERNAL_API
    110     /**
    111      * Construct a DateFormatSymbols object by loading format data from
    112      * resources for the default locale, in the default calendar (Gregorian).
    113      * <P>
    114      * NOTE: This constructor will never fail; if it cannot get resource
    115      * data for the default locale, it will return a last-resort object
    116      * based on hard-coded strings.
    117      *
    118      * @param type      Type of calendar (as returned by Calendar::getType).
    119      *                  Will be used to access the correct set of strings.
    120      *                  (NULL or empty string defaults to "gregorian".)
    121      * @param status    Status code.  Failure
    122      *                  results if the resources for the default cannot be
    123      *                  found or cannot be loaded
    124      * @internal
    125      */
    126     DateFormatSymbols(const char *type, UErrorCode& status);
    127 
    128     /**
    129      * Construct a DateFormatSymbols object by loading format data from
    130      * resources for the given locale, in the default calendar (Gregorian).
    131      *
    132      * @param locale    Locale to load format data from.
    133      * @param type      Type of calendar (as returned by Calendar::getType).
    134      *                  Will be used to access the correct set of strings.
    135      *                  (NULL or empty string defaults to "gregorian".)
    136      * @param status    Status code.  Failure
    137      *                  results if the resources for the locale cannot be
    138      *                  found or cannot be loaded
    139      * @internal
    140      */
    141     DateFormatSymbols(const Locale& locale,
    142                       const char *type,
    143                       UErrorCode& status);
    144 #endif  /* U_HIDE_INTERNAL_API */
    145 
    146     /**
    147      * Copy constructor.
    148      * @stable ICU 2.0
    149      */
    150     DateFormatSymbols(const DateFormatSymbols&);
    151 
    152     /**
    153      * Assignment operator.
    154      * @stable ICU 2.0
    155      */
    156     DateFormatSymbols& operator=(const DateFormatSymbols&);
    157 
    158     /**
    159      * Destructor. This is nonvirtual because this class is not designed to be
    160      * subclassed.
    161      * @stable ICU 2.0
    162      */
    163     virtual ~DateFormatSymbols();
    164 
    165     /**
    166      * Return true if another object is semantically equal to this one.
    167      *
    168      * @param other    the DateFormatSymbols object to be compared with.
    169      * @return         true if other is semantically equal to this.
    170      * @stable ICU 2.0
    171      */
    172     UBool operator==(const DateFormatSymbols& other) const;
    173 
    174     /**
    175      * Return true if another object is semantically unequal to this one.
    176      *
    177      * @param other    the DateFormatSymbols object to be compared with.
    178      * @return         true if other is semantically unequal to this.
    179      * @stable ICU 2.0
    180      */
    181     UBool operator!=(const DateFormatSymbols& other) const { return !operator==(other); }
    182 
    183     /**
    184      * Gets abbreviated era strings. For example: "AD" and "BC".
    185      *
    186      * @param count    Filled in with length of the array.
    187      * @return         the era strings.
    188      * @stable ICU 2.0
    189      */
    190     const UnicodeString* getEras(int32_t& count) const;
    191 
    192     /**
    193      * Sets abbreviated era strings. For example: "AD" and "BC".
    194      * @param eras  Array of era strings (DateFormatSymbols retains ownership.)
    195      * @param count Filled in with length of the array.
    196      * @stable ICU 2.0
    197      */
    198     void setEras(const UnicodeString* eras, int32_t count);
    199 
    200     /**
    201      * Gets era name strings. For example: "Anno Domini" and "Before Christ".
    202      *
    203      * @param count    Filled in with length of the array.
    204      * @return         the era name strings.
    205      * @stable ICU 3.4
    206      */
    207     const UnicodeString* getEraNames(int32_t& count) const;
    208 
    209     /**
    210      * Sets era name strings. For example: "Anno Domini" and "Before Christ".
    211      * @param eraNames  Array of era name strings (DateFormatSymbols retains ownership.)
    212      * @param count Filled in with length of the array.
    213      * @stable ICU 3.6
    214      */
    215     void setEraNames(const UnicodeString* eraNames, int32_t count);
    216 
    217     /**
    218      * Gets narrow era strings. For example: "A" and "B".
    219      *
    220      * @param count    Filled in with length of the array.
    221      * @return         the narrow era strings.
    222      * @stable ICU 4.2
    223      */
    224     const UnicodeString* getNarrowEras(int32_t& count) const;
    225 
    226     /**
    227      * Sets narrow era strings. For example: "A" and "B".
    228      * @param narrowEras  Array of narrow era strings (DateFormatSymbols retains ownership.)
    229      * @param count Filled in with length of the array.
    230      * @stable ICU 4.2
    231      */
    232     void setNarrowEras(const UnicodeString* narrowEras, int32_t count);
    233 
    234     /**
    235      * Gets month strings. For example: "January", "February", etc.
    236      * @param count Filled in with length of the array.
    237      * @return the month strings. (DateFormatSymbols retains ownership.)
    238      * @stable ICU 2.0
    239      */
    240     const UnicodeString* getMonths(int32_t& count) const;
    241 
    242     /**
    243      * Sets month strings. For example: "January", "February", etc.
    244      *
    245      * @param months    the new month strings. (not adopted; caller retains ownership)
    246      * @param count     Filled in with length of the array.
    247      * @stable ICU 2.0
    248      */
    249     void setMonths(const UnicodeString* months, int32_t count);
    250 
    251     /**
    252      * Gets short month strings. For example: "Jan", "Feb", etc.
    253      *
    254      * @param count Filled in with length of the array.
    255      * @return the short month strings. (DateFormatSymbols retains ownership.)
    256      * @stable ICU 2.0
    257      */
    258     const UnicodeString* getShortMonths(int32_t& count) const;
    259 
    260     /**
    261      * Sets short month strings. For example: "Jan", "Feb", etc.
    262      * @param count        Filled in with length of the array.
    263      * @param shortMonths  the new short month strings. (not adopted; caller retains ownership)
    264      * @stable ICU 2.0
    265      */
    266     void setShortMonths(const UnicodeString* shortMonths, int32_t count);
    267 
    268     /**
    269      * Selector for date formatting context
    270      * @stable ICU 3.6
    271      */
    272     enum DtContextType {
    273          FORMAT,
    274          STANDALONE,
    275          DT_CONTEXT_COUNT
    276     };
    277 
    278     /**
    279      * Selector for date formatting width
    280      * @stable ICU 3.6
    281      */
    282     enum DtWidthType {
    283          ABBREVIATED,
    284          WIDE,
    285          NARROW,
    286          /**
    287           * Short width is currently only supported for weekday names.
    288           * @stable ICU 51
    289           */
    290          SHORT,
    291          /**
    292           */
    293          DT_WIDTH_COUNT = 4
    294     };
    295 
    296     /**
    297      * Gets month strings by width and context. For example: "January", "February", etc.
    298      * @param count Filled in with length of the array.
    299      * @param context The formatting context, either FORMAT or STANDALONE
    300      * @param width   The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
    301      * @return the month strings. (DateFormatSymbols retains ownership.)
    302      * @stable ICU 3.4
    303      */
    304     const UnicodeString* getMonths(int32_t& count, DtContextType context, DtWidthType width) const;
    305 
    306     /**
    307      * Sets month strings by width and context. For example: "January", "February", etc.
    308      *
    309      * @param months  The new month strings. (not adopted; caller retains ownership)
    310      * @param count   Filled in with length of the array.
    311      * @param context The formatting context, either FORMAT or STANDALONE
    312      * @param width   The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
    313      * @stable ICU 3.6
    314      */
    315     void setMonths(const UnicodeString* months, int32_t count, DtContextType context, DtWidthType width);
    316 
    317     /**
    318      * Gets wide weekday strings. For example: "Sunday", "Monday", etc.
    319      * @param count        Filled in with length of the array.
    320      * @return the weekday strings. (DateFormatSymbols retains ownership.)
    321      * @stable ICU 2.0
    322      */
    323     const UnicodeString* getWeekdays(int32_t& count) const;
    324 
    325 
    326     /**
    327      * Sets wide weekday strings. For example: "Sunday", "Monday", etc.
    328      * @param weekdays     the new weekday strings. (not adopted; caller retains ownership)
    329      * @param count        Filled in with length of the array.
    330      * @stable ICU 2.0
    331      */
    332     void setWeekdays(const UnicodeString* weekdays, int32_t count);
    333 
    334     /**
    335      * Gets abbreviated weekday strings. For example: "Sun", "Mon", etc. (Note: The method name is
    336      * misleading; it does not get the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.)
    337      * @param count        Filled in with length of the array.
    338      * @return             the abbreviated weekday strings. (DateFormatSymbols retains ownership.)
    339      * @stable ICU 2.0
    340      */
    341     const UnicodeString* getShortWeekdays(int32_t& count) const;
    342 
    343     /**
    344      * Sets abbreviated weekday strings. For example: "Sun", "Mon", etc. (Note: The method name is
    345      * misleading; it does not set the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.)
    346      * @param abbrevWeekdays  the new abbreviated weekday strings. (not adopted; caller retains ownership)
    347      * @param count           Filled in with length of the array.
    348      * @stable ICU 2.0
    349      */
    350     void setShortWeekdays(const UnicodeString* abbrevWeekdays, int32_t count);
    351 
    352     /**
    353      * Gets weekday strings by width and context. For example: "Sunday", "Monday", etc.
    354      * @param count   Filled in with length of the array.
    355      * @param context The formatting context, either FORMAT or STANDALONE
    356      * @param width   The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW
    357      * @return the month strings. (DateFormatSymbols retains ownership.)
    358      * @stable ICU 3.4
    359      */
    360     const UnicodeString* getWeekdays(int32_t& count, DtContextType context, DtWidthType width) const;
    361 
    362     /**
    363      * Sets weekday strings by width and context. For example: "Sunday", "Monday", etc.
    364      * @param weekdays  The new weekday strings. (not adopted; caller retains ownership)
    365      * @param count     Filled in with length of the array.
    366      * @param context   The formatting context, either FORMAT or STANDALONE
    367      * @param width     The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW
    368      * @stable ICU 3.6
    369      */
    370     void setWeekdays(const UnicodeString* weekdays, int32_t count, DtContextType context, DtWidthType width);
    371 
    372     /**
    373      * Gets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc.
    374      * @param count Filled in with length of the array.
    375      * @param context The formatting context, either FORMAT or STANDALONE
    376      * @param width   The width of returned strings, either WIDE or ABBREVIATED. There
    377      *                are no NARROW quarters.
    378      * @return the quarter strings. (DateFormatSymbols retains ownership.)
    379      * @stable ICU 3.6
    380      */
    381     const UnicodeString* getQuarters(int32_t& count, DtContextType context, DtWidthType width) const;
    382 
    383     /**
    384      * Sets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc.
    385      *
    386      * @param quarters  The new quarter strings. (not adopted; caller retains ownership)
    387      * @param count   Filled in with length of the array.
    388      * @param context The formatting context, either FORMAT or STANDALONE
    389      * @param width   The width of returned strings, either WIDE or ABBREVIATED. There
    390      *                are no NARROW quarters.
    391      * @stable ICU 3.6
    392      */
    393     void setQuarters(const UnicodeString* quarters, int32_t count, DtContextType context, DtWidthType width);
    394 
    395     /**
    396      * Gets AM/PM strings. For example: "AM" and "PM".
    397      * @param count        Filled in with length of the array.
    398      * @return             the weekday strings. (DateFormatSymbols retains ownership.)
    399      * @stable ICU 2.0
    400      */
    401     const UnicodeString* getAmPmStrings(int32_t& count) const;
    402 
    403     /**
    404      * Sets ampm strings. For example: "AM" and "PM".
    405      * @param ampms        the new ampm strings. (not adopted; caller retains ownership)
    406      * @param count        Filled in with length of the array.
    407      * @stable ICU 2.0
    408      */
    409     void setAmPmStrings(const UnicodeString* ampms, int32_t count);
    410 
    411 #ifndef U_HIDE_INTERNAL_API
    412     /**
    413      * This default time separator is used for formatting when the locale
    414      * doesn't specify any time separator, and always recognized when parsing.
    415      * @internal
    416      */
    417     static const UChar DEFAULT_TIME_SEPARATOR = 0x003a;  // ':'
    418 
    419     /**
    420      * This alternate time separator is always recognized when parsing.
    421      * @internal
    422      */
    423     static const UChar ALTERNATE_TIME_SEPARATOR = 0x002e;  // '.'
    424 #endif  /* U_HIDE_INTERNAL_API */
    425 
    426 #ifndef U_HIDE_DRAFT_API
    427     /**
    428      * Gets the time separator string. For example: ":".
    429      * @param result Output param which will receive the time separator string.
    430      * @return       A reference to 'result'.
    431      * @draft ICU 55
    432      */
    433     UnicodeString& getTimeSeparatorString(UnicodeString& result) const;
    434 
    435     /**
    436      * Sets the time separator string. For example: ":".
    437      * @param newTimeSeparator the new time separator string.
    438      * @draft ICU 55
    439      */
    440     void setTimeSeparatorString(const UnicodeString& newTimeSeparator);
    441 #endif  /* U_HIDE_DRAFT_API */
    442 
    443 #ifndef U_HIDE_DRAFT_API
    444     /**
    445      * Gets cyclic year name strings if the calendar has them, by width and context.
    446      * For example: "jia-zi", "yi-chou", etc.
    447      * @param count     Filled in with length of the array.
    448      * @param context   The usage context: FORMAT, STANDALONE.
    449      * @param width     The requested name width: WIDE, ABBREVIATED, NARROW.
    450      * @return          The year name strings (DateFormatSymbols retains ownership),
    451      *                  or null if they are not available for this calendar.
    452      * @draft ICU 54
    453      */
    454     const UnicodeString* getYearNames(int32_t& count,
    455                             DtContextType context, DtWidthType width) const;
    456 
    457     /**
    458      * Sets cyclic year name strings by width and context. For example: "jia-zi", "yi-chou", etc.
    459      *
    460      * @param yearNames The new cyclic year name strings (not adopted; caller retains ownership).
    461      * @param count     The length of the array.
    462      * @param context   The usage context: FORMAT, STANDALONE (currently only FORMAT is supported).
    463      * @param width     The name width: WIDE, ABBREVIATED, NARROW (currently only ABBREVIATED is supported).
    464      * @draft ICU 54
    465      */
    466     void setYearNames(const UnicodeString* yearNames, int32_t count,
    467                             DtContextType context, DtWidthType width);
    468 
    469     /**
    470      * Gets calendar zodiac name strings if the calendar has them, by width and context.
    471      * For example: "Rat", "Ox", "Tiger", etc.
    472      * @param count     Filled in with length of the array.
    473      * @param context   The usage context: FORMAT, STANDALONE.
    474      * @param width     The requested name width: WIDE, ABBREVIATED, NARROW.
    475      * @return          The zodiac name strings (DateFormatSymbols retains ownership),
    476      *                  or null if they are not available for this calendar.
    477      * @draft ICU 54
    478      */
    479     const UnicodeString* getZodiacNames(int32_t& count,
    480                             DtContextType context, DtWidthType width) const;
    481 
    482     /**
    483      * Sets calendar zodiac name strings by width and context. For example: "Rat", "Ox", "Tiger", etc.
    484      *
    485      * @param zodiacNames The new zodiac name strings (not adopted; caller retains ownership).
    486      * @param count     The length of the array.
    487      * @param context   The usage context: FORMAT, STANDALONE (currently only FORMAT is supported).
    488      * @param width     The name width: WIDE, ABBREVIATED, NARROW (currently only ABBREVIATED is supported).
    489      * @draft ICU 54
    490      */
    491     void setZodiacNames(const UnicodeString* zodiacNames, int32_t count,
    492                             DtContextType context, DtWidthType width);
    493 
    494 #endif  /* U_HIDE_DRAFT_API */
    495 
    496 #ifndef U_HIDE_INTERNAL_API
    497     /**
    498      * Somewhat temporary constants for leap month pattern types, adequate for supporting
    499      * just leap month patterns as needed for Chinese lunar calendar.
    500      * Eventually we will add full support for different month pattern types (needed for
    501      * other calendars such as Hindu) at which point this approach will be replaced by a
    502      * more complete approach.
    503      * @internal
    504      */
    505     enum EMonthPatternType
    506     {
    507         kLeapMonthPatternFormatWide,
    508         kLeapMonthPatternFormatAbbrev,
    509         kLeapMonthPatternFormatNarrow,
    510         kLeapMonthPatternStandaloneWide,
    511         kLeapMonthPatternStandaloneAbbrev,
    512         kLeapMonthPatternStandaloneNarrow,
    513         kLeapMonthPatternNumeric,
    514         kMonthPatternsCount
    515     };
    516 
    517     /**
    518      * Somewhat temporary function for getting complete set of leap month patterns for all
    519      * contexts & widths, indexed by EMonthPatternType values. Returns NULL if calendar
    520      * does not have leap month patterns. Note, there is currently no setter for this.
    521      * Eventually we will add full support for different month pattern types (needed for
    522      * other calendars such as Hindu) at which point this approach will be replaced by a
    523      * more complete approach.
    524      * @param count        Filled in with length of the array (may be 0).
    525      * @return             The leap month patterns (DateFormatSymbols retains ownership).
    526      *                     May be NULL if there are no leap month patterns for this calendar.
    527      * @internal
    528      */
    529     const UnicodeString* getLeapMonthPatterns(int32_t& count) const;
    530 
    531 #endif  /* U_HIDE_INTERNAL_API */
    532 
    533 #ifndef U_HIDE_DEPRECATED_API
    534     /**
    535      * Gets timezone strings. These strings are stored in a 2-dimensional array.
    536      * @param rowCount      Output param to receive number of rows.
    537      * @param columnCount   Output param to receive number of columns.
    538      * @return              The timezone strings as a 2-d array. (DateFormatSymbols retains ownership.)
    539      * @deprecated ICU 3.6
    540      */
    541     const UnicodeString** getZoneStrings(int32_t& rowCount, int32_t& columnCount) const;
    542 #endif  /* U_HIDE_DEPRECATED_API */
    543 
    544     /**
    545      * Sets timezone strings. These strings are stored in a 2-dimensional array.
    546      * <p><b>Note:</b> SimpleDateFormat no longer use the zone strings stored in
    547      * a DateFormatSymbols. Therefore, the time zone strings set by this mthod
    548      * have no effects in an instance of SimpleDateFormat for formatting time
    549      * zones.
    550      * @param strings       The timezone strings as a 2-d array to be copied. (not adopted; caller retains ownership)
    551      * @param rowCount      The number of rows (count of first index).
    552      * @param columnCount   The number of columns (count of second index).
    553      * @stable ICU 2.0
    554      */
    555     void setZoneStrings(const UnicodeString* const* strings, int32_t rowCount, int32_t columnCount);
    556 
    557     /**
    558      * Get the non-localized date-time pattern characters.
    559      * @return    the non-localized date-time pattern characters
    560      * @stable ICU 2.0
    561      */
    562     static const UChar * U_EXPORT2 getPatternUChars(void);
    563 
    564     /**
    565      * Gets localized date-time pattern characters. For example: 'u', 't', etc.
    566      * <p>
    567      * Note: ICU no longer provides localized date-time pattern characters for a locale
    568      * starting ICU 3.8.  This method returns the non-localized date-time pattern
    569      * characters unless user defined localized data is set by setLocalPatternChars.
    570      * @param result    Output param which will receive the localized date-time pattern characters.
    571      * @return          A reference to 'result'.
    572      * @stable ICU 2.0
    573      */
    574     UnicodeString& getLocalPatternChars(UnicodeString& result) const;
    575 
    576     /**
    577      * Sets localized date-time pattern characters. For example: 'u', 't', etc.
    578      * @param newLocalPatternChars the new localized date-time
    579      * pattern characters.
    580      * @stable ICU 2.0
    581      */
    582     void setLocalPatternChars(const UnicodeString& newLocalPatternChars);
    583 
    584     /**
    585      * Returns the locale for this object. Two flavors are available:
    586      * valid and actual locale.
    587      * @stable ICU 2.8
    588      */
    589     Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
    590 
    591     /* The following type and kCapContextUsageTypeCount cannot be #ifndef U_HIDE_INTERNAL_API,
    592        they are needed for .h file declarations. */
    593     /**
    594      * Constants for capitalization context usage types.
    595      * @internal
    596      */
    597     enum ECapitalizationContextUsageType
    598     {
    599 #ifndef U_HIDE_INTERNAL_API
    600         kCapContextUsageOther = 0,
    601         kCapContextUsageMonthFormat,     /* except narrow */
    602         kCapContextUsageMonthStandalone, /* except narrow */
    603         kCapContextUsageMonthNarrow,
    604         kCapContextUsageDayFormat,     /* except narrow */
    605         kCapContextUsageDayStandalone, /* except narrow */
    606         kCapContextUsageDayNarrow,
    607         kCapContextUsageEraWide,
    608         kCapContextUsageEraAbbrev,
    609         kCapContextUsageEraNarrow,
    610         kCapContextUsageZoneLong,
    611         kCapContextUsageZoneShort,
    612         kCapContextUsageMetazoneLong,
    613         kCapContextUsageMetazoneShort,
    614 #endif /* U_HIDE_INTERNAL_API */
    615         kCapContextUsageTypeCount = 14
    616     };
    617 
    618     /**
    619      * ICU "poor man's RTTI", returns a UClassID for the actual class.
    620      *
    621      * @stable ICU 2.2
    622      */
    623     virtual UClassID getDynamicClassID() const;
    624 
    625     /**
    626      * ICU "poor man's RTTI", returns a UClassID for this class.
    627      *
    628      * @stable ICU 2.2
    629      */
    630     static UClassID U_EXPORT2 getStaticClassID();
    631 
    632 private:
    633 
    634     friend class SimpleDateFormat;
    635     friend class DateFormatSymbolsSingleSetter; // see udat.cpp
    636 
    637     /**
    638      * Abbreviated era strings. For example: "AD" and "BC".
    639      */
    640     UnicodeString*  fEras;
    641     int32_t         fErasCount;
    642 
    643     /**
    644      * Era name strings. For example: "Anno Domini" and "Before Christ".
    645      */
    646     UnicodeString*  fEraNames;
    647     int32_t         fEraNamesCount;
    648 
    649     /**
    650      * Narrow era strings. For example: "A" and "B".
    651      */
    652     UnicodeString*  fNarrowEras;
    653     int32_t         fNarrowErasCount;
    654 
    655     /**
    656      * Month strings. For example: "January", "February", etc.
    657      */
    658     UnicodeString*  fMonths;
    659     int32_t         fMonthsCount;
    660 
    661     /**
    662      * Short month strings. For example: "Jan", "Feb", etc.
    663      */
    664     UnicodeString*  fShortMonths;
    665     int32_t         fShortMonthsCount;
    666 
    667     /**
    668      * Narrow month strings. For example: "J", "F", etc.
    669      */
    670     UnicodeString*  fNarrowMonths;
    671     int32_t         fNarrowMonthsCount;
    672 
    673     /**
    674      * Standalone Month strings. For example: "January", "February", etc.
    675      */
    676     UnicodeString*  fStandaloneMonths;
    677     int32_t         fStandaloneMonthsCount;
    678 
    679     /**
    680      * Standalone Short month strings. For example: "Jan", "Feb", etc.
    681      */
    682     UnicodeString*  fStandaloneShortMonths;
    683     int32_t         fStandaloneShortMonthsCount;
    684 
    685     /**
    686      * Standalone Narrow month strings. For example: "J", "F", etc.
    687      */
    688     UnicodeString*  fStandaloneNarrowMonths;
    689     int32_t         fStandaloneNarrowMonthsCount;
    690 
    691     /**
    692      * CLDR-style format wide weekday strings. For example: "Sunday", "Monday", etc.
    693      */
    694     UnicodeString*  fWeekdays;
    695     int32_t         fWeekdaysCount;
    696 
    697     /**
    698      * CLDR-style format abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc.
    699      */
    700     UnicodeString*  fShortWeekdays;
    701     int32_t         fShortWeekdaysCount;
    702 
    703     /**
    704      * CLDR-style format short weekday strings. For example: "Su", "Mo", etc.
    705      */
    706     UnicodeString*  fShorterWeekdays;
    707     int32_t         fShorterWeekdaysCount;
    708 
    709     /**
    710      * CLDR-style format narrow weekday strings. For example: "S", "M", etc.
    711      */
    712     UnicodeString*  fNarrowWeekdays;
    713     int32_t         fNarrowWeekdaysCount;
    714 
    715     /**
    716      * CLDR-style standalone wide weekday strings. For example: "Sunday", "Monday", etc.
    717      */
    718     UnicodeString*  fStandaloneWeekdays;
    719     int32_t         fStandaloneWeekdaysCount;
    720 
    721     /**
    722      * CLDR-style standalone abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc.
    723      */
    724     UnicodeString*  fStandaloneShortWeekdays;
    725     int32_t         fStandaloneShortWeekdaysCount;
    726 
    727     /**
    728      * CLDR-style standalone short weekday strings. For example: "Su", "Mo", etc.
    729      */
    730     UnicodeString*  fStandaloneShorterWeekdays;
    731     int32_t         fStandaloneShorterWeekdaysCount;
    732 
    733     /**
    734      * Standalone Narrow weekday strings. For example: "Sun", "Mon", etc.
    735      */
    736     UnicodeString*  fStandaloneNarrowWeekdays;
    737     int32_t         fStandaloneNarrowWeekdaysCount;
    738 
    739     /**
    740      * Ampm strings. For example: "AM" and "PM".
    741      */
    742     UnicodeString*  fAmPms;
    743     int32_t         fAmPmsCount;
    744 
    745     /**
    746      * Narrow Ampm strings. For example: "a" and "p".
    747      */
    748     UnicodeString*  fNarrowAmPms;
    749     int32_t         fNarrowAmPmsCount;
    750 
    751     /**
    752      * Time separator string. For example: ":".
    753      */
    754     UnicodeString   fTimeSeparator;
    755 
    756     /**
    757      * Quarter strings. For example: "1st quarter", "2nd quarter", etc.
    758      */
    759     UnicodeString  *fQuarters;
    760     int32_t         fQuartersCount;
    761 
    762     /**
    763      * Short quarters. For example: "Q1", "Q2", etc.
    764      */
    765     UnicodeString  *fShortQuarters;
    766     int32_t         fShortQuartersCount;
    767 
    768     /**
    769      * Standalone quarter strings. For example: "1st quarter", "2nd quarter", etc.
    770      */
    771     UnicodeString  *fStandaloneQuarters;
    772     int32_t         fStandaloneQuartersCount;
    773 
    774     /**
    775      * Standalone short quarter strings. For example: "Q1", "Q2", etc.
    776      */
    777     UnicodeString  *fStandaloneShortQuarters;
    778     int32_t         fStandaloneShortQuartersCount;
    779 
    780     /**
    781      * All leap month patterns, for example "{0}bis".
    782      */
    783     UnicodeString  *fLeapMonthPatterns;
    784     int32_t         fLeapMonthPatternsCount;
    785 
    786     /**
    787      * Cyclic year names, for example: "jia-zi", "yi-chou", ... "gui-hai";
    788      * currently we only have data for format/abbreviated.
    789      * For the others, just get from format/abbreviated, ignore set.
    790      */
    791     UnicodeString  *fShortYearNames;
    792     int32_t         fShortYearNamesCount;
    793 
    794     /**
    795      * Cyclic zodiac names, for example "Rat", "Ox", "Tiger", etc.;
    796      * currently we only have data for format/abbreviated.
    797      * For the others, just get from format/abbreviated, ignore set.
    798      */
    799     UnicodeString  *fShortZodiacNames;
    800     int32_t         fShortZodiacNamesCount;
    801 
    802     /**
    803      * Localized names of time zones in this locale.  This is a
    804      * two-dimensional array of strings of size n by m,
    805      * where m is at least 5 and up to 7.  Each of the n rows is an
    806      * entry containing the localized names for a single TimeZone.
    807      *
    808      * Each such row contains (with i ranging from 0..n-1):
    809      *
    810      * zoneStrings[i][0] - time zone ID
    811      *  example: America/Los_Angeles
    812      * zoneStrings[i][1] - long name of zone in standard time
    813      *  example: Pacific Standard Time
    814      * zoneStrings[i][2] - short name of zone in standard time
    815      *  example: PST
    816      * zoneStrings[i][3] - long name of zone in daylight savings time
    817      *  example: Pacific Daylight Time
    818      * zoneStrings[i][4] - short name of zone in daylight savings time
    819      *  example: PDT
    820      * zoneStrings[i][5] - location name of zone
    821      *  example: United States (Los Angeles)
    822      * zoneStrings[i][6] - long generic name of zone
    823      *  example: Pacific Time
    824      * zoneStrings[i][7] - short generic of zone
    825      *  example: PT
    826      *
    827      * The zone ID is not localized; it corresponds to the ID
    828      * value associated with a system time zone object.  All other entries
    829      * are localized names.  If a zone does not implement daylight savings
    830      * time, the daylight savings time names are ignored.
    831      *
    832      * Note:CLDR 1.5 introduced metazone and its historical mappings.
    833      * This simple two-dimensional array is no longer sufficient to represent
    834      * localized names and its historic changes.  Since ICU 3.8.1, localized
    835      * zone names extracted from ICU locale data is stored in a ZoneStringFormat
    836      * instance.  But we still need to support the old way of customizing
    837      * localized zone names, so we keep this field for the purpose.
    838      */
    839     UnicodeString   **fZoneStrings;         // Zone string array set by setZoneStrings
    840     UnicodeString   **fLocaleZoneStrings;   // Zone string array created by the locale
    841     int32_t         fZoneStringsRowCount;
    842     int32_t         fZoneStringsColCount;
    843 
    844     Locale                  fZSFLocale;         // Locale used for getting ZoneStringFormat
    845 
    846     /**
    847      * Localized date-time pattern characters. For example: use 'u' as 'y'.
    848      */
    849     UnicodeString   fLocalPatternChars;
    850 
    851     /**
    852      * Capitalization transforms. For each usage type, the first array element indicates
    853      * whether to titlecase for uiListOrMenu context, the second indicates whether to
    854      * titlecase for stand-alone context.
    855      */
    856      UBool fCapitalization[kCapContextUsageTypeCount][2];
    857 
    858 private:
    859     /** valid/actual locale information
    860      *  these are always ICU locales, so the length should not be a problem
    861      */
    862     char validLocale[ULOC_FULLNAME_CAPACITY];
    863     char actualLocale[ULOC_FULLNAME_CAPACITY];
    864 
    865     DateFormatSymbols(); // default constructor not implemented
    866 
    867     /**
    868      * Called by the constructors to actually load data from the resources
    869      *
    870      * @param locale               The locale to get symbols for.
    871      * @param type                 Calendar Type (as from Calendar::getType())
    872      * @param status               Input/output parameter, set to success or
    873      *                             failure code upon return.
    874      * @param useLastResortData    determine if use last resort data
    875      */
    876     void initializeData(const Locale& locale, const char *type, UErrorCode& status, UBool useLastResortData = FALSE);
    877 
    878     /**
    879      * Copy or alias an array in another object, as appropriate.
    880      *
    881      * @param dstArray    the copy destination array.
    882      * @param dstCount    fill in with the lenth of 'dstArray'.
    883      * @param srcArray    the source array to be copied.
    884      * @param srcCount    the length of items to be copied from the 'srcArray'.
    885      */
    886     static void assignArray(UnicodeString*& dstArray,
    887                             int32_t& dstCount,
    888                             const UnicodeString* srcArray,
    889                             int32_t srcCount);
    890 
    891     /**
    892      * Return true if the given arrays' contents are equal, or if the arrays are
    893      * identical (pointers are equal).
    894      *
    895      * @param array1   one array to be compared with.
    896      * @param array2   another array to be compared with.
    897      * @param count    the length of items to be copied.
    898      * @return         true if the given arrays' contents are equal, or if the arrays are
    899      *                 identical (pointers are equal).
    900      */
    901     static UBool arrayCompare(const UnicodeString* array1,
    902                              const UnicodeString* array2,
    903                              int32_t count);
    904 
    905     /**
    906      * Create a copy, in fZoneStrings, of the given zone strings array. The
    907      * member variables fZoneStringsRowCount and fZoneStringsColCount should be
    908      * set already by the caller.
    909      */
    910     void createZoneStrings(const UnicodeString *const * otherStrings);
    911 
    912     /**
    913      * Delete all the storage owned by this object.
    914      */
    915     void dispose(void);
    916 
    917     /**
    918      * Copy all of the other's data to this.
    919      * @param other the object to be copied.
    920      */
    921     void copyData(const DateFormatSymbols& other);
    922 
    923     /**
    924      * Create zone strings array by locale if not yet available
    925      */
    926     void initZoneStringsArray(void);
    927 
    928     /**
    929      * Delete just the zone strings.
    930      */
    931     void disposeZoneStrings(void);
    932 
    933     /**
    934      * Returns the date format field index of the pattern character c,
    935      * or UDAT_FIELD_COUNT if c is not a pattern character.
    936      */
    937     static UDateFormatField U_EXPORT2 getPatternCharIndex(UChar c);
    938 
    939     /**
    940      * Returns TRUE if f (with its pattern character repeated count times) is a numeric field.
    941      */
    942     static UBool U_EXPORT2 isNumericField(UDateFormatField f, int32_t count);
    943 
    944     /**
    945      * Returns TRUE if c (repeated count times) is the pattern character for a numeric field.
    946      */
    947     static UBool U_EXPORT2 isNumericPatternChar(UChar c, int32_t count);
    948 public:
    949 #ifndef U_HIDE_INTERNAL_API
    950     /**
    951      * Gets a DateFormatSymbols by locale.
    952      * Unlike the constructors which always use gregorian calendar, this
    953      * method uses the calendar in the locale. If the locale contains no
    954      * explicit calendar, this method uses the default calendar for that
    955      * locale.
    956      * @param locale the locale.
    957      * @param status error returned here.
    958      * @return the new DateFormatSymbols which the caller owns.
    959      * @internal For ICU use only.
    960      */
    961     static DateFormatSymbols * U_EXPORT2 createForLocale(
    962             const Locale &locale, UErrorCode &status);
    963 #endif  /* U_HIDE_INTERNAL_API */
    964 };
    965 
    966 U_NAMESPACE_END
    967 
    968 #endif /* #if !UCONFIG_NO_FORMATTING */
    969 
    970 #endif // _DTFMTSYM
    971 //eof
    972