public class DefaultTextProvider extends Object implements TextProvider, Serializable, Unchainable
Modifier and Type | Field and Description |
---|---|
protected LocalizedTextProvider |
localizedTextProvider |
Constructor and Description |
---|
DefaultTextProvider() |
Modifier and Type | Method and Description |
---|---|
String |
getText(String key)
Gets a message based on a message key or if no message is found the provided key
is returned.
|
String |
getText(String key,
List<?> args)
Gets a message based on a key using the supplied args, as defined in
MessageFormat or the provided key if no message is found. |
String |
getText(String key,
String defaultValue)
Gets a message based on a key, or, if the message is not found, a supplied
default value is returned.
|
String |
getText(String key,
String[] args)
Gets a message based on a key using the supplied args, as defined in
MessageFormat , or the provided key if no message is found. |
String |
getText(String key,
String defaultValue,
List<?> args)
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,
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 obj)
Gets a message based on a key using the supplied obj, as defined in
MessageFormat , or, if the message is not found, a supplied
default value is returned. |
String |
getText(String key,
String defaultValue,
String[] args)
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[] 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 the implementing class (usually an action).
|
ResourceBundle |
getTexts(String bundleName)
Get the named bundle, such as "com/acme/Foo".
|
boolean |
hasKey(String key)
Checks if a message key exists.
|
void |
setLocalizedTextProvider(LocalizedTextProvider localizedTextProvider) |
protected LocalizedTextProvider localizedTextProvider
public void setLocalizedTextProvider(LocalizedTextProvider localizedTextProvider)
public boolean hasKey(String key)
TextProvider
hasKey
in interface TextProvider
key
- message key to check forpublic String getText(String key)
TextProvider
getText
in interface TextProvider
key
- the resource bundle key that is to be searched forpublic String getText(String key, String defaultValue)
TextProvider
getText
in interface TextProvider
key
- the resource bundle key that is to be searched fordefaultValue
- the default value which will be returned if no message is foundpublic String getText(String key, List<?> args)
TextProvider
MessageFormat
or the provided key if no message is found.getText
in interface TextProvider
key
- the resource bundle key that is to be searched forargs
- a list args to be used in a MessageFormat
messagepublic String getText(String key, String[] args)
TextProvider
MessageFormat
, or the provided key if no message is found.getText
in interface TextProvider
key
- the resource bundle key that is to be searched forargs
- an array args to be used in a MessageFormat
messagepublic String getText(String key, String defaultValue, List<?> args)
TextProvider
MessageFormat
, or, if the message is not found, a supplied
default value is returned.getText
in interface TextProvider
key
- 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
messagepublic String getText(String key, String defaultValue, String[] args)
TextProvider
MessageFormat
, or, if the message is not found, a supplied
default value is returned.getText
in interface TextProvider
key
- 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
messagepublic String getText(String key, String defaultValue, String obj)
TextProvider
MessageFormat
, or, if the message is not found, a supplied
default value is returned.getText
in interface TextProvider
key
- the resource bundle key that is to be searched fordefaultValue
- the default value which will be returned if no message is foundobj
- obj to be used in a MessageFormat
messagepublic String getText(String key, String defaultValue, List<?> args, ValueStack stack)
TextProvider
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 TextProvider
key
- 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)
TextProvider
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 TextProvider
key
- 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 bundleName)
TextProvider
getTexts
in interface TextProvider
bundleName
- the name of the resource bundle, such as "com/acme/Foo"
.public ResourceBundle getTexts()
TextProvider
getTexts
in interface TextProvider
Copyright © 2000–2020 Apache Software Foundation. All rights reserved.