36511
|
1 |
/*
|
|
2 |
* Copyright (c) 2015, 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 |
import java.util.ResourceBundle;
|
|
30 |
|
|
31 |
/**
|
|
32 |
* {@code ResourceBundleProvider} is a provider interface that is used for
|
|
33 |
* loading resource bundles. Implementation classes of this interface are loaded
|
|
34 |
* with {@link java.util.ServiceLoader ServiceLoader} during a call to the
|
|
35 |
* {@link ResourceBundle#getBundle(String, Locale, ClassLoader)
|
|
36 |
* ResourceBundle.getBundle} method. The provider service type is determined by
|
|
37 |
* {@code basename+"Provider"}. For example, if the base name is
|
|
38 |
* "com.example.app.MyResources", {@code com.example.app.MyResourcesProvider}
|
|
39 |
* will be the provider service type.
|
|
40 |
* <p>
|
|
41 |
* This providers's {@link #getBundle(String, Locale) getBundle} method is called
|
|
42 |
* through the resource bundle loading process instead of {@link
|
|
43 |
* java.util.ResourceBundle.Control#newBundle(String, Locale, String, ClassLoader, boolean)
|
|
44 |
* ResourceBundle.Control.newBundle()}. Refer to {@link ResourceBundle} for
|
|
45 |
* details.
|
|
46 |
*
|
|
47 |
* @since 9
|
|
48 |
*/
|
|
49 |
public interface ResourceBundleProvider {
|
|
50 |
/**
|
|
51 |
* Returns a {@code ResourceBundle} for the given bundle name and locale.
|
|
52 |
* This method returns null if there is no {@code ResourceBundle} found
|
|
53 |
* for the given parameters.
|
|
54 |
*
|
|
55 |
*
|
|
56 |
* @param baseName
|
|
57 |
* the base bundle name of the resource bundle, a fully
|
|
58 |
* qualified class name
|
|
59 |
* @param locale
|
|
60 |
* the locale for which the resource bundle should be loaded
|
|
61 |
* @return the ResourceBundle created for the given parameters, or null if no
|
|
62 |
* {@code ResourceBundle} for the given parameters is found
|
|
63 |
*/
|
|
64 |
public ResourceBundle getBundle(String baseName, Locale locale);
|
|
65 |
}
|