Package org.apache.struts2.text
Class CompositeTextProvider
java.lang.Object
org.apache.struts2.text.CompositeTextProvider
- All Implemented Interfaces:
TextProvider
This is a composite
TextProvider
that takes in an array or List
of TextProvider
s, it will
consult each of them in order to get a composite result. To know how each method behaves, please refer to the
javadoc for each methods.- Author:
- tmjee
-
Constructor Summary
ConstructorDescriptionCompositeTextProvider
(List<TextProvider> textProviders) Instantiates aCompositeTextProvider
with some predefinedtextProviders
.CompositeTextProvider
(TextProvider[] textProviders) Instantiates aCompositeTextProvider
with some predefinedtextProviders
. -
Method Summary
Modifier and TypeMethodDescriptionIt will consult eachTextProvider
s and return the first valid message for thiskey
It will consult eachTextProvider
s and return the first valid message for thiskey
before returningdefaultValue
if every else fails.It will consult eachTextProvider
s and return the first valid message for thiskey
.It will consult eachTextProvider
s and return the first valid message for thiskey
, before returningdefaultValue
if every else fails.It will consult eachTextProvider
s and return the first valid message for thiskey
, before returningdefaultValue
.getText
(String key, String defaultValue, String[] args, ValueStack stack) It will consult eachTextProvider
s and return the first valid message for thiskey
, before returningdefaultValue
It will consult eachTextProvider
s and return the first valid message for thiskey
, before returningdefaultValue
getText
(String key, String defaultValue, List<?> args, ValueStack stack) It will consult eachTextProvider
s and return the first valid message for thiskey
, before returningdefaultValue
It will consult eachTextProvider
s and return the first valid message for thiskey
.getTexts()
It will consult eachTextProvider
s and return the first non-nullResourceBundle
.It will consult eachTextProvider
s and return the first non-nullResourceBundle
.boolean
It will consult each individualTextProvider
s and return true if either one of theTextProvider
" has such akey
else false.
-
Constructor Details
-
CompositeTextProvider
Instantiates aCompositeTextProvider
with some predefinedtextProviders
.- Parameters:
textProviders
- list of text providers
-
CompositeTextProvider
Instantiates aCompositeTextProvider
with some predefinedtextProviders
.- Parameters:
textProviders
- array of text providers
-
-
Method Details
-
hasKey
It will consult each individualTextProvider
s and return true if either one of theTextProvider
" has such akey
else false.- Specified by:
hasKey
in interfaceTextProvider
- Parameters:
key
- The key to lookup in resource bundles.- Returns:
- true, if the requested key is found in one of the resource bundles.
- See Also:
-
getText
It will consult eachTextProvider
s and return the first valid message for thiskey
- Specified by:
getText
in interfaceTextProvider
- Parameters:
key
- The key to lookup in resource bundles.- Returns:
- The i18n text for the requested key.
- See Also:
-
getText
It will consult eachTextProvider
s and return the first valid message for thiskey
before returningdefaultValue
if every else fails.- Specified by:
getText
in interfaceTextProvider
- Parameters:
key
- the message keydefaultValue
- the default value- Returns:
- the first valid message for the key or default value
- See Also:
-
getText
It will consult eachTextProvider
s and return the first valid message for thiskey
, before returningdefaultValue
if every else fails.- Specified by:
getText
in interfaceTextProvider
- Parameters:
key
- the message keydefaultValue
- the default valueobj
- object- Returns:
- the first valid message for the key or default value
- See Also:
-
getText
It will consult eachTextProvider
s and return the first valid message for thiskey
.- Specified by:
getText
in interfaceTextProvider
- Parameters:
key
- the message keyargs
- additional arguments- Returns:
- the first valid message for the key
- See Also:
-
getText
It will consult eachTextProvider
s and return the first valid message for thiskey
.- Specified by:
getText
in interfaceTextProvider
- Parameters:
key
- the message keyargs
- additional arguments- Returns:
- the first valid message for the key or default value
- See Also:
-
getText
It will consult eachTextProvider
s and return the first valid message for thiskey
, before returningdefaultValue
- Specified by:
getText
in interfaceTextProvider
- Parameters:
key
- the message keydefaultValue
- the default valueargs
- additional arguments- Returns:
- the first valid message for the key or default value
- See Also:
-
getText
It will consult eachTextProvider
s and return the first valid message for thiskey
, before returningdefaultValue
.- Specified by:
getText
in interfaceTextProvider
- Parameters:
key
- the message keydefaultValue
- the default valueargs
- additional arguments- Returns:
- the first valid message for the key or default value
- See Also:
-
getText
It will consult eachTextProvider
s and return the first valid message for thiskey
, before returningdefaultValue
- Specified by:
getText
in interfaceTextProvider
- Parameters:
key
- the message keydefaultValue
- the default valueargs
- additional argumentsstack
- the value stack- Returns:
- the first valid message for the key or default value
- See Also:
-
getText
It will consult eachTextProvider
s and return the first valid message for thiskey
, before returningdefaultValue
- Specified by:
getText
in interfaceTextProvider
- Parameters:
key
- the message keydefaultValue
- the default valueargs
- additional argumentsstack
- the value stack- Returns:
- the first valid message for the key or default value
- See Also:
-
getTexts
It will consult eachTextProvider
s and return the first non-nullResourceBundle
.- Specified by:
getTexts
in interfaceTextProvider
- Parameters:
bundleName
- the bundle name- Returns:
- the resource bundle found for bundle name
- See Also:
-
getTexts
It will consult eachTextProvider
s and return the first non-nullResourceBundle
.- Specified by:
getTexts
in interfaceTextProvider
- Returns:
- the resource bundle
- See Also:
-