jdk/src/java.base/share/classes/java/util/spi/ResourceBundleProvider.java
author mchung
Fri, 03 Jun 2016 12:26:45 -0700
changeset 38782 ff27bc5c278e
parent 36511 9d0388c6b336
child 43712 5dfd0950317c
permissions -rw-r--r--
8158604: test/java/util/ResourceBundle/modules/appbasic missing @test Reviewed-by: alanb, okutsu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     1
/*
38782
ff27bc5c278e 8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents: 36511
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     4
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    10
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    15
 * accompanied this code).
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    16
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    20
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    23
 * questions.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    24
 */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    25
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    26
package java.util.spi;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    27
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    28
import java.util.Locale;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    29
import java.util.ResourceBundle;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    30
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    31
/**
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    32
 * {@code ResourceBundleProvider} is a provider interface that is used for
38782
ff27bc5c278e 8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents: 36511
diff changeset
    33
 * loading resource bundles for named modules. Implementation classes of
ff27bc5c278e 8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents: 36511
diff changeset
    34
 * this interface are loaded with {@link java.util.ServiceLoader ServiceLoader}
ff27bc5c278e 8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents: 36511
diff changeset
    35
 * during a call to the
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    36
 * {@link ResourceBundle#getBundle(String, Locale, ClassLoader)
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    37
 * ResourceBundle.getBundle} method. The provider service type is determined by
38782
ff27bc5c278e 8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents: 36511
diff changeset
    38
 * {@code basename+"Provider"}.
ff27bc5c278e 8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents: 36511
diff changeset
    39
 *
ff27bc5c278e 8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents: 36511
diff changeset
    40
 * <p>
ff27bc5c278e 8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents: 36511
diff changeset
    41
 * For example, if the base name is "com.example.app.MyResources",
ff27bc5c278e 8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents: 36511
diff changeset
    42
 * {@code com.example.app.MyResourcesProvider} will be the provider service type:
ff27bc5c278e 8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents: 36511
diff changeset
    43
 * <pre>{@code
ff27bc5c278e 8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents: 36511
diff changeset
    44
 * public interface MyResourcesProvider extends ResourceBundleProvider {
ff27bc5c278e 8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents: 36511
diff changeset
    45
 * }
ff27bc5c278e 8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents: 36511
diff changeset
    46
 * }</pre>
ff27bc5c278e 8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents: 36511
diff changeset
    47
 *
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    48
 * <p>
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    49
 * This providers's {@link #getBundle(String, Locale) getBundle} method is called
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    50
 * through the resource bundle loading process instead of {@link
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    51
 * java.util.ResourceBundle.Control#newBundle(String, Locale, String, ClassLoader, boolean)
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    52
 * ResourceBundle.Control.newBundle()}. Refer to {@link ResourceBundle} for
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    53
 * details.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    54
 *
38782
ff27bc5c278e 8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents: 36511
diff changeset
    55
 * @see <a href="../ResourceBundle.html#bundleprovider">
ff27bc5c278e 8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents: 36511
diff changeset
    56
 *     Resource Bundles in Named Modules</a>
ff27bc5c278e 8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents: 36511
diff changeset
    57
 * @see <a href="../ResourceBundle.html#RBP_support">
ff27bc5c278e 8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents: 36511
diff changeset
    58
 *     ResourceBundleProvider Service Providers</a>
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    59
 * @since 9
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    60
 */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    61
public interface ResourceBundleProvider {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    62
    /**
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    63
     * Returns a {@code ResourceBundle} for the given bundle name and locale.
38782
ff27bc5c278e 8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents: 36511
diff changeset
    64
     * This method returns {@code null} if there is no {@code ResourceBundle}
ff27bc5c278e 8158604: test/java/util/ResourceBundle/modules/appbasic missing @test
mchung
parents: 36511
diff changeset
    65
     * found for the given parameters.
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    66
     *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    67
     *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    68
     * @param baseName
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    69
     *        the base bundle name of the resource bundle, a fully
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    70
     *        qualified class name
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    71
     * @param locale
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    72
     *        the locale for which the resource bundle should be loaded
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    73
     * @return the ResourceBundle created for the given parameters, or null if no
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    74
     *         {@code ResourceBundle} for the given parameters is found
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    75
     */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    76
    public ResourceBundle getBundle(String baseName, Locale locale);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    77
}