public class TextProviderSupport extends Object implements ResourceBundleTextProvider
| Modifier and Type | Field and Description |
|---|---|
protected ResourceBundle |
bundle |
protected Class |
clazz |
protected LocaleProvider |
localeProvider |
protected LocalizedTextProvider |
localizedTextProvider |
| Constructor and Description |
|---|
TextProviderSupport(Class clazz,
LocaleProvider provider,
LocalizedTextProvider localizedTextProvider)
Constructor.
|
TextProviderSupport(ResourceBundle bundle,
LocaleProvider provider,
LocalizedTextProvider localizedTextProvider)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getText(String key)
Get a text from the resource bundles associated with this action.
|
String |
getText(String key,
List<?> args)
Get a text from the resource bundles associated with this action.
|
String |
getText(String key,
String defaultValue)
Get a text from the resource bundles associated with this action.
|
String |
getText(String key,
String[] args)
Get a text from the resource bundles associated with this action.
|
String |
getText(String key,
String defaultValue,
List<?> args)
Get a text from the resource bundles associated with this action.
|
String |
getText(String key,
String defaultValue,
List<?> args,
ValueStack stack)
Gets a message based on a key using the supplied args, as defined in
MessageFormat, or, if the message is not found, a supplied
default value is returned. |
String |
getText(String key,
String defaultValue,
String arg)
Get a text from the resource bundles associated with this action.
|
String |
getText(String key,
String defaultValue,
String[] args)
Get a text from the resource bundles associated with this action.
|
String |
getText(String key,
String defaultValue,
String[] args,
ValueStack stack)
Gets a message based on a key using the supplied args, as defined in
MessageFormat, or, if the message is not found, a supplied
default value is returned. |
ResourceBundle |
getTexts()
Get the resource bundle associated with this action.
|
ResourceBundle |
getTexts(String aBundleName)
Get the named bundle.
|
boolean |
hasKey(String key)
Checks if a key is available in the resource bundles associated with this action.
|
void |
setBundle(ResourceBundle bundle)
Set the resource bundle to use.
|
void |
setClazz(Class clazz)
Set the class to use for reading the resource bundle.
|
void |
setLocaleProvider(LocaleProvider localeProvider)
Set the LocaleProvider to use.
|
void |
setLocaleProviderFactory(LocaleProviderFactory localeProviderFactory) |
void |
setLocalizedTextProvider(LocalizedTextProvider localizedTextProvider) |
protected Class clazz
protected LocaleProvider localeProvider
protected ResourceBundle bundle
protected LocalizedTextProvider localizedTextProvider
public TextProviderSupport(Class clazz, LocaleProvider provider, LocalizedTextProvider localizedTextProvider)
clazz - a clazz to use for reading the resource bundle.provider - a locale provider.public TextProviderSupport(ResourceBundle bundle, LocaleProvider provider, LocalizedTextProvider localizedTextProvider)
bundle - the resource bundle.provider - a locale provider.public void setBundle(ResourceBundle bundle)
ResourceBundleTextProvidersetBundle in interface ResourceBundleTextProviderbundle - the resource bundle.public void setClazz(Class clazz)
ResourceBundleTextProvidersetClazz in interface ResourceBundleTextProviderclazz - a clazz to use for reading the resource bundle.public void setLocaleProvider(LocaleProvider localeProvider)
ResourceBundleTextProvidersetLocaleProvider in interface ResourceBundleTextProviderlocaleProvider - a locale provider.public void setLocaleProviderFactory(LocaleProviderFactory localeProviderFactory)
public void setLocalizedTextProvider(LocalizedTextProvider localizedTextProvider)
public boolean hasKey(String key)
hasKey in interface TextProviderkey - message key to check forpublic String getText(String key)
getText in interface TextProviderkey - name of text to be foundpublic String getText(String key, String defaultValue)
getText in interface TextProviderkey - name of text to be founddefaultValue - the default value which will be returned if no text is foundpublic String getText(String key, String defaultValue, String arg)
getText in interface TextProviderkey - name of text to be founddefaultValue - the default value which will be returned if no text is foundarg - obj to be used in a MessageFormat messagepublic String getText(String key, List<?> args)
getText in interface TextProviderkey - name of text to be foundargs - a List of args to be used in a MessageFormat messagepublic String getText(String key, String[] args)
getText in interface TextProviderkey - name of text to be foundargs - an array of args to be used in a MessageFormat messagepublic String getText(String key, String defaultValue, List<?> args)
getText in interface TextProviderkey - name of text to be founddefaultValue - the default value which will be returned if no text is foundargs - a List of args to be used in a MessageFormat messagepublic String getText(String key, String defaultValue, String[] args)
getText in interface TextProviderkey - name of text to be founddefaultValue - the default value which will be returned if no text is foundargs - an array of args to be used in a MessageFormat messagepublic String getText(String key, String defaultValue, List<?> args, ValueStack stack)
MessageFormat, or, if the message is not found, a supplied
default value is returned. Instead of using the value stack in the ActionContext
this version of the getText() method uses the provided value stack.getText in interface TextProviderkey - the resource bundle key that is to be searched fordefaultValue - the default value which will be returned if no message is foundargs - a list args to be used in a MessageFormat messagestack - the value stack to use for finding the textpublic String getText(String key, String defaultValue, String[] args, ValueStack stack)
MessageFormat, or, if the message is not found, a supplied
default value is returned. Instead of using the value stack in the ActionContext
this version of the getText() method uses the provided value stack.getText in interface TextProviderkey - the resource bundle key that is to be searched fordefaultValue - the default value which will be returned if no message is foundargs - an array args to be used in a MessageFormat messagestack - the value stack to use for finding the textpublic ResourceBundle getTexts(String aBundleName)
You can override the getLocale() methodName to change the behaviour of how to choose locale for the bundles that are returned. Typically you would use the TextProvider interface to get the users configured locale, or use your own methodName to allow the user to select the locale and store it in the session (by using the SessionAware interface).
getTexts in interface TextProvideraBundleName - bundle namepublic ResourceBundle getTexts()
getTexts in interface TextProviderCopyright © 2000–2018 Apache Software Foundation. All rights reserved.