jdk/src/share/classes/java/text/DateFormatSymbols.java
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 2 90ce3da70b43
child 6489 9e7015635425
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * (C) Copyright Taligent, Inc. 1996 - All Rights Reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * (C) Copyright IBM Corp. 1996 - All Rights Reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *   The original version of this source code and documentation is copyrighted
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * materials are provided under terms of a License Agreement between Taligent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * and Sun. This technology is protected by multiple US and International
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * patents. This notice and attribution to Taligent may not be removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *   Taligent is a registered trademark of Taligent, Inc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
package java.text;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import java.lang.ref.SoftReference;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import java.text.spi.DateFormatSymbolsProvider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import java.util.Arrays;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import java.util.Hashtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import java.util.Locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
import java.util.ResourceBundle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import java.util.TimeZone;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import java.util.spi.LocaleServiceProvider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
import sun.util.LocaleServiceProviderPool;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
import sun.util.TimeZoneNameUtility;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
import sun.util.calendar.ZoneInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
import sun.util.resources.LocaleData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * <code>DateFormatSymbols</code> is a public class for encapsulating
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * localizable date-time formatting data, such as the names of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * months, the names of the days of the week, and the time zone data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * <code>DateFormat</code> and <code>SimpleDateFormat</code> both use
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * <code>DateFormatSymbols</code> to encapsulate this information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * Typically you shouldn't use <code>DateFormatSymbols</code> directly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * Rather, you are encouraged to create a date-time formatter with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * <code>DateFormat</code> class's factory methods: <code>getTimeInstance</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * <code>getDateInstance</code>, or <code>getDateTimeInstance</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * These methods automatically create a <code>DateFormatSymbols</code> for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * the formatter so that you don't have to. After the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * formatter is created, you may modify its format pattern using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * <code>setPattern</code> method. For more information about
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * creating formatters using <code>DateFormat</code>'s factory methods,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * see {@link DateFormat}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * If you decide to create a date-time formatter with a specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * format pattern for a specific locale, you can do so with:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * new SimpleDateFormat(aPattern, DateFormatSymbols.getInstance(aLocale)).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * <code>DateFormatSymbols</code> objects are cloneable. When you obtain
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * a <code>DateFormatSymbols</code> object, feel free to modify the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * date-time formatting data. For instance, you can replace the localized
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * date-time format pattern characters with the ones that you feel easy
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * to remember. Or you can change the representative cities
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * to your favorite ones.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * New <code>DateFormatSymbols</code> subclasses may be added to support
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * <code>SimpleDateFormat</code> for date-time formatting for additional locales.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * @see          DateFormat
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * @see          SimpleDateFormat
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * @see          java.util.SimpleTimeZone
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * @author       Chen-Lieh Huang
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
public class DateFormatSymbols implements Serializable, Cloneable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * Construct a DateFormatSymbols object by loading format data from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * resources for the default locale. This constructor can only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * construct instances for the locales supported by the Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * runtime environment, not for those supported by installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * implementations. For full locale coverage, use the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * {@link #getInstance(Locale) getInstance} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @see #getInstance()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * @exception  java.util.MissingResourceException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *             if the resources for the default locale cannot be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     *             found or cannot be loaded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    public DateFormatSymbols()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        initializeData(Locale.getDefault());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * Construct a DateFormatSymbols object by loading format data from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * resources for the given locale. This constructor can only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * construct instances for the locales supported by the Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * runtime environment, not for those supported by installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * implementations. For full locale coverage, use the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * {@link #getInstance(Locale) getInstance} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @see #getInstance(Locale)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @exception  java.util.MissingResourceException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     *             if the resources for the specified locale cannot be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     *             found or cannot be loaded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    public DateFormatSymbols(Locale locale)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        initializeData(locale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * Era strings. For example: "AD" and "BC".  An array of 2 strings,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * indexed by <code>Calendar.BC</code> and <code>Calendar.AD</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    String eras[] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * Month strings. For example: "January", "February", etc.  An array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * of 13 strings (some calendars have 13 months), indexed by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * <code>Calendar.JANUARY</code>, <code>Calendar.FEBRUARY</code>, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    String months[] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * Short month strings. For example: "Jan", "Feb", etc.  An array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * 13 strings (some calendars have 13 months), indexed by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * <code>Calendar.JANUARY</code>, <code>Calendar.FEBRUARY</code>, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    String shortMonths[] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * Weekday strings. For example: "Sunday", "Monday", etc.  An array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * of 8 strings, indexed by <code>Calendar.SUNDAY</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * <code>Calendar.MONDAY</code>, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * The element <code>weekdays[0]</code> is ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    String weekdays[] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * Short weekday strings. For example: "Sun", "Mon", etc.  An array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * of 8 strings, indexed by <code>Calendar.SUNDAY</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * <code>Calendar.MONDAY</code>, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * The element <code>shortWeekdays[0]</code> is ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    String shortWeekdays[] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * AM and PM strings. For example: "AM" and "PM".  An array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * 2 strings, indexed by <code>Calendar.AM</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * <code>Calendar.PM</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    String ampms[] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * Localized names of time zones in this locale.  This is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * two-dimensional array of strings of size <em>n</em> by <em>m</em>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * where <em>m</em> is at least 5.  Each of the <em>n</em> rows is an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * entry containing the localized names for a single <code>TimeZone</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * Each such row contains (with <code>i</code> ranging from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * 0..<em>n</em>-1):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * <li><code>zoneStrings[i][0]</code> - time zone ID</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * <li><code>zoneStrings[i][1]</code> - long name of zone in standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * time</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * <li><code>zoneStrings[i][2]</code> - short name of zone in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * standard time</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * <li><code>zoneStrings[i][3]</code> - long name of zone in daylight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * saving time</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * <li><code>zoneStrings[i][4]</code> - short name of zone in daylight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * saving time</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * The zone ID is <em>not</em> localized; it's one of the valid IDs of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * the {@link java.util.TimeZone TimeZone} class that are not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * <a href="../java/util/TimeZone.html#CustomID">custom IDs</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * All other entries are localized names.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * @see java.util.TimeZone
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    String zoneStrings[][] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * Indicates that zoneStrings is set externally with setZoneStrings() method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    transient boolean isZoneStringsSet = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * Unlocalized date-time pattern characters. For example: 'y', 'd', etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * All locales use the same these unlocalized pattern characters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    static final String  patternChars = "GyMdkHmsSEDFwWahKzZ";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * Localized date-time pattern characters. For example, a locale may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * wish to use 'u' rather than 'y' to represent years in its date format
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * pattern strings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * This string must be exactly 18 characters long, with the index of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * the characters described by <code>DateFormat.ERA_FIELD</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * <code>DateFormat.YEAR_FIELD</code>, etc.  Thus, if the string were
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * "Xz...", then localized patterns would use 'X' for era and 'z' for year.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    String  localPatternChars = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * The locale which is used for initializing this DateFormatSymbols object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    Locale locale = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    /* use serialVersionUID from JDK 1.1.4 for interoperability */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    static final long serialVersionUID = -5987973545549424702L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * Returns an array of all locales for which the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * <code>getInstance</code> methods of this class can return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * localized instances.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * The returned array represents the union of locales supported by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * Java runtime and by installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * implementations.  It must contain at least a <code>Locale</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * instance equal to {@link java.util.Locale#US Locale.US}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * @return An array of locales for which localized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     *         <code>DateFormatSymbols</code> instances are available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    public static Locale[] getAvailableLocales() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        LocaleServiceProviderPool pool=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            LocaleServiceProviderPool.getPool(DateFormatSymbolsProvider.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        return pool.getAvailableLocales();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * Gets the <code>DateFormatSymbols</code> instance for the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * locale.  This method provides access to <code>DateFormatSymbols</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * instances for locales supported by the Java runtime itself as well
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * as for those supported by installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * implementations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * @return a <code>DateFormatSymbols</code> instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    public static final DateFormatSymbols getInstance() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        return getInstance(Locale.getDefault());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * Gets the <code>DateFormatSymbols</code> instance for the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * locale.  This method provides access to <code>DateFormatSymbols</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * instances for locales supported by the Java runtime itself as well
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * as for those supported by installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * implementations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * @param locale the given locale.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * @return a <code>DateFormatSymbols</code> instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * @exception NullPointerException if <code>locale</code> is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    public static final DateFormatSymbols getInstance(Locale locale) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        // Check whether a provider can provide an implementation that's closer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        // to the requested locale than what the Java runtime itself can provide.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        LocaleServiceProviderPool pool =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            LocaleServiceProviderPool.getPool(DateFormatSymbolsProvider.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        if (pool.hasProviders()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            DateFormatSymbols providersInstance = pool.getLocalizedObject(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                                DateFormatSymbolsGetter.INSTANCE, locale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
            if (providersInstance != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                return providersInstance;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        return new DateFormatSymbols(locale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * Gets era strings. For example: "AD" and "BC".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * @return the era strings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    public String[] getEras() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        return Arrays.copyOf(eras, eras.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * Sets era strings. For example: "AD" and "BC".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * @param newEras the new era strings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    public void setEras(String[] newEras) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        eras = Arrays.copyOf(newEras, newEras.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * Gets month strings. For example: "January", "February", etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * @return the month strings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    public String[] getMonths() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        return Arrays.copyOf(months, months.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * Sets month strings. For example: "January", "February", etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * @param newMonths the new month strings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    public void setMonths(String[] newMonths) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        months = Arrays.copyOf(newMonths, newMonths.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * Gets short month strings. For example: "Jan", "Feb", etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * @return the short month strings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    public String[] getShortMonths() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        return Arrays.copyOf(shortMonths, shortMonths.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * Sets short month strings. For example: "Jan", "Feb", etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * @param newShortMonths the new short month strings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    public void setShortMonths(String[] newShortMonths) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        shortMonths = Arrays.copyOf(newShortMonths, newShortMonths.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * Gets weekday strings. For example: "Sunday", "Monday", etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * @return the weekday strings. Use <code>Calendar.SUNDAY</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * <code>Calendar.MONDAY</code>, etc. to index the result array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    public String[] getWeekdays() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        return Arrays.copyOf(weekdays, weekdays.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * Sets weekday strings. For example: "Sunday", "Monday", etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * @param newWeekdays the new weekday strings. The array should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * be indexed by <code>Calendar.SUNDAY</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * <code>Calendar.MONDAY</code>, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    public void setWeekdays(String[] newWeekdays) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        weekdays = Arrays.copyOf(newWeekdays, newWeekdays.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * Gets short weekday strings. For example: "Sun", "Mon", etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * @return the short weekday strings. Use <code>Calendar.SUNDAY</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * <code>Calendar.MONDAY</code>, etc. to index the result array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    public String[] getShortWeekdays() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        return Arrays.copyOf(shortWeekdays, shortWeekdays.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * Sets short weekday strings. For example: "Sun", "Mon", etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * @param newShortWeekdays the new short weekday strings. The array should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * be indexed by <code>Calendar.SUNDAY</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * <code>Calendar.MONDAY</code>, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    public void setShortWeekdays(String[] newShortWeekdays) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        shortWeekdays = Arrays.copyOf(newShortWeekdays, newShortWeekdays.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * Gets ampm strings. For example: "AM" and "PM".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * @return the ampm strings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    public String[] getAmPmStrings() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        return Arrays.copyOf(ampms, ampms.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * Sets ampm strings. For example: "AM" and "PM".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * @param newAmpms the new ampm strings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    public void setAmPmStrings(String[] newAmpms) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        ampms = Arrays.copyOf(newAmpms, newAmpms.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * Gets time zone strings.  Use of this method is discouraged; use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * {@link java.util.TimeZone#getDisplayName() TimeZone.getDisplayName()}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * instead.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * The value returned is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * two-dimensional array of strings of size <em>n</em> by <em>m</em>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * where <em>m</em> is at least 5.  Each of the <em>n</em> rows is an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * entry containing the localized names for a single <code>TimeZone</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * Each such row contains (with <code>i</code> ranging from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * 0..<em>n</em>-1):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * <li><code>zoneStrings[i][0]</code> - time zone ID</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * <li><code>zoneStrings[i][1]</code> - long name of zone in standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * time</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * <li><code>zoneStrings[i][2]</code> - short name of zone in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * standard time</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * <li><code>zoneStrings[i][3]</code> - long name of zone in daylight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * saving time</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * <li><code>zoneStrings[i][4]</code> - short name of zone in daylight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * saving time</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * The zone ID is <em>not</em> localized; it's one of the valid IDs of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * the {@link java.util.TimeZone TimeZone} class that are not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * <a href="../util/TimeZone.html#CustomID">custom IDs</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * All other entries are localized names.  If a zone does not implement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * daylight saving time, the daylight saving time names should not be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * If {@link #setZoneStrings(String[][]) setZoneStrings} has been called
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * on this <code>DateFormatSymbols</code> instance, then the strings
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * provided by that call are returned. Otherwise, the returned array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * contains names provided by the Java runtime and by installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * {@link java.util.spi.TimeZoneNameProvider TimeZoneNameProvider}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * implementations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * @return the time zone strings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * @see #setZoneStrings(String[][])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    public String[][] getZoneStrings() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        return getZoneStringsImpl(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * Sets time zone strings.  The argument must be a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * two-dimensional array of strings of size <em>n</em> by <em>m</em>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * where <em>m</em> is at least 5.  Each of the <em>n</em> rows is an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * entry containing the localized names for a single <code>TimeZone</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * Each such row contains (with <code>i</code> ranging from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * 0..<em>n</em>-1):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * <li><code>zoneStrings[i][0]</code> - time zone ID</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * <li><code>zoneStrings[i][1]</code> - long name of zone in standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * time</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * <li><code>zoneStrings[i][2]</code> - short name of zone in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * standard time</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * <li><code>zoneStrings[i][3]</code> - long name of zone in daylight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * saving time</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * <li><code>zoneStrings[i][4]</code> - short name of zone in daylight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * saving time</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * The zone ID is <em>not</em> localized; it's one of the valid IDs of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * the {@link java.util.TimeZone TimeZone} class that are not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * <a href="../util/TimeZone.html#CustomID">custom IDs</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * All other entries are localized names.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * @param newZoneStrings the new time zone strings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * @exception IllegalArgumentException if the length of any row in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     *    <code>newZoneStrings</code> is less than 5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * @exception NullPointerException if <code>newZoneStrings</code> is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * @see #getZoneStrings()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    public void setZoneStrings(String[][] newZoneStrings) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        String[][] aCopy = new String[newZoneStrings.length][];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        for (int i = 0; i < newZoneStrings.length; ++i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            int len = newZoneStrings[i].length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
            if (len < 5) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
                throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
            aCopy[i] = Arrays.copyOf(newZoneStrings[i], len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        zoneStrings = aCopy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        isZoneStringsSet = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * Gets localized date-time pattern characters. For example: 'u', 't', etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * @return the localized date-time pattern characters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    public String getLocalPatternChars() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        return new String(localPatternChars);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * Sets localized date-time pattern characters. For example: 'u', 't', etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * @param newLocalPatternChars the new localized date-time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * pattern characters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    public void setLocalPatternChars(String newLocalPatternChars) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        localPatternChars = new String(newLocalPatternChars);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * Overrides Cloneable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    public Object clone()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        try
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
            DateFormatSymbols other = (DateFormatSymbols)super.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
            copyMembers(this, other);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
            return other;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        } catch (CloneNotSupportedException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
            throw new InternalError();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     * Override hashCode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     * Generates a hash code for the DateFormatSymbols object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        int hashcode = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        String[][] zoneStrings = getZoneStringsWrapper();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        for (int index = 0; index < zoneStrings[0].length; ++index)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
            hashcode ^= zoneStrings[0][index].hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        return hashcode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     * Override equals
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    public boolean equals(Object obj)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        if (this == obj) return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        if (obj == null || getClass() != obj.getClass()) return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        DateFormatSymbols that = (DateFormatSymbols) obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        return (Arrays.equals(eras, that.eras)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
                && Arrays.equals(months, that.months)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
                && Arrays.equals(shortMonths, that.shortMonths)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                && Arrays.equals(weekdays, that.weekdays)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                && Arrays.equals(shortWeekdays, that.shortWeekdays)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                && Arrays.equals(ampms, that.ampms)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
                && Arrays.deepEquals(getZoneStringsWrapper(), that.getZoneStringsWrapper())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
                && ((localPatternChars != null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
                  && localPatternChars.equals(that.localPatternChars))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                 || (localPatternChars == null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                  && that.localPatternChars == null)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
    // =======================privates===============================
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * Useful constant for defining time zone offsets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    static final int millisPerHour = 60*60*1000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * Cache to hold the FormatData and TimeZoneNames ResourceBundles
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * of a Locale.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
    private static Hashtable cachedLocaleData = new Hashtable(3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     * Look up resource data for the desiredLocale in the cache; update the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     * cache if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
    private static ResourceBundle cacheLookup(Locale desiredLocale) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        ResourceBundle rb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        SoftReference data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
            = (SoftReference)cachedLocaleData.get(desiredLocale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        if (data == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
            rb = LocaleData.getDateFormatData(desiredLocale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
            data = new SoftReference(rb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
            cachedLocaleData.put(desiredLocale, data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
            if ((rb = (ResourceBundle)data.get()) == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                rb = LocaleData.getDateFormatData(desiredLocale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                data = new SoftReference(rb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        return rb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    private void initializeData(Locale desiredLocale) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        ResourceBundle resource = cacheLookup(desiredLocale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        // FIXME: cache only ResourceBundle. Hence every time, will do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        // getObject(). This won't be necessary if the Resource itself
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        // is cached.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        eras = (String[])resource.getObject("Eras");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        months = resource.getStringArray("MonthNames");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
        shortMonths = resource.getStringArray("MonthAbbreviations");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        String[] lWeekdays = resource.getStringArray("DayNames");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        weekdays = new String[8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        weekdays[0] = "";  // 1-based
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        for (i=0; i<lWeekdays.length; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
            weekdays[i+1] = lWeekdays[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        String[] sWeekdays = resource.getStringArray("DayAbbreviations");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
        shortWeekdays = new String[8];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        shortWeekdays[0] = "";  // 1-based
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        for (i=0; i<sWeekdays.length; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
            shortWeekdays[i+1] = sWeekdays[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        ampms = resource.getStringArray("AmPmMarkers");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        localPatternChars = resource.getString("DateTimePatternChars");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        locale = desiredLocale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     * Package private: used by SimpleDateFormat
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * Gets the index for the given time zone ID to obtain the time zone
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     * strings for formatting. The time zone ID is just for programmatic
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     * lookup. NOT LOCALIZED!!!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     * @param ID the given time zone ID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * @return the index of the given time zone ID.  Returns -1 if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     * the given time zone ID can't be located in the DateFormatSymbols object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     * @see java.util.SimpleTimeZone
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    final int getZoneIndex(String ID)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        String[][] zoneStrings = getZoneStringsWrapper();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        for (int index=0; index<zoneStrings.length; index++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
            if (ID.equals(zoneStrings[index][0])) return index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
        return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     * Wrapper method to the getZoneStrings(), which is called from inside
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     * the java.text package and not to mutate the returned arrays, so that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
     * it does not need to create a defensive copy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    final String[][] getZoneStringsWrapper() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        if (isSubclassObject()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
            return getZoneStrings();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
            return getZoneStringsImpl(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    private final String[][] getZoneStringsImpl(boolean needsCopy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        if (zoneStrings == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
            zoneStrings = TimeZoneNameUtility.getZoneStrings(locale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
        if (!needsCopy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
            return zoneStrings;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        int len = zoneStrings.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        String[][] aCopy = new String[len][];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        for (int i = 0; i < len; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
            aCopy[i] = Arrays.copyOf(zoneStrings[i], zoneStrings[i].length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        return aCopy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    private final boolean isSubclassObject() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        return !getClass().getName().equals("java.text.DateFormatSymbols");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     * Clones all the data members from the source DateFormatSymbols to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * the target DateFormatSymbols. This is only for subclasses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     * @param src the source DateFormatSymbols.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     * @param dst the target DateFormatSymbols.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    private final void copyMembers(DateFormatSymbols src, DateFormatSymbols dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        dst.eras = Arrays.copyOf(src.eras, src.eras.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        dst.months = Arrays.copyOf(src.months, src.months.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        dst.shortMonths = Arrays.copyOf(src.shortMonths, src.shortMonths.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        dst.weekdays = Arrays.copyOf(src.weekdays, src.weekdays.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
        dst.shortWeekdays = Arrays.copyOf(src.shortWeekdays, src.shortWeekdays.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        dst.ampms = Arrays.copyOf(src.ampms, src.ampms.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        if (src.zoneStrings != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
            dst.zoneStrings = src.getZoneStringsImpl(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
            dst.zoneStrings = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        dst.localPatternChars = new String (src.localPatternChars);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     * Write out the default serializable data, after ensuring the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     * <code>zoneStrings</code> field is initialized in order to make
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     * sure the backward compatibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
    private void writeObject(ObjectOutputStream stream) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
        if (zoneStrings == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
            zoneStrings = TimeZoneNameUtility.getZoneStrings(locale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
        stream.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     * Obtains a DateFormatSymbols instance from a DateFormatSymbolsProvider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    private static class DateFormatSymbolsGetter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
        implements LocaleServiceProviderPool.LocalizedObjectGetter<DateFormatSymbolsProvider,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
                                                                   DateFormatSymbols> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
        private static final DateFormatSymbolsGetter INSTANCE =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
            new DateFormatSymbolsGetter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
        public DateFormatSymbols getObject(DateFormatSymbolsProvider dateFormatSymbolsProvider,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
                                Locale locale,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
                                String key,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
                                Object... params) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
            assert params.length == 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
            return dateFormatSymbolsProvider.getInstance(locale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
}