public class DefaultResourceHandler extends Object implements DMXResourceHandler
Modifier and Type | Field and Description |
---|---|
protected Map<String,Object> |
callbackResourceMap
Maps of resources registered by callbacks.
|
protected Map<String,Object> |
resourceMap
Map of loaded resources for application.
|
Constructor and Description |
---|
DefaultResourceHandler()
Creates new instance.
|
Modifier and Type | Method and Description |
---|---|
String |
formatMessage(String key,
Object... args)
Formats message defined with a given key with specified arguments.
|
Object |
getResource(String key)
Returns a resource associated with given key.
|
Set<String> |
getResourceKeys()
Returns the keys of all registered resources.
|
String |
getString(String key)
Gets a string specified in resource bundle with a given key.
|
void |
loadCallbackBundles(DMXExtensionCallback callback)
Loads resource bundles registered by callback.
|
void |
loadResourceBundle(String name,
ClassLoader classLoader)
Loads resource bundle with supplied name for the current locale.
|
protected void |
postLoadBundle(String name,
ResourceBundle bundle,
ClassLoader classLoader)
Invoked after the bundle has been loaded.
|
void |
reloadBundles()
Reload all loaded bundles on locale change.
|
void |
setCurrentLocale(Locale locale)
Set current locale for handler.
|
void |
unloadBundle(String name)
Unloads bundle with specified name from list of loaded bundles.
|
public void setCurrentLocale(Locale locale)
DMXResourceHandler
setCurrentLocale
in interface DMXResourceHandler
locale
- locale to setpublic String getString(String key)
DMXResourceHandler
getString
in interface DMXResourceHandler
key
- string keypublic Object getResource(String key)
key
- resource keypublic String formatMessage(String key, Object... args)
DMXResourceHandler
Formats message defined with a given key with specified arguments. Message format should conform to standard
Java format pattern (see MessageFormat
for more information).
formatMessage
in interface DMXResourceHandler
key
- key defined for the messageargs
- format argumentspublic void loadResourceBundle(String name, ClassLoader classLoader)
Loads resource bundle with supplied name for the current locale. Contents of the bundle will be made available to callers. If this method is called multiple times, all resources will be added to local cache.
name
- resource bundle nameclassLoader
- class loader to useprotected void postLoadBundle(String name, ResourceBundle bundle, ClassLoader classLoader)
name
- resource bundle namebundle
- loaded bundleclassLoader
- classloader for the bundlepublic Set<String> getResourceKeys()
public void unloadBundle(String name)
name
- bundle namepublic void reloadBundles()
public void loadCallbackBundles(DMXExtensionCallback callback)
callback
- extension callbackCopyright © 2012-2014 Vektor Software. All Rights Reserved.