Returns a
List
of
Locale
s as candidate
locales for
baseName
and
locale
. This
method is called by the
ResourceBundle.getBundle
factory method each time the factory method tries finding a
resource bundle for a target
Locale
.
The sequence of the candidate locales also corresponds to the
runtime resource lookup path (also known as the parent
chain), if the corresponding resource bundles for the
candidate locales exist and their parents are not defined by
loaded resource bundles themselves. The last element of the list
must be a root locale if it is desired to
have the base bundle as the terminal of the parent chain.
If the given locale is equal to Locale.ROOT
(the
root locale), a List
containing only the root
Locale
must be returned. In this case, the
ResourceBundle.getBundle
factory method loads only
the base bundle as the resulting resource bundle.
It is not a requirement to return an immutable
(unmodifiable) List
. However, the returned
List
must not be mutated after it has been
returned by getCandidateLocales
.
The default implementation returns a List
containing
Locale
s in the following sequence:
Locale(language, country, variant)
Locale(language, country)
Locale(language)
Locale.ROOT
where
language
,
country
and
variant
are the language, country and variant values
of the given
locale
, respectively. Locales where the
final component values are empty strings are omitted.
The default implementation uses an ArrayList
that
overriding implementations may modify before returning it to the
caller. However, a subclass must not modify it after it has
been returned by getCandidateLocales
.
For example, if the given baseName
is "Messages"
and the given locale
is
Locale("ja", "", "XX")
, then a
List
of Locale
s:
Locale("ja", "", "XX")
Locale("ja")
Locale.ROOT
is returned. And if the resource bundles for the "ja" and
""
Locale
s are found, then the runtime resource
lookup path (parent chain) is:
Messages_ja -> Messages
Returns:
a
List
of candidate
Locale
s for the given
locale
Parameters:
-
baseName - the base name of the resource bundle, a fully
qualified class name
-
locale - the locale for which a resource bundle is desired
Throws:
-
NullPointerException - if
baseName
or
locale
is
null