Showing the changes to java/pkg/java/util/spi (10 of 18352 files). Show all
Unified · Split
Binary file not shown.
| @@ -0,0 +1,119 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package java.util.spi; | |
| 27 | + | |
| 28 | +import java.util.Arrays; | |
| 29 | +import java.util.Currency; | |
| 30 | +import java.util.List; | |
| 31 | +import java.util.Locale; | |
| 32 | + | |
| 33 | +/** | |
| 34 | + * An abstract class for service providers that | |
| 35 | + * provide localized currency symbols and display names for the | |
| 36 | + * {@link java.util.Currency Currency} class. | |
| 37 | + * Note that currency symbols are considered names when determining | |
| 38 | + * behaviors described in the | |
| 39 | + * {@link java.util.spi.LocaleServiceProvider LocaleServiceProvider} | |
| 40 | + * specification. | |
| 41 | + * | |
| 42 | + * @since 1.6 | |
| 43 | + */ | |
| 44 | +public abstract class CurrencyNameProvider extends LocaleServiceProvider { | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * Sole constructor. (For invocation by subclass constructors, typically | |
| 48 | + * implicit.) | |
| 49 | + */ | |
| 50 | + protected CurrencyNameProvider() { | |
| 51 | + } | |
| 52 | + | |
| 53 | + /** | |
| 54 | + * Gets the symbol of the given currency code for the specified locale. | |
| 55 | + * For example, for "USD" (US Dollar), the symbol is "$" if the specified | |
| 56 | + * locale is the US, while for other locales it may be "US$". If no | |
| 57 | + * symbol can be determined, null should be returned. | |
| 58 | + * | |
| 59 | + * @param currencyCode the ISO 4217 currency code, which | |
| 60 | + * consists of three upper-case letters between 'A' (U+0041) and | |
| 61 | + * 'Z' (U+005A) | |
| 62 | + * @param locale the desired locale | |
| 63 | + * @return the symbol of the given currency code for the specified locale, or null if | |
| 64 | + * the symbol is not available for the locale | |
| 65 | + * @exception NullPointerException if <code>currencyCode</code> or | |
| 66 | + * <code>locale</code> is null | |
| 67 | + * @exception IllegalArgumentException if <code>currencyCode</code> is not in | |
| 68 | + * the form of three upper-case letters, or <code>locale</code> isn't | |
| 69 | + * one of the locales returned from | |
| 70 | + * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales() | |
| 71 | + * getAvailableLocales()}. | |
| 72 | + * @see java.util.Currency#getSymbol(java.util.Locale) | |
| 73 | + */ | |
| 74 | + public abstract String getSymbol(String currencyCode, Locale locale); | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * Returns a name for the currency that is appropriate for display to the | |
| 78 | + * user. The default implementation returns null. | |
| 79 | + * | |
| 80 | + * @param currencyCode the ISO 4217 currency code, which | |
| 81 | + * consists of three upper-case letters between 'A' (U+0041) and | |
| 82 | + * 'Z' (U+005A) | |
| 83 | + * @param locale the desired locale | |
| 84 | + * @return the name for the currency that is appropriate for display to the | |
| 85 | + * user, or null if the name is not available for the locale | |
| 86 | + * @exception IllegalArgumentException if <code>currencyCode</code> is not in | |
| 87 | + * the form of three upper-case letters, or <code>locale</code> isn't | |
| 88 | + * one of the locales returned from | |
| 89 | + * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales() | |
| 90 | + * getAvailableLocales()}. | |
| 91 | + * @exception NullPointerException if <code>currencyCode</code> or | |
| 92 | + * <code>locale</code> is <code>null</code> | |
| 93 | + * @since 1.7 | |
| 94 | + */ | |
| 95 | + public String getDisplayName(String currencyCode, Locale locale) { | |
| 96 | + if (currencyCode == null || locale == null) { | |
| 97 | + throw new NullPointerException(); | |
| 98 | + } | |
| 99 | + | |
| 100 | + // Check whether the currencyCode is valid | |
| 101 | + char[] charray = currencyCode.toCharArray(); | |
| 102 | + if (charray.length != 3) { | |
| 103 | + throw new IllegalArgumentException("The currencyCode is not in the form of three upper-case letters."); | |
| 104 | + } | |
| 105 | + for (char c : charray) { | |
| 106 | + if (c < 'A' || c > 'Z') { | |
| 107 | + throw new IllegalArgumentException("The currencyCode is not in the form of three upper-case letters."); | |
| 108 | + } | |
| 109 | + } | |
| 110 | + | |
| 111 | + // Check whether the locale is valid | |
| 112 | + List<Locale> avail = Arrays.asList(getAvailableLocales()); | |
| 113 | + if (!avail.contains(locale)) { | |
| 114 | + throw new IllegalArgumentException("The locale is not available"); | |
| 115 | + } | |
| 116 | + | |
| 117 | + return null; | |
| 118 | + } | |
| 119 | +} | |
Binary file not shown.
| @@ -0,0 +1,144 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package java.util.spi; | |
| 27 | + | |
| 28 | +import java.util.Locale; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * An abstract class for service providers that | |
| 32 | + * provide localized names for the | |
| 33 | + * {@link java.util.Locale Locale} class. | |
| 34 | + * | |
| 35 | + * @since 1.6 | |
| 36 | + */ | |
| 37 | +public abstract class LocaleNameProvider extends LocaleServiceProvider { | |
| 38 | + | |
| 39 | + /** | |
| 40 | + * Sole constructor. (For invocation by subclass constructors, typically | |
| 41 | + * implicit.) | |
| 42 | + */ | |
| 43 | + protected LocaleNameProvider() { | |
| 44 | + } | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt"> | |
| 48 | + * IETF BCP47</a> language code and the given locale that is appropriate for | |
| 49 | + * display to the user. | |
| 50 | + * For example, if <code>languageCode</code> is "fr" and <code>locale</code> | |
| 51 | + * is en_US, getDisplayLanguage() will return "French"; if <code>languageCode</code> | |
| 52 | + * is "en" and <code>locale</code> is fr_FR, getDisplayLanguage() will return "anglais". | |
| 53 | + * If the name returned cannot be localized according to <code>locale</code>, | |
| 54 | + * (say, the provider does not have a Japanese name for Croatian), | |
| 55 | + * this method returns null. | |
| 56 | + * @param languageCode the language code string in the form of two to eight | |
| 57 | + * lower-case letters between 'a' (U+0061) and 'z' (U+007A) | |
| 58 | + * @param locale the desired locale | |
| 59 | + * @return the name of the given language code for the specified locale, or null if it's not | |
| 60 | + * available. | |
| 61 | + * @exception NullPointerException if <code>languageCode</code> or <code>locale</code> is null | |
| 62 | + * @exception IllegalArgumentException if <code>languageCode</code> is not in the form of | |
| 63 | + * two or three lower-case letters, or <code>locale</code> isn't | |
| 64 | + * one of the locales returned from | |
| 65 | + * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales() | |
| 66 | + * getAvailableLocales()}. | |
| 67 | + * @see java.util.Locale#getDisplayLanguage(java.util.Locale) | |
| 68 | + */ | |
| 69 | + public abstract String getDisplayLanguage(String languageCode, Locale locale); | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt"> | |
| 73 | + * IETF BCP47</a> script code and the given locale that is appropriate for | |
| 74 | + * display to the user. | |
| 75 | + * For example, if <code>scriptCode</code> is "Latn" and <code>locale</code> | |
| 76 | + * is en_US, getDisplayScript() will return "Latin"; if <code>scriptCode</code> | |
| 77 | + * is "Cyrl" and <code>locale</code> is fr_FR, getDisplayScript() will return "cyrillique". | |
| 78 | + * If the name returned cannot be localized according to <code>locale</code>, | |
| 79 | + * (say, the provider does not have a Japanese name for Cyrillic), | |
| 80 | + * this method returns null. The default implementation returns null. | |
| 81 | + * @param scriptCode the four letter script code string in the form of title-case | |
| 82 | + * letters (the first letter is upper-case character between 'A' (U+0041) and | |
| 83 | + * 'Z' (U+005A) followed by three lower-case character between 'a' (U+0061) | |
| 84 | + * and 'z' (U+007A)). | |
| 85 | + * @param locale the desired locale | |
| 86 | + * @return the name of the given script code for the specified locale, or null if it's not | |
| 87 | + * available. | |
| 88 | + * @exception NullPointerException if <code>scriptCode</code> or <code>locale</code> is null | |
| 89 | + * @exception IllegalArgumentException if <code>scriptCode</code> is not in the form of | |
| 90 | + * four title case letters, or <code>locale</code> isn't | |
| 91 | + * one of the locales returned from | |
| 92 | + * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales() | |
| 93 | + * getAvailableLocales()}. | |
| 94 | + * @see java.util.Locale#getDisplayScript(java.util.Locale) | |
| 95 | + * @since 1.7 | |
| 96 | + */ | |
| 97 | + public String getDisplayScript(String scriptCode, Locale locale) { | |
| 98 | + return null; | |
| 99 | + } | |
| 100 | + | |
| 101 | + /** | |
| 102 | + * Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt"> | |
| 103 | + * IETF BCP47</a> region code (either ISO 3166 country code or UN M.49 area | |
| 104 | + * codes) and the given locale that is appropriate for display to the user. | |
| 105 | + * For example, if <code>countryCode</code> is "FR" and <code>locale</code> | |
| 106 | + * is en_US, getDisplayCountry() will return "France"; if <code>countryCode</code> | |
| 107 | + * is "US" and <code>locale</code> is fr_FR, getDisplayCountry() will return "Etats-Unis". | |
| 108 | + * If the name returned cannot be localized according to <code>locale</code>, | |
| 109 | + * (say, the provider does not have a Japanese name for Croatia), | |
| 110 | + * this method returns null. | |
| 111 | + * @param countryCode the country(region) code string in the form of two | |
| 112 | + * upper-case letters between 'A' (U+0041) and 'Z' (U+005A) or the UN M.49 area code | |
| 113 | + * in the form of three digit letters between '0' (U+0030) and '9' (U+0039). | |
| 114 | + * @param locale the desired locale | |
| 115 | + * @return the name of the given country code for the specified locale, or null if it's not | |
| 116 | + * available. | |
| 117 | + * @exception NullPointerException if <code>countryCode</code> or <code>locale</code> is null | |
| 118 | + * @exception IllegalArgumentException if <code>countryCode</code> is not in the form of | |
| 119 | + * two upper-case letters or three digit letters, or <code>locale</code> isn't | |
| 120 | + * one of the locales returned from | |
| 121 | + * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales() | |
| 122 | + * getAvailableLocales()}. | |
| 123 | + * @see java.util.Locale#getDisplayCountry(java.util.Locale) | |
| 124 | + */ | |
| 125 | + public abstract String getDisplayCountry(String countryCode, Locale locale); | |
| 126 | + | |
| 127 | + /** | |
| 128 | + * Returns a localized name for the given variant code and the given locale that | |
| 129 | + * is appropriate for display to the user. | |
| 130 | + * If the name returned cannot be localized according to <code>locale</code>, | |
| 131 | + * this method returns null. | |
| 132 | + * @param variant the variant string | |
| 133 | + * @param locale the desired locale | |
| 134 | + * @return the name of the given variant string for the specified locale, or null if it's not | |
| 135 | + * available. | |
| 136 | + * @exception NullPointerException if <code>variant</code> or <code>locale</code> is null | |
| 137 | + * @exception IllegalArgumentException if <code>locale</code> isn't | |
| 138 | + * one of the locales returned from | |
| 139 | + * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales() | |
| 140 | + * getAvailableLocales()}. | |
| 141 | + * @see java.util.Locale#getDisplayVariant(java.util.Locale) | |
| 142 | + */ | |
| 143 | + public abstract String getDisplayVariant(String variant, Locale locale); | |
| 144 | +} | |
Binary file not shown.
| @@ -0,0 +1,138 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package java.util.spi; | |
| 27 | + | |
| 28 | +import java.util.Locale; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * <p> | |
| 32 | + * This is the super class of all the locale sensitive service provider | |
| 33 | + * interfaces (SPIs). | |
| 34 | + * <p> | |
| 35 | + * Locale sensitive service provider interfaces are interfaces that | |
| 36 | + * correspond to locale sensitive classes in the <code>java.text</code> | |
| 37 | + * and <code>java.util</code> packages. The interfaces enable the | |
| 38 | + * construction of locale sensitive objects and the retrieval of | |
| 39 | + * localized names for these packages. Locale sensitive factory methods | |
| 40 | + * and methods for name retrieval in the <code>java.text</code> and | |
| 41 | + * <code>java.util</code> packages use implementations of the provider | |
| 42 | + * interfaces to offer support for locales beyond the set of locales | |
| 43 | + * supported by the Java runtime environment itself. | |
| 44 | + * <p> | |
| 45 | + * <h4>Packaging of Locale Sensitive Service Provider Implementations</h4> | |
| 46 | + * Implementations of these locale sensitive services are packaged using the | |
| 47 | + * <a href="../../../../technotes/guides/extensions/index.html">Java Extension Mechanism</a> | |
| 48 | + * as installed extensions. A provider identifies itself with a | |
| 49 | + * provider-configuration file in the resource directory META-INF/services, | |
| 50 | + * using the fully qualified provider interface class name as the file name. | |
| 51 | + * The file should contain a list of fully-qualified concrete provider class names, | |
| 52 | + * one per line. A line is terminated by any one of a line feed ('\n'), a carriage | |
| 53 | + * return ('\r'), or a carriage return followed immediately by a line feed. Space | |
| 54 | + * and tab characters surrounding each name, as well as blank lines, are ignored. | |
| 55 | + * The comment character is '#' ('\u0023'); on each line all characters following | |
| 56 | + * the first comment character are ignored. The file must be encoded in UTF-8. | |
| 57 | + * <p> | |
| 58 | + * If a particular concrete provider class is named in more than one configuration | |
| 59 | + * file, or is named in the same configuration file more than once, then the | |
| 60 | + * duplicates will be ignored. The configuration file naming a particular provider | |
| 61 | + * need not be in the same jar file or other distribution unit as the provider itself. | |
| 62 | + * The provider must be accessible from the same class loader that was initially | |
| 63 | + * queried to locate the configuration file; this is not necessarily the class loader | |
| 64 | + * that loaded the file. | |
| 65 | + * <p> | |
| 66 | + * For example, an implementation of the | |
| 67 | + * {@link java.text.spi.DateFormatProvider DateFormatProvider} class should | |
| 68 | + * take the form of a jar file which contains the file: | |
| 69 | + * <pre> | |
| 70 | + * META-INF/services/java.text.spi.DateFormatProvider | |
| 71 | + * </pre> | |
| 72 | + * And the file <code>java.text.spi.DateFormatProvider</code> should have | |
| 73 | + * a line such as: | |
| 74 | + * <pre> | |
| 75 | + * <code>com.foo.DateFormatProviderImpl</code> | |
| 76 | + * </pre> | |
| 77 | + * which is the fully qualified class name of the class implementing | |
| 78 | + * <code>DateFormatProvider</code>. | |
| 79 | + * <h4>Invocation of Locale Sensitive Services</h4> | |
| 80 | + * <p> | |
| 81 | + * Locale sensitive factory methods and methods for name retrieval in the | |
| 82 | + * <code>java.text</code> and <code>java.util</code> packages invoke | |
| 83 | + * service provider methods when needed to support the requested locale. | |
| 84 | + * The methods first check whether the Java runtime environment itself | |
| 85 | + * supports the requested locale, and use its support if available. | |
| 86 | + * Otherwise, they call the <code>getAvailableLocales()</code> methods of | |
| 87 | + * installed providers for the appropriate interface to find one that | |
| 88 | + * supports the requested locale. If such a provider is found, its other | |
| 89 | + * methods are called to obtain the requested object or name. When checking | |
| 90 | + * whether a locale is supported, the locale's extensions are ignored. | |
| 91 | + * If neither the Java runtime environment itself nor an installed provider | |
| 92 | + * supports the requested locale, the methods go through a list of candidate | |
| 93 | + * locales and repeat the availability check for each until a match is found. | |
| 94 | + * The algorithm used for creating a list of candidate locales is same as | |
| 95 | + * the one used by <code>ResourceBunlde</code> by default (see | |
| 96 | + * {@link java.util.ResourceBundle.Control#getCandidateLocales getCandidateLocales} | |
| 97 | + * for the details). Even if a locale is resolved from the candidate list, | |
| 98 | + * methods that return requested objects or names are invoked with the original | |
| 99 | + * requested locale including extensions. The Java runtime environment must | |
| 100 | + * support the root locale for all locale sensitive services in order to | |
| 101 | + * guarantee that this process terminates. | |
| 102 | + * <p> | |
| 103 | + * Providers of names (but not providers of other objects) are allowed to | |
| 104 | + * return null for some name requests even for locales that they claim to | |
| 105 | + * support by including them in their return value for | |
| 106 | + * <code>getAvailableLocales</code>. Similarly, the Java runtime | |
| 107 | + * environment itself may not have all names for all locales that it | |
| 108 | + * supports. This is because the sets of objects for which names are | |
| 109 | + * requested can be large and vary over time, so that it's not always | |
| 110 | + * feasible to cover them completely. If the Java runtime environment or a | |
| 111 | + * provider returns null instead of a name, the lookup will proceed as | |
| 112 | + * described above as if the locale was not supported. | |
| 113 | + * | |
| 114 | + * @since 1.6 | |
| 115 | + */ | |
| 116 | +public abstract class LocaleServiceProvider { | |
| 117 | + | |
| 118 | + /** | |
| 119 | + * Sole constructor. (For invocation by subclass constructors, typically | |
| 120 | + * implicit.) | |
| 121 | + */ | |
| 122 | + protected LocaleServiceProvider() { | |
| 123 | + } | |
| 124 | + | |
| 125 | + /** | |
| 126 | + * Returns an array of all locales for which this locale service provider | |
| 127 | + * can provide localized objects or names. | |
| 128 | + * <p> | |
| 129 | + * <b>Note:</b> Extensions in a <code>Locale</code> are ignored during | |
| 130 | + * service provider lookup. So the array returned by this method should | |
| 131 | + * not include two or more <code>Locale</code> objects only differing in | |
| 132 | + * their extensions. | |
| 133 | + * | |
| 134 | + * @return An array of all locales for which this locale service provider | |
| 135 | + * can provide localized objects or names. | |
| 136 | + */ | |
| 137 | + public abstract Locale[] getAvailableLocales(); | |
| 138 | +} | |
Binary file not shown.
| @@ -0,0 +1,80 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package java.util.spi; | |
| 27 | + | |
| 28 | +import java.util.Locale; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * An abstract class for service providers that | |
| 32 | + * provide localized time zone names for the | |
| 33 | + * {@link java.util.TimeZone TimeZone} class. | |
| 34 | + * The localized time zone names available from the implementations of | |
| 35 | + * this class are also the source for the | |
| 36 | + * {@link java.text.DateFormatSymbols#getZoneStrings() | |
| 37 | + * DateFormatSymbols.getZoneStrings()} method. | |
| 38 | + * | |
| 39 | + * @since 1.6 | |
| 40 | + */ | |
| 41 | +public abstract class TimeZoneNameProvider extends LocaleServiceProvider { | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * Sole constructor. (For invocation by subclass constructors, typically | |
| 45 | + * implicit.) | |
| 46 | + */ | |
| 47 | + protected TimeZoneNameProvider() { | |
| 48 | + } | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * Returns a name for the given time zone ID that's suitable for | |
| 52 | + * presentation to the user in the specified locale. The given time | |
| 53 | + * zone ID is "GMT" or one of the names defined using "Zone" entries | |
| 54 | + * in the "tz database", a public domain time zone database at | |
| 55 | + * <a href="ftp://elsie.nci.nih.gov/pub/">ftp://elsie.nci.nih.gov/pub/</a>. | |
| 56 | + * The data of this database is contained in a file whose name starts with | |
| 57 | + * "tzdata", and the specification of the data format is part of the zic.8 | |
| 58 | + * man page, which is contained in a file whose name starts with "tzcode". | |
| 59 | + * <p> | |
| 60 | + * If <code>daylight</code> is true, the method should return a name | |
| 61 | + * appropriate for daylight saving time even if the specified time zone | |
| 62 | + * has not observed daylight saving time in the past. | |
| 63 | + * | |
| 64 | + * @param ID a time zone ID string | |
| 65 | + * @param daylight if true, return the daylight saving name. | |
| 66 | + * @param style either {@link java.util.TimeZone#LONG TimeZone.LONG} or | |
| 67 | + * {@link java.util.TimeZone#SHORT TimeZone.SHORT} | |
| 68 | + * @param locale the desired locale | |
| 69 | + * @return the human-readable name of the given time zone in the | |
| 70 | + * given locale, or null if it's not available. | |
| 71 | + * @exception IllegalArgumentException if <code>style</code> is invalid, | |
| 72 | + * or <code>locale</code> isn't one of the locales returned from | |
| 73 | + * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales() | |
| 74 | + * getAvailableLocales()}. | |
| 75 | + * @exception NullPointerException if <code>ID</code> or <code>locale</code> | |
| 76 | + * is null | |
| 77 | + * @see java.util.TimeZone#getDisplayName(boolean, int, java.util.Locale) | |
| 78 | + */ | |
| 79 | + public abstract String getDisplayName(String ID, boolean daylight, int style, Locale locale); | |
| 80 | +} | |
| @@ -0,0 +1,11 @@ | ||
| 1 | +<../../../../../mkconfig | |
| 2 | + | |
| 3 | +TARG=\ | |
| 4 | + CurrencyNameProvider.dis\ | |
| 5 | + LocaleNameProvider.dis\ | |
| 6 | + LocaleServiceProvider.dis\ | |
| 7 | + TimeZoneNameProvider.dis\ | |
| 8 | + | |
| 9 | +DISBIN=$ROOT/java/dis/java/java/java/util/spi | |
| 10 | + | |
| 11 | +<$ROOT/mkfiles/mkjava | |
| @@ -0,0 +1,50 @@ | ||
| 1 | +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> | |
| 2 | +<html> | |
| 3 | +<head> | |
| 4 | +<!-- | |
| 5 | +Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. | |
| 6 | +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 7 | + | |
| 8 | +This code is free software; you can redistribute it and/or modify it | |
| 9 | +under the terms of the GNU General Public License version 2 only, as | |
| 10 | +published by the Free Software Foundation. Oracle designates this | |
| 11 | +particular file as subject to the "Classpath" exception as provided | |
| 12 | +by Oracle in the LICENSE file that accompanied this code. | |
| 13 | + | |
| 14 | +This code is distributed in the hope that it will be useful, but WITHOUT | |
| 15 | +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 16 | +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 17 | +version 2 for more details (a copy is included in the LICENSE file that | |
| 18 | +accompanied this code). | |
| 19 | + | |
| 20 | +You should have received a copy of the GNU General Public License version | |
| 21 | +2 along with this work; if not, write to the Free Software Foundation, | |
| 22 | +Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 23 | + | |
| 24 | +Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 25 | +or visit www.oracle.com if you need additional information or have any | |
| 26 | +questions. | |
| 27 | +--> | |
| 28 | + | |
| 29 | +</head> | |
| 30 | +<body bgcolor="white"> | |
| 31 | +Service provider classes for the classes in the java.util package. | |
| 32 | +<!-- | |
| 33 | +<h2>Package Specification</h2> | |
| 34 | + | |
| 35 | +##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### | |
| 36 | +<ul> | |
| 37 | + <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a> | |
| 38 | +</ul> | |
| 39 | + | |
| 40 | +<h2>Related Documentation</h2> | |
| 41 | + | |
| 42 | +For overviews, tutorials, examples, guides, and tool documentation, please see: | |
| 43 | +<ul> | |
| 44 | + <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> | |
| 45 | +</ul> | |
| 46 | +--> | |
| 47 | + | |
| 48 | +@since 1.6 | |
| 49 | +</body> | |
| 50 | +</html> | |