LocaleServiceProviderPool.java revision 4564
2216N/A * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 0N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 1472N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A * or visit www.oracle.com if you need additional information or have any 0N/A * An instance of this class holds a set of the third party implementations of a particular 0N/A * locale sensitive service, such as {@link java.util.spi.LocaleNameProvider}. 0N/A * A Map that holds singleton instances of this class. Each instance holds a 0N/A * set of provider implementations of a particular locale sensitive service. 342N/A * A Set containing locale service providers that implement the 342N/A * specified provider SPI 2216N/A * A Map that retains Locale->provider mapping 0N/A * Available locales for this locale sensitive service. This also contains 0N/A * JRE's available locales 453N/A * Available locales within this JRE. Currently this is declared as 453N/A * static. This could be non-static later, so that they could have 453N/A * different sets for each locale sensitive services. 113N/A * Provider locales for this locale sensitive service. 113N/A * Special locale for ja_JP with Japanese calendar 0N/A * Special locale for th_TH with Thai numbering system 0N/A * A factory method that returns a singleton instance 0N/A * The sole constructor. 0N/A * @param c class of the locale sensitive service 0N/A * Lazy loaded set of available locales. 0N/A * Loading all locales is a very long operation. 0N/A * Available locales for all locale sensitive services. 0N/A * This also contains JRE's available locales 0N/A // Normalize locales for look up 0N/A * Returns an array of available locales for all the provider classes. 0N/A * This array is a merged array of all the locales that are provided by each 0N/A * provider, including the JRE. 0N/A * @return an array of the available locales for all provider classes 0N/A * Returns an array of available locales. This array is a 0N/A * merged array of all the locales that are provided by each 0N/A * provider, including the JRE. 0N/A * @return an array of the available locales 0N/A * Returns an array of available locales (already normalized 0N/A * for service lookup) from providers. 0N/A * Note that this method does not return a defensive copy. 0N/A * @return list of the provider locales 0N/A * Returns whether any provider for this locale sensitive 0N/A * service is available or not. 0N/A * @return true if any provider is available 0N/A * Returns an array of available locales (already normalized for 342N/A * service lookup) supported by the JRE. 342N/A * Note that this method does not return a defensive copy. 0N/A * @return list of the available JRE locales 1244N/A * Returns whether the given locale is supported by the JRE. 0N/A * @param locale the locale to test. 0N/A * @return true, if the locale is supported by the JRE. false 0N/A * Returns the provider's localized object for the specified 0N/A * @param getter an object on which getObject() method 0N/A * is called to obtain the provider's instance. 0N/A * @param locale the given locale that is used as the starting one 0N/A * @param params provider specific parameters 0N/A * @return provider's instance, or null. 0N/A * Returns the provider's localized name for the specified 0N/A * @param getter an object on which getObject() method 0N/A * is called to obtain the provider's instance. 0N/A * @param locale the given locale that is used as the starting one 0N/A * @param bundle JRE resource bundle that contains 0N/A * the localized names, or null for localized objects. 0N/A * @param key the key string if bundle is supplied, otherwise null. 0N/A * @param params provider specific parameters 0N/A * @return provider's instance, or null. 453N/A * Returns the provider's localized name for the specified 0N/A * @param getter an object on which getObject() method 0N/A * is called to obtain the provider's instance. 0N/A * @param locale the given locale that is used as the starting one 0N/A * @param bundleKey JRE specific bundle key. e.g., "USD" is for currency 0N/A symbol and "usd" is for currency display name in the JRE bundle. 0N/A * @param bundle JRE resource bundle that contains 342N/A * the localized names, or null for localized objects. 342N/A * @param key the key string if bundle is supplied, otherwise null. 342N/A * @param params provider specific parameters 342N/A * @return provider's instance, or null. 0N/A // check whether a provider has an implementation that's closer 0N/A // to the requested locale than the bundle we've found (for 0N/A // localized names), or Java runtime's supported locale 0N/A // (for localized objects) 0N/A "A locale sensitive service provider returned null for a localized objects, which should not happen. provider: " +
lsp +
" locale: " +
locale);
0N/A // look up the JRE bundle and its parent chain. Only 0N/A // providers for localized names are checked hereafter. 0N/A // try parent bundle 0N/A * Returns a locale service provider instance that supports 0N/A * the specified locale. 0N/A * @param locale the given locale 0N/A * @return the provider, or null if there is 0N/A * no provider available. 0N/A * Returns a list of candidate locales for service look up. 0N/A * @param locale the input locale 0N/A * @return the list of candiate locales for the given locale 0N/A // Note: We currently use the default implementation of 0N/A // ResourceBundle.Control.getCandidateLocales. The result 0N/A // returned by getCandidateLocales are already normalized 0N/A // (no extensions) for service look up. 0N/A * Returns an instance of Locale used for service look up. 0N/A * The result Locale has no extensions except for ja_JP_JP 0N/A * @param locale the locale 0N/A * @return the locale used for service look up 0N/A // remove extensions 0N/A // A Locale with non-empty extensions 0N/A // should have well-formed fields except 0N/A // for ja_JP_JP and th_TH_TH. Therefore, 0N/A // it should never enter in this catch clause. 0N/A config(
"A locale(" +
locale +
") has non-empty extensions, but has illformed fields.");
0N/A // Fallback - script field will be lost. 0N/A * A dummy locale service provider that indicates there is no 0N/A * provider available 0N/A * An interface to get a localized object for each locale sensitve 0N/A * Returns an object from the provider 0N/A * @param lsp the provider 0N/A * @param locale the locale 0N/A * @param key key string to localize, or null if the provider is not 0N/A * @param params provider specific params 0N/A * @return localized object from the provider