Package org.apache.struts2.text
Class DefaultTextProvider
java.lang.Object
org.apache.struts2.text.DefaultTextProvider
- All Implemented Interfaces:
Serializable,TextProvider,Unchainable
DefaultTextProvider gets texts from only the default resource bundles associated with the default bundles.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets a message based on a message key or if no message is found the provided key is returned.Gets a message based on a key, or, if the message is not found, a supplied default value is returned.Gets a message based on a key using the supplied args, as defined inMessageFormat, or the provided key if no message is found.Gets a message based on a key using the supplied obj, as defined inMessageFormat, or, if the message is not found, a supplied default value is returned.Gets a message based on a key using the supplied args, as defined inMessageFormat, or, if the message is not found, a supplied default value is returned.getText(String key, String defaultValue, String[] args, ValueStack stack) Gets a message based on a key using the supplied args, as defined inMessageFormat, or, if the message is not found, a supplied default value is returned.Gets a message based on a key using the supplied args, as defined inMessageFormat, or, if the message is not found, a supplied default value is returned.getText(String key, String defaultValue, List<?> args, ValueStack stack) Gets a message based on a key using the supplied args, as defined inMessageFormat, or, if the message is not found, a supplied default value is returned.Gets a message based on a key using the supplied args, as defined inMessageFormator the provided key if no message is found.getTexts()Get the resource bundle associated with the implementing class (usually an action).Get the named bundle, such as "com/acme/Foo".booleanChecks if a message key exists.voidsetLocalizedTextProvider(LocalizedTextProvider localizedTextProvider)
-
Field Details
-
localizedTextProvider
-
-
Constructor Details
-
DefaultTextProvider
public DefaultTextProvider()
-
-
Method Details
-
setLocalizedTextProvider
-
hasKey
Description copied from interface:TextProviderChecks if a message key exists.- Specified by:
hasKeyin interfaceTextProvider- Parameters:
key- message key to check for- Returns:
- boolean true if key exists, false otherwise.
-
getText
Description copied from interface:TextProviderGets a message based on a message key or if no message is found the provided key is returned.- Specified by:
getTextin interfaceTextProvider- Parameters:
key- the resource bundle key that is to be searched for- Returns:
- the message as found in the resource bundle, or the provided key if none is found.
-
getText
Description copied from interface:TextProviderGets a message based on a key, or, if the message is not found, a supplied default value is returned.- Specified by:
getTextin interfaceTextProvider- Parameters:
key- the resource bundle key that is to be searched fordefaultValue- the default value which will be returned if no message is found- Returns:
- the message as found in the resource bundle, or defaultValue if none is found
-
getText
Description copied from interface:TextProviderGets a message based on a key using the supplied args, as defined inMessageFormator the provided key if no message is found.- Specified by:
getTextin interfaceTextProvider- Parameters:
key- the resource bundle key that is to be searched forargs- a list args to be used in aMessageFormatmessage- Returns:
- the message as found in the resource bundle, or the provided key if none is found.
-
getText
Description copied from interface:TextProviderGets a message based on a key using the supplied args, as defined inMessageFormat, or the provided key if no message is found.- Specified by:
getTextin interfaceTextProvider- Parameters:
key- the resource bundle key that is to be searched forargs- an array args to be used in aMessageFormatmessage- Returns:
- the message as found in the resource bundle, or the provided key if none is found.
-
getText
Description copied from interface:TextProviderGets a message based on a key using the supplied args, as defined inMessageFormat, or, if the message is not found, a supplied default value is returned.- Specified by:
getTextin interfaceTextProvider- Parameters:
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 aMessageFormatmessage- Returns:
- the message as found in the resource bundle, or defaultValue if none is found
-
getText
Description copied from interface:TextProviderGets a message based on a key using the supplied args, as defined inMessageFormat, or, if the message is not found, a supplied default value is returned.- Specified by:
getTextin interfaceTextProvider- Parameters:
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 aMessageFormatmessage- Returns:
- the message as found in the resource bundle, or defaultValue if none is found
-
getText
Description copied from interface:TextProviderGets a message based on a key using the supplied obj, as defined inMessageFormat, or, if the message is not found, a supplied default value is returned.- Specified by:
getTextin interfaceTextProvider- Parameters:
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 aMessageFormatmessage- Returns:
- the message as found in the resource bundle, or defaultValue if none is found
-
getText
Description copied from interface:TextProviderGets a message based on a key using the supplied args, as defined inMessageFormat, 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.- Specified by:
getTextin interfaceTextProvider- Parameters:
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 aMessageFormatmessagestack- the value stack to use for finding the text- Returns:
- the message as found in the resource bundle, or defaultValue if none is found
-
getText
Description copied from interface:TextProviderGets a message based on a key using the supplied args, as defined inMessageFormat, 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.- Specified by:
getTextin interfaceTextProvider- Parameters:
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 aMessageFormatmessagestack- the value stack to use for finding the text- Returns:
- the message as found in the resource bundle, or defaultValue if none is found
-
getTexts
Description copied from interface:TextProviderGet the named bundle, such as "com/acme/Foo".- Specified by:
getTextsin interfaceTextProvider- Parameters:
bundleName- the name of the resource bundle, such as"com/acme/Foo".- Returns:
- the bundle
-
getTexts
Description copied from interface:TextProviderGet the resource bundle associated with the implementing class (usually an action).- Specified by:
getTextsin interfaceTextProvider- Returns:
- the bundle
-