java.lang.Object | |
↳ | java.util.ResourceBundle |
Known Direct Subclasses |
ResourceBundle
is an abstract class which is the superclass of classes which
provide Locale
-specific resources. A bundle contains a number of named
resources, where the names are Strings
. A bundle may have a parent bundle,
and when a resource is not found in a bundle, the parent bundle is searched for
the resource. If the fallback mechanism reaches the base bundle and still
can't find the resource it throws a MissingResourceException
.
ResourceBundle
.ResourceBundle
.
PREEURO
where the
currency of come countries changed. The country bundle would return the
current currency (Euro) and the PREEURO
variant bundle would return the old
currency (e.g. DM for Germany).Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
parent | The parent of this ResourceBundle that is used if this bundle doesn't
include the requested resource. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new instance of this class.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Finds the named resource bundle for the specified
Locale and ClassLoader . | |||||||||||
Finds the named
ResourceBundle for the specified Locale and the caller
ClassLoader . | |||||||||||
Finds the named resource bundle for the default
Locale and the caller's
ClassLoader . | |||||||||||
Returns the names of the resources contained in this
ResourceBundle . | |||||||||||
Gets the
Locale of this ResourceBundle . | |||||||||||
Returns the named resource from this
ResourceBundle . | |||||||||||
Returns the named string resource from this
ResourceBundle . | |||||||||||
Returns the named resource from this
ResourceBundle . |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns the named resource from this
ResourceBundle , or null if the
resource is not found. | |||||||||||
Sets the parent resource bundle of this
ResourceBundle . |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
|
The parent of this ResourceBundle
that is used if this bundle doesn't
include the requested resource.
Finds the named resource bundle for the specified Locale
and ClassLoader
.
The passed base name and Locale
are used to create resource bundle names.
The first name is created by concatenating the base name with the result
of toString()
. From this name all parent bundle names are
derived. Then the same thing is done for the default Locale
. This results
in a list of possible bundle names.
Example For the basename "BaseName", the Locale
of the
German part of Switzerland (de_CH) and the default Locale
en_US the list
would look something like this:
ResourceBundle
with the names provided.
If such a class can be instantiated and initialized, it is returned and
all the parent bundles are instantiated too. If no such class can be
found this method tries to load a .properties
file with the names by
replacing dots in the base name with a slash and by appending
".properties
" at the end of the string. If such a resource can be found
by calling getResource(String)
it is used to
initialize a PropertyResourceBundle
. If this succeeds, it will
also load the parents of this ResourceBundle
.
For compatibility with older code, the bundle name isn't required to be
a fully qualified class name. It's also possible to directly pass
the path to a properties file (without a file extension).bundleName | the name of the ResourceBundle . |
---|---|
locale | the Locale . |
loader | the ClassLoader to use. |
ResourceBundle
.MissingResourceException | if the ResourceBundle cannot be found.
|
---|
Finds the named ResourceBundle
for the specified Locale
and the caller
ClassLoader
.
bundleName | the name of the ResourceBundle . |
---|---|
locale | the Locale . |
MissingResourceException | if the resource bundle cannot be found. |
---|
Finds the named resource bundle for the default Locale
and the caller's
ClassLoader
.
bundleName | the name of the ResourceBundle . |
---|
ResourceBundle
.MissingResourceException | if the ResourceBundle cannot be found.
|
---|
Returns the names of the resources contained in this ResourceBundle
.
Enumeration
of the resource names.
Gets the Locale
of this ResourceBundle
. In case a bundle was not
found for the requested Locale
, this will return the actual Locale
of
this resource bundle that was found after doing a fallback.
Locale
of this ResourceBundle
.
Returns the named resource from this ResourceBundle
. If the resource
cannot be found in this bundle, it falls back to the parent bundle (if
it's not null) by calling the handleGetObject(String)
method. If the resource still
can't be found it throws a MissingResourceException
.
key | the name of the resource. |
---|
MissingResourceException | if the resource is not found. |
---|
Returns the named string resource from this ResourceBundle
.
key | the name of the resource. |
---|
MissingResourceException | if the resource is not found. |
---|---|
ClassCastException | if the resource found is not a string. |
Returns the named resource from this ResourceBundle
.
key | the name of the resource. |
---|
MissingResourceException | if the resource is not found. |
---|---|
ClassCastException | if the resource found is not an array of strings. |
Returns the named resource from this ResourceBundle
, or null if the
resource is not found.
key | the name of the resource. |
---|
Sets the parent resource bundle of this ResourceBundle
. The parent is
searched for resources which are not found in this ResourceBundle
.
bundle | the parent ResourceBundle .
|
---|