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