feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
81
jdkSrc/jdk8/java/util/spi/CalendarDataProvider.java
Normal file
81
jdkSrc/jdk8/java/util/spi/CalendarDataProvider.java
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package java.util.spi;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* An abstract class for service providers that provide locale-dependent {@link
|
||||
* Calendar} parameters.
|
||||
*
|
||||
* @author Masayoshi Okutsu
|
||||
* @since 1.8
|
||||
* @see CalendarNameProvider
|
||||
*/
|
||||
public abstract class CalendarDataProvider extends LocaleServiceProvider {
|
||||
|
||||
/**
|
||||
* Sole constructor. (For invocation by subclass constructors, typically
|
||||
* implicit.)
|
||||
*/
|
||||
protected CalendarDataProvider() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first day of a week in the given {@code locale}. This
|
||||
* information is required by {@link Calendar} to support operations on the
|
||||
* week-related calendar fields.
|
||||
*
|
||||
* @param locale
|
||||
* the desired locale
|
||||
* @return the first day of a week; one of {@link Calendar#SUNDAY} ..
|
||||
* {@link Calendar#SATURDAY},
|
||||
* or 0 if the value isn't available for the {@code locale}
|
||||
* @throws NullPointerException
|
||||
* if {@code locale} is {@code null}.
|
||||
* @see java.util.Calendar#getFirstDayOfWeek()
|
||||
* @see <a href="../Calendar.html#first_week">First Week</a>
|
||||
*/
|
||||
public abstract int getFirstDayOfWeek(Locale locale);
|
||||
|
||||
/**
|
||||
* Returns the minimal number of days required in the first week of a
|
||||
* year. This information is required by {@link Calendar} to determine the
|
||||
* first week of a year. Refer to the description of <a
|
||||
* href="../Calendar.html#first_week"> how {@code Calendar} determines
|
||||
* the first week</a>.
|
||||
*
|
||||
* @param locale
|
||||
* the desired locale
|
||||
* @return the minimal number of days of the first week,
|
||||
* or 0 if the value isn't available for the {@code locale}
|
||||
* @throws NullPointerException
|
||||
* if {@code locale} is {@code null}.
|
||||
* @see java.util.Calendar#getMinimalDaysInFirstWeek()
|
||||
*/
|
||||
public abstract int getMinimalDaysInFirstWeek(Locale locale);
|
||||
}
|
||||
291
jdkSrc/jdk8/java/util/spi/CalendarNameProvider.java
Normal file
291
jdkSrc/jdk8/java/util/spi/CalendarNameProvider.java
Normal file
@@ -0,0 +1,291 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package java.util.spi;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* An abstract class for service providers that provide localized string
|
||||
* representations (display names) of {@code Calendar} field values.
|
||||
*
|
||||
* <p><a name="calendartypes"><b>Calendar Types</b></a>
|
||||
*
|
||||
* <p>Calendar types are used to specify calendar systems for which the {@link
|
||||
* #getDisplayName(String, int, int, int, Locale) getDisplayName} and {@link
|
||||
* #getDisplayNames(String, int, int, Locale) getDisplayNames} methods provide
|
||||
* calendar field value names. See {@link Calendar#getCalendarType()} for details.
|
||||
*
|
||||
* <p><b>Calendar Fields</b>
|
||||
*
|
||||
* <p>Calendar fields are specified with the constants defined in {@link
|
||||
* Calendar}. The following are calendar-common fields and their values to be
|
||||
* supported for each calendar system.
|
||||
*
|
||||
* <table style="border-bottom:1px solid" border="1" cellpadding="3" cellspacing="0" summary="Field values">
|
||||
* <tr>
|
||||
* <th>Field</th>
|
||||
* <th>Value</th>
|
||||
* <th>Description</th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td valign="top">{@link Calendar#MONTH}</td>
|
||||
* <td valign="top">{@link Calendar#JANUARY} to {@link Calendar#UNDECIMBER}</td>
|
||||
* <td>Month numbering is 0-based (e.g., 0 - January, ..., 11 -
|
||||
* December). Some calendar systems have 13 months. Month
|
||||
* names need to be supported in both the formatting and
|
||||
* stand-alone forms if required by the supported locales. If there's
|
||||
* no distinction in the two forms, the same names should be returned
|
||||
* in both of the forms.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td valign="top">{@link Calendar#DAY_OF_WEEK}</td>
|
||||
* <td valign="top">{@link Calendar#SUNDAY} to {@link Calendar#SATURDAY}</td>
|
||||
* <td>Day-of-week numbering is 1-based starting from Sunday (i.e., 1 - Sunday,
|
||||
* ..., 7 - Saturday).</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td valign="top">{@link Calendar#AM_PM}</td>
|
||||
* <td valign="top">{@link Calendar#AM} to {@link Calendar#PM}</td>
|
||||
* <td>0 - AM, 1 - PM</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* <p style="margin-top:20px">The following are calendar-specific fields and their values to be supported.
|
||||
*
|
||||
* <table style="border-bottom:1px solid" border="1" cellpadding="3" cellspacing="0" summary="Calendar type and field values">
|
||||
* <tr>
|
||||
* <th>Calendar Type</th>
|
||||
* <th>Field</th>
|
||||
* <th>Value</th>
|
||||
* <th>Description</th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td rowspan="2" valign="top">{@code "gregory"}</td>
|
||||
* <td rowspan="2" valign="top">{@link Calendar#ERA}</td>
|
||||
* <td>0</td>
|
||||
* <td>{@link java.util.GregorianCalendar#BC} (BCE)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>1</td>
|
||||
* <td>{@link java.util.GregorianCalendar#AD} (CE)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td rowspan="2" valign="top">{@code "buddhist"}</td>
|
||||
* <td rowspan="2" valign="top">{@link Calendar#ERA}</td>
|
||||
* <td>0</td>
|
||||
* <td>BC (BCE)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>1</td>
|
||||
* <td>B.E. (Buddhist Era)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td rowspan="6" valign="top">{@code "japanese"}</td>
|
||||
* <td rowspan="5" valign="top">{@link Calendar#ERA}</td>
|
||||
* <td>0</td>
|
||||
* <td>Seireki (Before Meiji)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>1</td>
|
||||
* <td>Meiji</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>2</td>
|
||||
* <td>Taisho</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>3</td>
|
||||
* <td>Showa</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>4</td>
|
||||
* <td >Heisei</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link Calendar#YEAR}</td>
|
||||
* <td>1</td>
|
||||
* <td>the first year in each era. It should be returned when a long
|
||||
* style ({@link Calendar#LONG_FORMAT} or {@link Calendar#LONG_STANDALONE}) is
|
||||
* specified. See also the <a href="../../text/SimpleDateFormat.html#year">
|
||||
* Year representation in {@code SimpleDateFormat}</a>.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td rowspan="2" valign="top">{@code "roc"}</td>
|
||||
* <td rowspan="2" valign="top">{@link Calendar#ERA}</td>
|
||||
* <td>0</td>
|
||||
* <td>Before R.O.C.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>1</td>
|
||||
* <td>R.O.C.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td rowspan="2" valign="top">{@code "islamic"}</td>
|
||||
* <td rowspan="2" valign="top">{@link Calendar#ERA}</td>
|
||||
* <td>0</td>
|
||||
* <td>Before AH</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>1</td>
|
||||
* <td>Anno Hijrah (AH)</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* <p>Calendar field value names for {@code "gregory"} must be consistent with
|
||||
* the date-time symbols provided by {@link java.text.spi.DateFormatSymbolsProvider}.
|
||||
*
|
||||
* <p>Time zone names are supported by {@link TimeZoneNameProvider}.
|
||||
*
|
||||
* @author Masayoshi Okutsu
|
||||
* @since 1.8
|
||||
* @see CalendarDataProvider
|
||||
* @see Locale#getUnicodeLocaleType(String)
|
||||
*/
|
||||
public abstract class CalendarNameProvider extends LocaleServiceProvider {
|
||||
/**
|
||||
* Sole constructor. (For invocation by subclass constructors, typically
|
||||
* implicit.)
|
||||
*/
|
||||
protected CalendarNameProvider() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string representation (display name) of the calendar
|
||||
* <code>field value</code> in the given <code>style</code> and
|
||||
* <code>locale</code>. If no string representation is
|
||||
* applicable, <code>null</code> is returned.
|
||||
*
|
||||
* <p>{@code field} is a {@code Calendar} field index, such as {@link
|
||||
* Calendar#MONTH}. The time zone fields, {@link Calendar#ZONE_OFFSET} and
|
||||
* {@link Calendar#DST_OFFSET}, are <em>not</em> supported by this
|
||||
* method. {@code null} must be returned if any time zone fields are
|
||||
* specified.
|
||||
*
|
||||
* <p>{@code value} is the numeric representation of the {@code field} value.
|
||||
* For example, if {@code field} is {@link Calendar#DAY_OF_WEEK}, the valid
|
||||
* values are {@link Calendar#SUNDAY} to {@link Calendar#SATURDAY}
|
||||
* (inclusive).
|
||||
*
|
||||
* <p>{@code style} gives the style of the string representation. It is one
|
||||
* of {@link Calendar#SHORT_FORMAT} ({@link Calendar#SHORT SHORT}),
|
||||
* {@link Calendar#SHORT_STANDALONE}, {@link Calendar#LONG_FORMAT}
|
||||
* ({@link Calendar#LONG LONG}), {@link Calendar#LONG_STANDALONE},
|
||||
* {@link Calendar#NARROW_FORMAT}, or {@link Calendar#NARROW_STANDALONE}.
|
||||
*
|
||||
* <p>For example, the following call will return {@code "Sunday"}.
|
||||
* <pre>
|
||||
* getDisplayName("gregory", Calendar.DAY_OF_WEEK, Calendar.SUNDAY,
|
||||
* Calendar.LONG_STANDALONE, Locale.ENGLISH);
|
||||
* </pre>
|
||||
*
|
||||
* @param calendarType
|
||||
* the calendar type. (Any calendar type given by {@code locale}
|
||||
* is ignored.)
|
||||
* @param field
|
||||
* the {@code Calendar} field index,
|
||||
* such as {@link Calendar#DAY_OF_WEEK}
|
||||
* @param value
|
||||
* the value of the {@code Calendar field},
|
||||
* such as {@link Calendar#MONDAY}
|
||||
* @param style
|
||||
* the string representation style: one of {@link
|
||||
* Calendar#SHORT_FORMAT} ({@link Calendar#SHORT SHORT}),
|
||||
* {@link Calendar#SHORT_STANDALONE}, {@link
|
||||
* Calendar#LONG_FORMAT} ({@link Calendar#LONG LONG}),
|
||||
* {@link Calendar#LONG_STANDALONE},
|
||||
* {@link Calendar#NARROW_FORMAT},
|
||||
* or {@link Calendar#NARROW_STANDALONE}
|
||||
* @param locale
|
||||
* the desired locale
|
||||
* @return the string representation of the {@code field value}, or {@code
|
||||
* null} if the string representation is not applicable or
|
||||
* the given calendar type is unknown
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code field} or {@code style} is invalid
|
||||
* @throws NullPointerException if {@code locale} is {@code null}
|
||||
* @see TimeZoneNameProvider
|
||||
* @see java.util.Calendar#get(int)
|
||||
* @see java.util.Calendar#getDisplayName(int, int, Locale)
|
||||
*/
|
||||
public abstract String getDisplayName(String calendarType,
|
||||
int field, int value,
|
||||
int style, Locale locale);
|
||||
|
||||
/**
|
||||
* Returns a {@code Map} containing all string representations (display
|
||||
* names) of the {@code Calendar} {@code field} in the given {@code style}
|
||||
* and {@code locale} and their corresponding field values.
|
||||
*
|
||||
* <p>{@code field} is a {@code Calendar} field index, such as {@link
|
||||
* Calendar#MONTH}. The time zone fields, {@link Calendar#ZONE_OFFSET} and
|
||||
* {@link Calendar#DST_OFFSET}, are <em>not</em> supported by this
|
||||
* method. {@code null} must be returned if any time zone fields are specified.
|
||||
*
|
||||
* <p>{@code style} gives the style of the string representation. It must be
|
||||
* one of {@link Calendar#ALL_STYLES}, {@link Calendar#SHORT_FORMAT} ({@link
|
||||
* Calendar#SHORT SHORT}), {@link Calendar#SHORT_STANDALONE}, {@link
|
||||
* Calendar#LONG_FORMAT} ({@link Calendar#LONG LONG}), {@link
|
||||
* Calendar#LONG_STANDALONE}, {@link Calendar#NARROW_FORMAT}, or
|
||||
* {@link Calendar#NARROW_STANDALONE}. Note that narrow names may
|
||||
* not be unique due to use of single characters, such as "S" for Sunday
|
||||
* and Saturday, and that no narrow names are included in that case.
|
||||
*
|
||||
* <p>For example, the following call will return a {@code Map} containing
|
||||
* {@code "January"} to {@link Calendar#JANUARY}, {@code "Jan"} to {@link
|
||||
* Calendar#JANUARY}, {@code "February"} to {@link Calendar#FEBRUARY},
|
||||
* {@code "Feb"} to {@link Calendar#FEBRUARY}, and so on.
|
||||
* <pre>
|
||||
* getDisplayNames("gregory", Calendar.MONTH, Calendar.ALL_STYLES, Locale.ENGLISH);
|
||||
* </pre>
|
||||
*
|
||||
* @param calendarType
|
||||
* the calendar type. (Any calendar type given by {@code locale}
|
||||
* is ignored.)
|
||||
* @param field
|
||||
* the calendar field for which the display names are returned
|
||||
* @param style
|
||||
* the style applied to the display names; one of
|
||||
* {@link Calendar#ALL_STYLES}, {@link Calendar#SHORT_FORMAT}
|
||||
* ({@link Calendar#SHORT SHORT}), {@link
|
||||
* Calendar#SHORT_STANDALONE}, {@link Calendar#LONG_FORMAT}
|
||||
* ({@link Calendar#LONG LONG}), {@link Calendar#LONG_STANDALONE},
|
||||
* {@link Calendar#NARROW_FORMAT},
|
||||
* or {@link Calendar#NARROW_STANDALONE}
|
||||
* @param locale
|
||||
* the desired locale
|
||||
* @return a {@code Map} containing all display names of {@code field} in
|
||||
* {@code style} and {@code locale} and their {@code field} values,
|
||||
* or {@code null} if no display names are defined for {@code field}
|
||||
* @throws NullPointerException
|
||||
* if {@code locale} is {@code null}
|
||||
* @see Calendar#getDisplayNames(int, int, Locale)
|
||||
*/
|
||||
public abstract Map<String, Integer> getDisplayNames(String calendarType,
|
||||
int field, int style,
|
||||
Locale locale);
|
||||
}
|
||||
122
jdkSrc/jdk8/java/util/spi/CurrencyNameProvider.java
Normal file
122
jdkSrc/jdk8/java/util/spi/CurrencyNameProvider.java
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package java.util.spi;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Currency;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle.Control;
|
||||
|
||||
/**
|
||||
* An abstract class for service providers that
|
||||
* provide localized currency symbols and display names for the
|
||||
* {@link java.util.Currency Currency} class.
|
||||
* Note that currency symbols are considered names when determining
|
||||
* behaviors described in the
|
||||
* {@link java.util.spi.LocaleServiceProvider LocaleServiceProvider}
|
||||
* specification.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public abstract class CurrencyNameProvider extends LocaleServiceProvider {
|
||||
|
||||
/**
|
||||
* Sole constructor. (For invocation by subclass constructors, typically
|
||||
* implicit.)
|
||||
*/
|
||||
protected CurrencyNameProvider() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the symbol of the given currency code for the specified locale.
|
||||
* For example, for "USD" (US Dollar), the symbol is "$" if the specified
|
||||
* locale is the US, while for other locales it may be "US$". If no
|
||||
* symbol can be determined, null should be returned.
|
||||
*
|
||||
* @param currencyCode the ISO 4217 currency code, which
|
||||
* consists of three upper-case letters between 'A' (U+0041) and
|
||||
* 'Z' (U+005A)
|
||||
* @param locale the desired locale
|
||||
* @return the symbol of the given currency code for the specified locale, or null if
|
||||
* the symbol is not available for the locale
|
||||
* @exception NullPointerException if <code>currencyCode</code> or
|
||||
* <code>locale</code> is null
|
||||
* @exception IllegalArgumentException if <code>currencyCode</code> is not in
|
||||
* the form of three upper-case letters, or <code>locale</code> isn't
|
||||
* one of the locales returned from
|
||||
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
|
||||
* getAvailableLocales()}.
|
||||
* @see java.util.Currency#getSymbol(java.util.Locale)
|
||||
*/
|
||||
public abstract String getSymbol(String currencyCode, Locale locale);
|
||||
|
||||
/**
|
||||
* Returns a name for the currency that is appropriate for display to the
|
||||
* user. The default implementation returns null.
|
||||
*
|
||||
* @param currencyCode the ISO 4217 currency code, which
|
||||
* consists of three upper-case letters between 'A' (U+0041) and
|
||||
* 'Z' (U+005A)
|
||||
* @param locale the desired locale
|
||||
* @return the name for the currency that is appropriate for display to the
|
||||
* user, or null if the name is not available for the locale
|
||||
* @exception IllegalArgumentException if <code>currencyCode</code> is not in
|
||||
* the form of three upper-case letters, or <code>locale</code> isn't
|
||||
* one of the locales returned from
|
||||
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
|
||||
* getAvailableLocales()}.
|
||||
* @exception NullPointerException if <code>currencyCode</code> or
|
||||
* <code>locale</code> is <code>null</code>
|
||||
* @since 1.7
|
||||
*/
|
||||
public String getDisplayName(String currencyCode, Locale locale) {
|
||||
if (currencyCode == null || locale == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
// Check whether the currencyCode is valid
|
||||
char[] charray = currencyCode.toCharArray();
|
||||
if (charray.length != 3) {
|
||||
throw new IllegalArgumentException("The currencyCode is not in the form of three upper-case letters.");
|
||||
}
|
||||
for (char c : charray) {
|
||||
if (c < 'A' || c > 'Z') {
|
||||
throw new IllegalArgumentException("The currencyCode is not in the form of three upper-case letters.");
|
||||
}
|
||||
}
|
||||
|
||||
// Check whether the locale is valid
|
||||
Control c = Control.getNoFallbackControl(Control.FORMAT_DEFAULT);
|
||||
for (Locale l : getAvailableLocales()) {
|
||||
if (c.getCandidateLocales("", l).contains(locale)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("The locale is not available");
|
||||
}
|
||||
}
|
||||
144
jdkSrc/jdk8/java/util/spi/LocaleNameProvider.java
Normal file
144
jdkSrc/jdk8/java/util/spi/LocaleNameProvider.java
Normal file
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package java.util.spi;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* An abstract class for service providers that
|
||||
* provide localized names for the
|
||||
* {@link java.util.Locale Locale} class.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public abstract class LocaleNameProvider extends LocaleServiceProvider {
|
||||
|
||||
/**
|
||||
* Sole constructor. (For invocation by subclass constructors, typically
|
||||
* implicit.)
|
||||
*/
|
||||
protected LocaleNameProvider() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
|
||||
* IETF BCP47</a> language code and the given locale that is appropriate for
|
||||
* display to the user.
|
||||
* For example, if <code>languageCode</code> is "fr" and <code>locale</code>
|
||||
* is en_US, getDisplayLanguage() will return "French"; if <code>languageCode</code>
|
||||
* is "en" and <code>locale</code> is fr_FR, getDisplayLanguage() will return "anglais".
|
||||
* If the name returned cannot be localized according to <code>locale</code>,
|
||||
* (say, the provider does not have a Japanese name for Croatian),
|
||||
* this method returns null.
|
||||
* @param languageCode the language code string in the form of two to eight
|
||||
* lower-case letters between 'a' (U+0061) and 'z' (U+007A)
|
||||
* @param locale the desired locale
|
||||
* @return the name of the given language code for the specified locale, or null if it's not
|
||||
* available.
|
||||
* @exception NullPointerException if <code>languageCode</code> or <code>locale</code> is null
|
||||
* @exception IllegalArgumentException if <code>languageCode</code> is not in the form of
|
||||
* two or three lower-case letters, or <code>locale</code> isn't
|
||||
* one of the locales returned from
|
||||
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
|
||||
* getAvailableLocales()}.
|
||||
* @see java.util.Locale#getDisplayLanguage(java.util.Locale)
|
||||
*/
|
||||
public abstract String getDisplayLanguage(String languageCode, Locale locale);
|
||||
|
||||
/**
|
||||
* Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
|
||||
* IETF BCP47</a> script code and the given locale that is appropriate for
|
||||
* display to the user.
|
||||
* For example, if <code>scriptCode</code> is "Latn" and <code>locale</code>
|
||||
* is en_US, getDisplayScript() will return "Latin"; if <code>scriptCode</code>
|
||||
* is "Cyrl" and <code>locale</code> is fr_FR, getDisplayScript() will return "cyrillique".
|
||||
* If the name returned cannot be localized according to <code>locale</code>,
|
||||
* (say, the provider does not have a Japanese name for Cyrillic),
|
||||
* this method returns null. The default implementation returns null.
|
||||
* @param scriptCode the four letter script code string in the form of title-case
|
||||
* letters (the first letter is upper-case character between 'A' (U+0041) and
|
||||
* 'Z' (U+005A) followed by three lower-case character between 'a' (U+0061)
|
||||
* and 'z' (U+007A)).
|
||||
* @param locale the desired locale
|
||||
* @return the name of the given script code for the specified locale, or null if it's not
|
||||
* available.
|
||||
* @exception NullPointerException if <code>scriptCode</code> or <code>locale</code> is null
|
||||
* @exception IllegalArgumentException if <code>scriptCode</code> is not in the form of
|
||||
* four title case letters, or <code>locale</code> isn't
|
||||
* one of the locales returned from
|
||||
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
|
||||
* getAvailableLocales()}.
|
||||
* @see java.util.Locale#getDisplayScript(java.util.Locale)
|
||||
* @since 1.7
|
||||
*/
|
||||
public String getDisplayScript(String scriptCode, Locale locale) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
|
||||
* IETF BCP47</a> region code (either ISO 3166 country code or UN M.49 area
|
||||
* codes) and the given locale that is appropriate for display to the user.
|
||||
* For example, if <code>countryCode</code> is "FR" and <code>locale</code>
|
||||
* is en_US, getDisplayCountry() will return "France"; if <code>countryCode</code>
|
||||
* is "US" and <code>locale</code> is fr_FR, getDisplayCountry() will return "Etats-Unis".
|
||||
* If the name returned cannot be localized according to <code>locale</code>,
|
||||
* (say, the provider does not have a Japanese name for Croatia),
|
||||
* this method returns null.
|
||||
* @param countryCode the country(region) code string in the form of two
|
||||
* upper-case letters between 'A' (U+0041) and 'Z' (U+005A) or the UN M.49 area code
|
||||
* in the form of three digit letters between '0' (U+0030) and '9' (U+0039).
|
||||
* @param locale the desired locale
|
||||
* @return the name of the given country code for the specified locale, or null if it's not
|
||||
* available.
|
||||
* @exception NullPointerException if <code>countryCode</code> or <code>locale</code> is null
|
||||
* @exception IllegalArgumentException if <code>countryCode</code> is not in the form of
|
||||
* two upper-case letters or three digit letters, or <code>locale</code> isn't
|
||||
* one of the locales returned from
|
||||
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
|
||||
* getAvailableLocales()}.
|
||||
* @see java.util.Locale#getDisplayCountry(java.util.Locale)
|
||||
*/
|
||||
public abstract String getDisplayCountry(String countryCode, Locale locale);
|
||||
|
||||
/**
|
||||
* Returns a localized name for the given variant code and the given locale that
|
||||
* is appropriate for display to the user.
|
||||
* If the name returned cannot be localized according to <code>locale</code>,
|
||||
* this method returns null.
|
||||
* @param variant the variant string
|
||||
* @param locale the desired locale
|
||||
* @return the name of the given variant string for the specified locale, or null if it's not
|
||||
* available.
|
||||
* @exception NullPointerException if <code>variant</code> or <code>locale</code> is null
|
||||
* @exception IllegalArgumentException if <code>locale</code> isn't
|
||||
* one of the locales returned from
|
||||
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
|
||||
* getAvailableLocales()}.
|
||||
* @see java.util.Locale#getDisplayVariant(java.util.Locale)
|
||||
*/
|
||||
public abstract String getDisplayVariant(String variant, Locale locale);
|
||||
}
|
||||
201
jdkSrc/jdk8/java/util/spi/LocaleServiceProvider.java
Normal file
201
jdkSrc/jdk8/java/util/spi/LocaleServiceProvider.java
Normal file
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package java.util.spi;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This is the super class of all the locale sensitive service provider
|
||||
* interfaces (SPIs).
|
||||
* <p>
|
||||
* Locale sensitive service provider interfaces are interfaces that
|
||||
* correspond to locale sensitive classes in the <code>java.text</code>
|
||||
* and <code>java.util</code> packages. The interfaces enable the
|
||||
* construction of locale sensitive objects and the retrieval of
|
||||
* localized names for these packages. Locale sensitive factory methods
|
||||
* and methods for name retrieval in the <code>java.text</code> and
|
||||
* <code>java.util</code> packages use implementations of the provider
|
||||
* interfaces to offer support for locales beyond the set of locales
|
||||
* supported by the Java runtime environment itself.
|
||||
*
|
||||
* <h3>Packaging of Locale Sensitive Service Provider Implementations</h3>
|
||||
* Implementations of these locale sensitive services are packaged using the
|
||||
* <a href="../../../../technotes/guides/extensions/index.html">Java Extension Mechanism</a>
|
||||
* as installed extensions. A provider identifies itself with a
|
||||
* provider-configuration file in the resource directory META-INF/services,
|
||||
* using the fully qualified provider interface class name as the file name.
|
||||
* The file should contain a list of fully-qualified concrete provider class names,
|
||||
* one per line. A line is terminated by any one of a line feed ('\n'), a carriage
|
||||
* return ('\r'), or a carriage return followed immediately by a line feed. Space
|
||||
* and tab characters surrounding each name, as well as blank lines, are ignored.
|
||||
* The comment character is '#' ('\u0023'); on each line all characters following
|
||||
* the first comment character are ignored. The file must be encoded in UTF-8.
|
||||
* <p>
|
||||
* If a particular concrete provider class is named in more than one configuration
|
||||
* file, or is named in the same configuration file more than once, then the
|
||||
* duplicates will be ignored. The configuration file naming a particular provider
|
||||
* need not be in the same jar file or other distribution unit as the provider itself.
|
||||
* The provider must be accessible from the same class loader that was initially
|
||||
* queried to locate the configuration file; this is not necessarily the class loader
|
||||
* that loaded the file.
|
||||
* <p>
|
||||
* For example, an implementation of the
|
||||
* {@link java.text.spi.DateFormatProvider DateFormatProvider} class should
|
||||
* take the form of a jar file which contains the file:
|
||||
* <pre>
|
||||
* META-INF/services/java.text.spi.DateFormatProvider
|
||||
* </pre>
|
||||
* And the file <code>java.text.spi.DateFormatProvider</code> should have
|
||||
* a line such as:
|
||||
* <pre>
|
||||
* <code>com.foo.DateFormatProviderImpl</code>
|
||||
* </pre>
|
||||
* which is the fully qualified class name of the class implementing
|
||||
* <code>DateFormatProvider</code>.
|
||||
* <h4>Invocation of Locale Sensitive Services</h4>
|
||||
* <p>
|
||||
* Locale sensitive factory methods and methods for name retrieval in the
|
||||
* <code>java.text</code> and <code>java.util</code> packages invoke
|
||||
* service provider methods when needed to support the requested locale.
|
||||
* The methods first check whether the Java runtime environment itself
|
||||
* supports the requested locale, and use its support if available.
|
||||
* Otherwise, they call the {@link #isSupportedLocale(Locale) isSupportedLocale}
|
||||
* methods of installed providers for the appropriate interface to find one that
|
||||
* supports the requested locale. If such a provider is found, its other
|
||||
* methods are called to obtain the requested object or name. When checking
|
||||
* whether a locale is supported, the <a href="../Locale.html#def_extensions">
|
||||
* locale's extensions</a> are ignored by default. (If locale's extensions should
|
||||
* also be checked, the {@code isSupportedLocale} method must be overridden.)
|
||||
* If neither the Java runtime environment itself nor an installed provider
|
||||
* supports the requested locale, the methods go through a list of candidate
|
||||
* locales and repeat the availability check for each until a match is found.
|
||||
* The algorithm used for creating a list of candidate locales is same as
|
||||
* the one used by <code>ResourceBundle</code> by default (see
|
||||
* {@link java.util.ResourceBundle.Control#getCandidateLocales getCandidateLocales}
|
||||
* for the details). Even if a locale is resolved from the candidate list,
|
||||
* methods that return requested objects or names are invoked with the original
|
||||
* requested locale including {@code Locale} extensions. The Java runtime
|
||||
* environment must support the root locale for all locale sensitive services in
|
||||
* order to guarantee that this process terminates.
|
||||
* <p>
|
||||
* Providers of names (but not providers of other objects) are allowed to
|
||||
* return null for some name requests even for locales that they claim to
|
||||
* support by including them in their return value for
|
||||
* <code>getAvailableLocales</code>. Similarly, the Java runtime
|
||||
* environment itself may not have all names for all locales that it
|
||||
* supports. This is because the sets of objects for which names are
|
||||
* requested can be large and vary over time, so that it's not always
|
||||
* feasible to cover them completely. If the Java runtime environment or a
|
||||
* provider returns null instead of a name, the lookup will proceed as
|
||||
* described above as if the locale was not supported.
|
||||
* <p>
|
||||
* Starting from JDK8, the search order of locale sensitive services can
|
||||
* be configured by using the "java.locale.providers" system property.
|
||||
* This system property declares the user's preferred order for looking up
|
||||
* the locale sensitive services separated by a comma. It is only read at
|
||||
* the Java runtime startup, so the later call to System.setProperty() won't
|
||||
* affect the order.
|
||||
* <p>
|
||||
* For example, if the following is specified in the property:
|
||||
* <pre>
|
||||
* java.locale.providers=SPI,JRE
|
||||
* </pre>
|
||||
* where "SPI" represents the locale sensitive services implemented in the
|
||||
* installed SPI providers, and "JRE" represents the locale sensitive services
|
||||
* in the Java Runtime Environment, the locale sensitive services in the SPI
|
||||
* providers are looked up first.
|
||||
* <p>
|
||||
* There are two other possible locale sensitive service providers, i.e., "CLDR"
|
||||
* which is a provider based on Unicode Consortium's
|
||||
* <a href="http://cldr.unicode.org/">CLDR Project</a>, and "HOST" which is a
|
||||
* provider that reflects the user's custom settings in the underlying operating
|
||||
* system. These two providers may not be available, depending on the Java Runtime
|
||||
* Environment implementation. Specifying "JRE,SPI" is identical to the default
|
||||
* behavior, which is compatibile with the prior releases.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public abstract class LocaleServiceProvider {
|
||||
|
||||
/**
|
||||
* Sole constructor. (For invocation by subclass constructors, typically
|
||||
* implicit.)
|
||||
*/
|
||||
protected LocaleServiceProvider() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of all locales for which this locale service provider
|
||||
* can provide localized objects or names. This information is used to
|
||||
* compose {@code getAvailableLocales()} values of the locale-dependent
|
||||
* services, such as {@code DateFormat.getAvailableLocales()}.
|
||||
*
|
||||
* <p>The array returned by this method should not include two or more
|
||||
* {@code Locale} objects only differing in their extensions.
|
||||
*
|
||||
* @return An array of all locales for which this locale service provider
|
||||
* can provide localized objects or names.
|
||||
*/
|
||||
public abstract Locale[] getAvailableLocales();
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the given {@code locale} is supported by
|
||||
* this locale service provider. The given {@code locale} may contain
|
||||
* <a href="../Locale.html#def_extensions">extensions</a> that should be
|
||||
* taken into account for the support determination.
|
||||
*
|
||||
* <p>The default implementation returns {@code true} if the given {@code locale}
|
||||
* is equal to any of the available {@code Locale}s returned by
|
||||
* {@link #getAvailableLocales()} with ignoring any extensions in both the
|
||||
* given {@code locale} and the available locales. Concrete locale service
|
||||
* provider implementations should override this method if those
|
||||
* implementations are {@code Locale} extensions-aware. For example,
|
||||
* {@code DecimalFormatSymbolsProvider} implementations will need to check
|
||||
* extensions in the given {@code locale} to see if any numbering system is
|
||||
* specified and can be supported. However, {@code CollatorProvider}
|
||||
* implementations may not be affected by any particular numbering systems,
|
||||
* and in that case, extensions for numbering systems should be ignored.
|
||||
*
|
||||
* @param locale a {@code Locale} to be tested
|
||||
* @return {@code true} if the given {@code locale} is supported by this
|
||||
* provider; {@code false} otherwise.
|
||||
* @throws NullPointerException
|
||||
* if the given {@code locale} is {@code null}
|
||||
* @see Locale#hasExtensions()
|
||||
* @see Locale#stripExtensions()
|
||||
* @since 1.8
|
||||
*/
|
||||
public boolean isSupportedLocale(Locale locale) {
|
||||
locale = locale.stripExtensions(); // throws NPE if locale == null
|
||||
for (Locale available : getAvailableLocales()) {
|
||||
if (locale.equals(available.stripExtensions())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
65
jdkSrc/jdk8/java/util/spi/ResourceBundleControlProvider.java
Normal file
65
jdkSrc/jdk8/java/util/spi/ResourceBundleControlProvider.java
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package java.util.spi;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* An interface for service providers that provide implementations of {@link
|
||||
* java.util.ResourceBundle.Control}. The <a
|
||||
* href="../ResourceBundle.html#default_behavior">default resource bundle loading
|
||||
* behavior</a> of the {@code ResourceBundle.getBundle} factory methods that take
|
||||
* no {@link java.util.ResourceBundle.Control} instance can be modified with {@code
|
||||
* ResourceBundleControlProvider} implementations.
|
||||
*
|
||||
* <p>Provider implementations must be packaged using the <a
|
||||
* href="../../../../technotes/guides/extensions/index.html">Java Extension
|
||||
* Mechanism</a> as installed extensions. Refer to {@link java.util.ServiceLoader}
|
||||
* for the extension packaging. Any installed {@code
|
||||
* ResourceBundleControlProvider} implementations are loaded using {@link
|
||||
* java.util.ServiceLoader} at the {@code ResourceBundle} class loading time.
|
||||
*
|
||||
* @author Masayoshi Okutsu
|
||||
* @since 1.8
|
||||
* @see ResourceBundle#getBundle(String, java.util.Locale, ClassLoader, ResourceBundle.Control)
|
||||
* ResourceBundle.getBundle
|
||||
* @see java.util.ServiceLoader#loadInstalled(Class)
|
||||
*/
|
||||
public interface ResourceBundleControlProvider {
|
||||
/**
|
||||
* Returns a {@code ResourceBundle.Control} instance that is used
|
||||
* to handle resource bundle loading for the given {@code
|
||||
* baseName}. This method must return {@code null} if the given
|
||||
* {@code baseName} isn't handled by this provider.
|
||||
*
|
||||
* @param baseName the base name of the resource bundle
|
||||
* @return a {@code ResourceBundle.Control} instance,
|
||||
* or {@code null} if the given {@code baseName} is not
|
||||
* applicable to this provider.
|
||||
* @throws NullPointerException if {@code baseName} is {@code null}
|
||||
*/
|
||||
public ResourceBundle.Control getControl(String baseName);
|
||||
}
|
||||
110
jdkSrc/jdk8/java/util/spi/TimeZoneNameProvider.java
Normal file
110
jdkSrc/jdk8/java/util/spi/TimeZoneNameProvider.java
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package java.util.spi;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* An abstract class for service providers that
|
||||
* provide localized time zone names for the
|
||||
* {@link java.util.TimeZone TimeZone} class.
|
||||
* The localized time zone names available from the implementations of
|
||||
* this class are also the source for the
|
||||
* {@link java.text.DateFormatSymbols#getZoneStrings()
|
||||
* DateFormatSymbols.getZoneStrings()} method.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public abstract class TimeZoneNameProvider extends LocaleServiceProvider {
|
||||
|
||||
/**
|
||||
* Sole constructor. (For invocation by subclass constructors, typically
|
||||
* implicit.)
|
||||
*/
|
||||
protected TimeZoneNameProvider() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a name for the given time zone ID that's suitable for
|
||||
* presentation to the user in the specified locale. The given time
|
||||
* zone ID is "GMT" or one of the names defined using "Zone" entries
|
||||
* in the "tz database", a public domain time zone database at
|
||||
* <a href="ftp://elsie.nci.nih.gov/pub/">ftp://elsie.nci.nih.gov/pub/</a>.
|
||||
* The data of this database is contained in a file whose name starts with
|
||||
* "tzdata", and the specification of the data format is part of the zic.8
|
||||
* man page, which is contained in a file whose name starts with "tzcode".
|
||||
* <p>
|
||||
* If <code>daylight</code> is true, the method should return a name
|
||||
* appropriate for daylight saving time even if the specified time zone
|
||||
* has not observed daylight saving time in the past.
|
||||
*
|
||||
* @param ID a time zone ID string
|
||||
* @param daylight if true, return the daylight saving name.
|
||||
* @param style either {@link java.util.TimeZone#LONG TimeZone.LONG} or
|
||||
* {@link java.util.TimeZone#SHORT TimeZone.SHORT}
|
||||
* @param locale the desired locale
|
||||
* @return the human-readable name of the given time zone in the
|
||||
* given locale, or null if it's not available.
|
||||
* @exception IllegalArgumentException if <code>style</code> is invalid,
|
||||
* or <code>locale</code> isn't one of the locales returned from
|
||||
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
|
||||
* getAvailableLocales()}.
|
||||
* @exception NullPointerException if <code>ID</code> or <code>locale</code>
|
||||
* is null
|
||||
* @see java.util.TimeZone#getDisplayName(boolean, int, java.util.Locale)
|
||||
*/
|
||||
public abstract String getDisplayName(String ID, boolean daylight, int style, Locale locale);
|
||||
|
||||
/**
|
||||
* Returns a generic name for the given time zone {@code ID} that's suitable
|
||||
* for presentation to the user in the specified {@code locale}. Generic
|
||||
* time zone names are neutral from standard time and daylight saving
|
||||
* time. For example, "PT" is the short generic name of time zone ID {@code
|
||||
* America/Los_Angeles}, while its short standard time and daylight saving
|
||||
* time names are "PST" and "PDT", respectively. Refer to
|
||||
* {@link #getDisplayName(String, boolean, int, Locale) getDisplayName}
|
||||
* for valid time zone IDs.
|
||||
*
|
||||
* <p>The default implementation of this method returns {@code null}.
|
||||
*
|
||||
* @param ID a time zone ID string
|
||||
* @param style either {@link java.util.TimeZone#LONG TimeZone.LONG} or
|
||||
* {@link java.util.TimeZone#SHORT TimeZone.SHORT}
|
||||
* @param locale the desired locale
|
||||
* @return the human-readable generic name of the given time zone in the
|
||||
* given locale, or {@code null} if it's not available.
|
||||
* @exception IllegalArgumentException if <code>style</code> is invalid,
|
||||
* or <code>locale</code> isn't one of the locales returned from
|
||||
* {@link LocaleServiceProvider#getAvailableLocales()
|
||||
* getAvailableLocales()}.
|
||||
* @exception NullPointerException if <code>ID</code> or <code>locale</code>
|
||||
* is {@code null}
|
||||
* @since 1.8
|
||||
*/
|
||||
public String getGenericDisplayName(String ID, int style, Locale locale) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user