2702N/A * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * (C) Copyright Taligent, Inc. 1996 - All Rights Reserved 0N/A * (C) Copyright IBM Corp. 1996 - All Rights Reserved 0N/A * The original version of this source code and documentation is copyrighted 0N/A * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These 0N/A * materials are provided under terms of a License Agreement between Taligent 0N/A * and Sun. This technology is protected by multiple US and International 0N/A * patents. This notice and attribution to Taligent may not be removed. 0N/A * Taligent is a registered trademark of Taligent, Inc. 0N/A * <code>DateFormatSymbols</code> is a public class for encapsulating 0N/A * localizable date-time formatting data, such as the names of the 0N/A * months, the names of the days of the week, and the time zone data. 0N/A * <code>DateFormat</code> and <code>SimpleDateFormat</code> both use 0N/A * <code>DateFormatSymbols</code> to encapsulate this information. 0N/A * Typically you shouldn't use <code>DateFormatSymbols</code> directly. 0N/A * Rather, you are encouraged to create a date-time formatter with the 0N/A * <code>DateFormat</code> class's factory methods: <code>getTimeInstance</code>, 0N/A * <code>getDateInstance</code>, or <code>getDateTimeInstance</code>. 0N/A * These methods automatically create a <code>DateFormatSymbols</code> for 0N/A * the formatter so that you don't have to. After the 0N/A * formatter is created, you may modify its format pattern using the 0N/A * <code>setPattern</code> method. For more information about 0N/A * creating formatters using <code>DateFormat</code>'s factory methods, 0N/A * see {@link DateFormat}. 0N/A * If you decide to create a date-time formatter with a specific 0N/A * format pattern for a specific locale, you can do so with: 0N/A * new SimpleDateFormat(aPattern, DateFormatSymbols.getInstance(aLocale)). 0N/A * <code>DateFormatSymbols</code> objects are cloneable. When you obtain 0N/A * a <code>DateFormatSymbols</code> object, feel free to modify the 0N/A * date-time formatting data. For instance, you can replace the localized 0N/A * date-time format pattern characters with the ones that you feel easy 0N/A * to remember. Or you can change the representative cities 0N/A * to your favorite ones. 0N/A * New <code>DateFormatSymbols</code> subclasses may be added to support 0N/A * <code>SimpleDateFormat</code> for date-time formatting for additional locales. 0N/A * @see SimpleDateFormat 0N/A * @see java.util.SimpleTimeZone 0N/A * @author Chen-Lieh Huang 0N/A * Construct a DateFormatSymbols object by loading format data from 0N/A * resources for the default locale. This constructor can only 0N/A * construct instances for the locales supported by the Java 0N/A * runtime environment, not for those supported by installed 0N/A * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider} 0N/A * implementations. For full locale coverage, use the 0N/A * {@link #getInstance(Locale) getInstance} method. 0N/A * @see #getInstance() 0N/A * @exception java.util.MissingResourceException 0N/A * if the resources for the default locale cannot be 0N/A * found or cannot be loaded. 0N/A * Construct a DateFormatSymbols object by loading format data from 0N/A * resources for the given locale. This constructor can only 0N/A * construct instances for the locales supported by the Java 0N/A * runtime environment, not for those supported by installed 0N/A * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider} 0N/A * implementations. For full locale coverage, use the 0N/A * {@link #getInstance(Locale) getInstance} method. 0N/A * @see #getInstance(Locale) 0N/A * @exception java.util.MissingResourceException 0N/A * if the resources for the specified locale cannot be 0N/A * found or cannot be loaded. 0N/A * Era strings. For example: "AD" and "BC". An array of 2 strings, 0N/A * indexed by <code>Calendar.BC</code> and <code>Calendar.AD</code>. 0N/A * Month strings. For example: "January", "February", etc. An array 0N/A * of 13 strings (some calendars have 13 months), indexed by 0N/A * <code>Calendar.JANUARY</code>, <code>Calendar.FEBRUARY</code>, etc. 0N/A * Short month strings. For example: "Jan", "Feb", etc. An array of 0N/A * 13 strings (some calendars have 13 months), indexed by 0N/A * <code>Calendar.JANUARY</code>, <code>Calendar.FEBRUARY</code>, etc. 0N/A * Weekday strings. For example: "Sunday", "Monday", etc. An array 0N/A * of 8 strings, indexed by <code>Calendar.SUNDAY</code>, 0N/A * <code>Calendar.MONDAY</code>, etc. 0N/A * The element <code>weekdays[0]</code> is ignored. 0N/A * Short weekday strings. For example: "Sun", "Mon", etc. An array 0N/A * of 8 strings, indexed by <code>Calendar.SUNDAY</code>, 0N/A * <code>Calendar.MONDAY</code>, etc. 0N/A * The element <code>shortWeekdays[0]</code> is ignored. 0N/A * AM and PM strings. For example: "AM" and "PM". An array of 0N/A * 2 strings, indexed by <code>Calendar.AM</code> and 0N/A * <code>Calendar.PM</code>. 0N/A * Localized names of time zones in this locale. This is a 0N/A * two-dimensional array of strings of size <em>n</em> by <em>m</em>, 0N/A * where <em>m</em> is at least 5. Each of the <em>n</em> rows is an 0N/A * entry containing the localized names for a single <code>TimeZone</code>. 0N/A * Each such row contains (with <code>i</code> ranging from 0N/A * <li><code>zoneStrings[i][0]</code> - time zone ID</li> 0N/A * <li><code>zoneStrings[i][1]</code> - long name of zone in standard 0N/A * <li><code>zoneStrings[i][2]</code> - short name of zone in 0N/A * standard time</li> 0N/A * <li><code>zoneStrings[i][3]</code> - long name of zone in daylight 0N/A * <li><code>zoneStrings[i][4]</code> - short name of zone in daylight 0N/A * The zone ID is <em>not</em> localized; it's one of the valid IDs of 0N/A * the {@link java.util.TimeZone TimeZone} class that are not 0N/A * All other entries are localized names. 0N/A * @see java.util.TimeZone 0N/A * Indicates that zoneStrings is set externally with setZoneStrings() method. 0N/A * Unlocalized date-time pattern characters. For example: 'y', 'd', etc. 0N/A * All locales use the same these unlocalized pattern characters. 0N/A * Localized date-time pattern characters. For example, a locale may 0N/A * wish to use 'u' rather than 'y' to represent years in its date format 0N/A * This string must be exactly 18 characters long, with the index of 0N/A * the characters described by <code>DateFormat.ERA_FIELD</code>, 0N/A * <code>DateFormat.YEAR_FIELD</code>, etc. Thus, if the string were 0N/A * "Xz...", then localized patterns would use 'X' for era and 'z' for year. 0N/A * The locale which is used for initializing this DateFormatSymbols object. 0N/A /* use serialVersionUID from JDK 1.1.4 for interoperability */ 0N/A * Returns an array of all locales for which the 0N/A * <code>getInstance</code> methods of this class can return 0N/A * localized instances. 0N/A * The returned array represents the union of locales supported by the 0N/A * Java runtime and by installed 0N/A * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider} 0N/A * implementations. It must contain at least a <code>Locale</code> 0N/A * instance equal to {@link java.util.Locale#US Locale.US}. 0N/A * @return An array of locales for which localized 0N/A * <code>DateFormatSymbols</code> instances are available. 0N/A * Gets the <code>DateFormatSymbols</code> instance for the default 0N/A * locale. This method provides access to <code>DateFormatSymbols</code> 0N/A * instances for locales supported by the Java runtime itself as well 0N/A * as for those supported by installed 0N/A * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider} 0N/A * @return a <code>DateFormatSymbols</code> instance. 0N/A * Gets the <code>DateFormatSymbols</code> instance for the specified 0N/A * locale. This method provides access to <code>DateFormatSymbols</code> 0N/A * instances for locales supported by the Java runtime itself as well 0N/A * as for those supported by installed 0N/A * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider} 0N/A * @param locale the given locale. 0N/A * @return a <code>DateFormatSymbols</code> instance. 0N/A * @exception NullPointerException if <code>locale</code> is null 2962N/A * Returns a DateFormatSymbols provided by a provider or found in 2962N/A * the cache. Note that this method returns a cached instance, 2962N/A * not its clone. Therefore, the instance should never be given to 0N/A // Check whether a provider can provide an implementation that's closer 0N/A // to the requested locale than what the Java runtime itself can provide. 2962N/A * Returns a cached DateFormatSymbols if it's found in the 2962N/A * cache. Otherwise, this method returns a newly cached instance 2962N/A // Replace the empty SoftReference with ref. 0N/A * Gets era strings. For example: "AD" and "BC". 0N/A * @return the era strings. 0N/A * Sets era strings. For example: "AD" and "BC". 0N/A * @param newEras the new era strings. 0N/A * Gets month strings. For example: "January", "February", etc. 0N/A * @return the month strings. 0N/A * Sets month strings. For example: "January", "February", etc. 0N/A * @param newMonths the new month strings. 0N/A * Gets short month strings. For example: "Jan", "Feb", etc. 0N/A * @return the short month strings. 0N/A * Sets short month strings. For example: "Jan", "Feb", etc. 0N/A * @param newShortMonths the new short month strings. 0N/A * Gets weekday strings. For example: "Sunday", "Monday", etc. 0N/A * @return the weekday strings. Use <code>Calendar.SUNDAY</code>, 0N/A * <code>Calendar.MONDAY</code>, etc. to index the result array. 0N/A * Sets weekday strings. For example: "Sunday", "Monday", etc. 0N/A * @param newWeekdays the new weekday strings. The array should 0N/A * be indexed by <code>Calendar.SUNDAY</code>, 0N/A * <code>Calendar.MONDAY</code>, etc. 0N/A * Gets short weekday strings. For example: "Sun", "Mon", etc. 0N/A * @return the short weekday strings. Use <code>Calendar.SUNDAY</code>, 0N/A * <code>Calendar.MONDAY</code>, etc. to index the result array. 0N/A * Sets short weekday strings. For example: "Sun", "Mon", etc. 0N/A * @param newShortWeekdays the new short weekday strings. The array should 0N/A * be indexed by <code>Calendar.SUNDAY</code>, 0N/A * <code>Calendar.MONDAY</code>, etc. 0N/A * Gets ampm strings. For example: "AM" and "PM". 0N/A * @return the ampm strings. 0N/A * Sets ampm strings. For example: "AM" and "PM". 0N/A * @param newAmpms the new ampm strings. 0N/A * Gets time zone strings. Use of this method is discouraged; use 0N/A * {@link java.util.TimeZone#getDisplayName() TimeZone.getDisplayName()} 0N/A * The value returned is a 0N/A * two-dimensional array of strings of size <em>n</em> by <em>m</em>, 0N/A * where <em>m</em> is at least 5. Each of the <em>n</em> rows is an 0N/A * entry containing the localized names for a single <code>TimeZone</code>. 0N/A * Each such row contains (with <code>i</code> ranging from 0N/A * <li><code>zoneStrings[i][0]</code> - time zone ID</li> 0N/A * <li><code>zoneStrings[i][1]</code> - long name of zone in standard 0N/A * <li><code>zoneStrings[i][2]</code> - short name of zone in 0N/A * standard time</li> 0N/A * <li><code>zoneStrings[i][3]</code> - long name of zone in daylight 0N/A * <li><code>zoneStrings[i][4]</code> - short name of zone in daylight 0N/A * The zone ID is <em>not</em> localized; it's one of the valid IDs of 0N/A * the {@link java.util.TimeZone TimeZone} class that are not 0N/A * All other entries are localized names. If a zone does not implement 0N/A * daylight saving time, the daylight saving time names should not be used. 0N/A * If {@link #setZoneStrings(String[][]) setZoneStrings} has been called 0N/A * on this <code>DateFormatSymbols</code> instance, then the strings 0N/A * provided by that call are returned. Otherwise, the returned array 0N/A * contains names provided by the Java runtime and by installed 0N/A * {@link java.util.spi.TimeZoneNameProvider TimeZoneNameProvider} 0N/A * @return the time zone strings. 0N/A * @see #setZoneStrings(String[][]) 0N/A * Sets time zone strings. The argument must be a 0N/A * two-dimensional array of strings of size <em>n</em> by <em>m</em>, 0N/A * where <em>m</em> is at least 5. Each of the <em>n</em> rows is an 0N/A * entry containing the localized names for a single <code>TimeZone</code>. 0N/A * Each such row contains (with <code>i</code> ranging from 0N/A * <li><code>zoneStrings[i][0]</code> - time zone ID</li> 0N/A * <li><code>zoneStrings[i][1]</code> - long name of zone in standard 0N/A * <li><code>zoneStrings[i][2]</code> - short name of zone in 0N/A * standard time</li> 0N/A * <li><code>zoneStrings[i][3]</code> - long name of zone in daylight 0N/A * <li><code>zoneStrings[i][4]</code> - short name of zone in daylight 0N/A * The zone ID is <em>not</em> localized; it's one of the valid IDs of 0N/A * the {@link java.util.TimeZone TimeZone} class that are not 0N/A * All other entries are localized names. 0N/A * @param newZoneStrings the new time zone strings. 0N/A * @exception IllegalArgumentException if the length of any row in 0N/A * <code>newZoneStrings</code> is less than 5 0N/A * @exception NullPointerException if <code>newZoneStrings</code> is null 0N/A * @see #getZoneStrings() 0N/A * Gets localized date-time pattern characters. For example: 'u', 't', etc. 0N/A * @return the localized date-time pattern characters. 0N/A * Sets localized date-time pattern characters. For example: 'u', 't', etc. 0N/A * @param newLocalPatternChars the new localized date-time 0N/A * pattern characters. 2702N/A // Call toString() to throw an NPE in case the argument is null 0N/A * Overrides Cloneable 0N/A * Override hashCode. 0N/A * Generates a hash code for the DateFormatSymbols object. 0N/A // =======================privates=============================== 0N/A * Useful constant for defining time zone offsets. 2962N/A * Cache to hold DateFormatSymbols instances per Locale. 2962N/A // Copy values of a cached instance if any. 2962N/A // Initialize the fields from the ResourceBundle for locale. 2962N/A // Day of week names are stored in a 1-based array. 0N/A * Package private: used by SimpleDateFormat 0N/A * Gets the index for the given time zone ID to obtain the time zone 0N/A * strings for formatting. The time zone ID is just for programmatic 0N/A * lookup. NOT LOCALIZED!!! 0N/A * @param ID the given time zone ID. 0N/A * @return the index of the given time zone ID. Returns -1 if 0N/A * the given time zone ID can't be located in the DateFormatSymbols object. 0N/A * @see java.util.SimpleTimeZone 5521N/A * getZoneIndex has been re-written for performance reasons. instead of 5521N/A * traversing the zoneStrings array every time, we cache the last used zone 5521N/A /* slow path, search entire list */ 0N/A * Wrapper method to the getZoneStrings(), which is called from inside 0N/A * the java.text package and not to mutate the returned arrays, so that 0N/A * it does not need to create a defensive copy. 0N/A for (
int i =
0; i <
len; i++) {
0N/A * Clones all the data members from the source DateFormatSymbols to 0N/A * the target DateFormatSymbols. This is only for subclasses. 0N/A * @param src the source DateFormatSymbols. 0N/A * @param dst the target DateFormatSymbols. 0N/A * Write out the default serializable data, after ensuring the 0N/A * <code>zoneStrings</code> field is initialized in order to make 0N/A * sure the backward compatibility. 0N/A * Obtains a DateFormatSymbols instance from a DateFormatSymbolsProvider