public class AdapterResourceBundleManager
extends java.lang.Object
The client locale is the locale of an application that is requesting a service of the server. Because of the two locales, WmART will need to know which locale it needs a string for. This class provides two methods to make it easier to access the resources. The method getStringResourceServerLocale() gets a resource in the server's locale, and the method getStringResourceClientLocale() gets a resource in the client's locale.
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
bundleName
The name of resource bundle managed by this AdapterResourceBundleManager.
|
protected java.lang.ClassLoader |
classLoader
The classloader which can find the resource bundle.
|
protected java.util.ResourceBundle |
clientLocaleResources
ResourceBundle containing strings in the client's locale.
|
protected boolean |
initialized
Indicates if the resource bundle has been successfully loaded.
|
protected java.util.WeakHashMap |
resourceBundles
HashMap that will cache all resources in all locales, for each locale requested.
|
protected java.util.Locale |
serverLocale
Server's locale.
|
protected java.util.ResourceBundle |
serverLocaleResources
ResourceBundle containing strings in the server's locale.
|
Constructor and Description |
---|
AdapterResourceBundleManager(java.lang.String bundleName,
java.lang.ClassLoader classLoader)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getBundleName()
Gets the base name of the ResourceBundle set that this manager manages.
|
java.lang.String |
getStringResource(java.lang.String key,
java.util.Locale l)
Returns a string resource localized in the user-specified locale.
|
java.lang.String |
getStringResource(java.lang.String key,
java.lang.Object[] fields,
java.util.Locale l)
Returns a string resource localized in the user-specified locale.
|
static java.lang.String |
getStringResource(java.lang.String key,
java.lang.Object[] fields,
java.util.ResourceBundle bundle)
Helper method to access a String resource from a specified localized
ResourceBundle instance.
|
java.lang.String |
getStringResourceClientLocale(java.lang.String key)
Returns a String resource localized in the client's locale.
|
java.lang.String |
getStringResourceClientLocale(java.lang.String key,
java.lang.Object[] fields)
Returns a String resource localized in the client's locale.
|
java.lang.String |
getStringResourceClientLocaleNoExceptions(java.lang.String key)
Returns a String resource localized in the client's locale.
|
java.lang.String |
getStringResourceClientLocaleNoExceptions(java.lang.String key,
java.lang.Object[] fields)
Returns a String resource localized in the client's locale.
|
java.lang.String |
getStringResourceNoExceptions(java.lang.String key,
java.util.Locale locale)
Returns a String resource localized in the specified locale.
|
java.lang.String |
getStringResourceNoExceptions(java.lang.String key,
java.lang.Object[] fields,
java.util.Locale locale)
Returns a String resource localized in the user-specified locale.
|
static java.lang.String |
getStringResourceNoExceptions(java.lang.String key,
java.lang.Object[] fields,
java.util.ResourceBundle bundle)
Helper method to access a String resource from a specified localized
ResourceBundle instance.
|
java.lang.String |
getStringResourceServerLocale(java.lang.String key)
Returns a String resource localized in the server's locale.
|
java.lang.String |
getStringResourceServerLocale(java.lang.String key,
java.lang.Object[] fields)
Returns a String resource localized in the server's locale.
|
java.lang.String |
getStringResourceServerLocaleNoExceptions(java.lang.String key)
Returns a String resource localized in the server's locale.
|
java.lang.String |
getStringResourceServerLocaleNoExceptions(java.lang.String key,
java.lang.Object[] fields)
Returns a String resource localized in the server's locale.
|
protected java.lang.String bundleName
protected java.lang.ClassLoader classLoader
protected java.util.ResourceBundle clientLocaleResources
protected boolean initialized
protected java.util.WeakHashMap resourceBundles
protected java.util.Locale serverLocale
protected java.util.ResourceBundle serverLocaleResources
public AdapterResourceBundleManager(java.lang.String bundleName, java.lang.ClassLoader classLoader) throws AdapterException
bundleName
- The base java class name for the resource bundle this manager will manager.classLoader
- A ClassLoader instance capable of locating the resource bundle. This is often necessary when a resource bundle is located within an Integration Server package, which has a classloader different from the system class loader. This parameter may be null.AdapterException
- if the specified resource bundle is not found.public java.lang.String getBundleName()
public java.lang.String getStringResource(java.lang.String key, java.util.Locale l)
key
- The ResourceBundle key to the string resource.l
- The Locale the string should be localized to.public java.lang.String getStringResource(java.lang.String key, java.lang.Object[] fields, java.util.Locale l)
key
- The ResourceBundle key to the string resource.fields
- Array of arguments that should be used in generating the string resource.l
- The Locale the string should be localized to.public static java.lang.String getStringResource(java.lang.String key, java.lang.Object[] fields, java.util.ResourceBundle bundle)
key
- the ResourceBundle key to the String resource.fields
- an Array of arguments that should be used when generating the String resource.bundle
- the specific ResourceBundle object from which to get the String resource.MissingResourceException
- if the key specified does not exist in the resource bundlepublic java.lang.String getStringResourceClientLocale(java.lang.String key)
key
- the ResourceBundle key to the String resource.public java.lang.String getStringResourceClientLocale(java.lang.String key, java.lang.Object[] fields)
key
- the ResourceBundle key to the String resource.fields
- an Array of arguments that should be used when generating the String resource.public java.lang.String getStringResourceClientLocaleNoExceptions(java.lang.String key)
key
- the ResourceBundle key to the String resource.public java.lang.String getStringResourceClientLocaleNoExceptions(java.lang.String key, java.lang.Object[] fields)
key
- the ResourceBundle key to the String resource.fields
- an Array of arguments that should be used when generating the String resource.public java.lang.String getStringResourceNoExceptions(java.lang.String key, java.util.Locale locale)
key
- the ResourceBundle key to the String resource.l
- the locale to which the String should be localized.public java.lang.String getStringResourceNoExceptions(java.lang.String key, java.lang.Object[] fields, java.util.Locale locale)
key
- the ResourceBundle key to the String resource.l
- the locale to which the String should be localized.fields
- an Array of arguments that should be used when generating the String resource.public static java.lang.String getStringResourceNoExceptions(java.lang.String key, java.lang.Object[] fields, java.util.ResourceBundle bundle)
key
- the ResourceBundle key to the String resource.fields
- an Array of arguments that should be used when generating the String resource.bundle
- the specific ResourcBundle object to get the String resource frompublic java.lang.String getStringResourceServerLocale(java.lang.String key)
key
- the ResourceBundle key to the String resource.public java.lang.String getStringResourceServerLocale(java.lang.String key, java.lang.Object[] fields)
key
- the ResourceBundle key to the String resource.fields
- an Array of arguments that should be used when generating the String resource.public java.lang.String getStringResourceServerLocaleNoExceptions(java.lang.String key)
key
- the ResourceBundle key to the String resource.public java.lang.String getStringResourceServerLocaleNoExceptions(java.lang.String key, java.lang.Object[] fields)
key
- the ResourceBundle key to the String resource.l
- the locale to which the String should be localized.fields
- an Array of arguments that should be used when generating the String resource.
Copyright © 2003 - 2021 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.