Module java.base
Package java.util.spi

## Class AbstractResourceBundleProvider

- java.lang.Object
- - java.util.spi.AbstractResourceBundleProvider

All Implemented Interfaces:
  ResourceBundleProvider

    public abstract class AbstractResourceBundleProvider
    extends Object
    implements ResourceBundleProvider

`AbstractResourceBundleProvider` is an abstract class for helping implement the `ResourceBundleProvider` interface.

Since:
  9

### Constructor Summary

Constructors
`protected` `AbstractResourceBundleProvider()` Constructs an `AbstractResourceBundleProvider` with the "java.properties" format.
`protected` `AbstractResourceBundleProvider(String... formats)` Constructs an `AbstractResourceBundleProvider` with the specified `formats`.

### Method Summary

All Methods Instance Methods Concrete Methods
`ResourceBundle` `getBundle(String baseName, Locale locale)` Returns a `ResourceBundle` for the given `baseName` and `locale`.
`protected String` `toBundleName(String baseName, Locale locale)` Returns the bundle name for the given `baseName` and `locale`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### AbstractResourceBundleProvider

    protected AbstractResourceBundleProvider()

Constructs an `AbstractResourceBundleProvider` with the "java.properties" format. This constructor is equivalent to `AbstractResourceBundleProvider("java.properties")`.

#### AbstractResourceBundleProvider

    protected AbstractResourceBundleProvider(String... formats)

Constructs an `AbstractResourceBundleProvider` with the specified `formats`. The `getBundle(String, Locale)` method looks up resource bundles for the given `formats`. `formats` must be "java.class" or "java.properties".

Parameters:
  `formats` - the formats to be used for loading resource bundles
Throws:
  `NullPointerException` - if the given `formats` is null
  `IllegalArgumentException` - if the given `formats` is not "java.class" or "java.properties".

### Method Detail

#### toBundleName

    protected String toBundleName(String baseName,
                                  Locale locale)

Returns the bundle name for the given `baseName` and `locale`. This method is called from the default implementation of the `getBundle(String, Locale)` method.

Implementation Note:
  The default implementation of this method is the same as the implementation of `ResourceBundle.Control.toBundleName(String, Locale)`.
Parameters:
  `baseName` - the base name of the resource bundle, a fully qualified class name
  `locale` - the locale for which a resource bundle should be loaded
Returns:
  the bundle name for the resource bundle

#### getBundle

    public ResourceBundle getBundle(String baseName,
                                    Locale locale)

Returns a `ResourceBundle` for the given `baseName` and `locale`. This method calls the `toBundleName` method to get the bundle name for the `baseName` and `locale`. The formats specified by the constructor will be searched to find the resource bundle.

Specified by:
  `getBundle` in interface `ResourceBundleProvider`
Implementation Note:
  The default implementation of this method will find the resource bundle local to the module of this provider.
Parameters:
  `baseName` - the base bundle name of the resource bundle, a fully qualified class name.
  `locale` - the locale for which the resource bundle should be instantiated
Returns:
  `ResourceBundle` of the given `baseName` and `locale`, or null if no resource bundle is found
Throws:
  `NullPointerException` - if `baseName` or `locale` is null
  `UncheckedIOException` - if any IO exception occurred during resource bundle loading