public class ResourceManager
extends java.lang.Object
ResourceManager
avoids loading instances of ResourceBundle
multiple times by keeping these in a Map
data structure. As
ResourceBundle
s are a kind of unmodifiable Map
-like data
structures, these do not have to be loaded again and again (in contrast to,
e.g., Preferences
).Constructor | Description |
---|---|
ResourceManager() |
Modifier and Type | Method | Description |
---|---|---|
static java.util.ResourceBundle |
getBundle(java.lang.String baseName) |
Loads the
ResourceBundle with the given name for the default
Locale . |
static java.util.ResourceBundle |
getBundle(java.lang.String baseName,
java.util.Locale locale) |
Loads the
ResourceBundle with the given name for the given
Locale . |
public static java.util.ResourceBundle getBundle(java.lang.String baseName)
ResourceBundle
with the given name for the default
Locale
. This method first tries to obtain the desired resource from
the cache. Only if the resource has not yet been loaded it will try to
obtain it from the file system. In this case it will also memorize the
resource in the cache afterwards.baseName
- the name of the desired ResourceBundle
.java.lang.NullPointerException
- if baseName
is null
java.util.MissingResourceException
- if no resource bundle for the specified base name in any of the
Locale
s can be found.java.lang.IllegalArgumentException
- if the given control
doesn't perform properly
(e.g., control.getCandidateLocales
returns
null
.)
Note that validation of control
is performed as
needed.getBundle(String, Locale)
public static java.util.ResourceBundle getBundle(java.lang.String baseName, java.util.Locale locale)
ResourceBundle
with the given name for the given
Locale
. This method first tries to obtain the desired resource from
the cache. Only if the resource has not yet been loaded it will try to
obtain it from the file system. In this case it will also memorize the
resource in the cache afterwards.baseName
- locale
- java.lang.NullPointerException
- if baseName
, locales
or
control
is null
java.util.MissingResourceException
- if no resource bundle for the specified base name in any of the
Locale
s can be found.java.lang.IllegalArgumentException
- if the given control
doesn't perform properly
(e.g., control.getCandidateLocales
returns null
.)
Note that validation of control
is performed as
needed.