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