org.sbml.jsbml.util
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
).Modifier and Type | Field and Description |
---|---|
private static java.util.Map<java.lang.String,java.util.Map<java.util.Locale,java.util.ResourceBundle>> |
loaded
Locale -dependent memory for already loaded ResourceBundle
instances. |
Constructor and Description |
---|
ResourceManager() |
Modifier and Type | Method and 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 . |
private static java.util.ResourceBundle |
loadBundle(java.lang.String baseName,
java.util.Locale locale)
This loads a
ResourceBundle from the file system for the given
Locale . |
private static java.util.Map<java.lang.String,java.util.Map<java.util.Locale,java.util.ResourceBundle>> loaded
Locale
-dependent memory for already loaded ResourceBundle
instances.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.private static java.util.ResourceBundle loadBundle(java.lang.String baseName, java.util.Locale locale)
ResourceBundle
from the file system for the given
Locale
.baseName
- locale
- ResourceBundle
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.