Class DelegatingMessageSource
- java.lang.Object
-
- com.aspectran.core.support.i18n.message.MessageSourceSupport
-
- com.aspectran.core.support.i18n.message.DelegatingMessageSource
-
- All Implemented Interfaces:
HierarchicalMessageSource
,MessageSource
public class DelegatingMessageSource extends MessageSourceSupport implements HierarchicalMessageSource
EmptyMessageSource
that delegates all calls to the parent MessageSource. If no parent is available, it simply won't resolve any message.Created: 2016. 3. 13.
-
-
Field Summary
-
Fields inherited from class com.aspectran.core.support.i18n.message.MessageSourceSupport
log
-
-
Constructor Summary
Constructors Constructor Description DelegatingMessageSource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getMessage(java.lang.String code, java.lang.Object[] args, java.lang.String defaultMessage, java.util.Locale locale)
Try to resolve the message.java.lang.String
getMessage(java.lang.String code, java.lang.Object[] args, java.util.Locale locale)
Try to resolve the message.MessageSource
getParentMessageSource()
Return the parent of this MessageSource, ornull
if none.void
setParentMessageSource(MessageSource parent)
Set the parent that will be used to try to resolve messages that this object can't resolve.-
Methods inherited from class com.aspectran.core.support.i18n.message.MessageSourceSupport
createMessageFormat, formatMessage, isAlwaysUseMessageFormat, renderDefaultMessage, resolveArguments, setAlwaysUseMessageFormat
-
-
-
-
Method Detail
-
setParentMessageSource
public void setParentMessageSource(MessageSource parent)
Description copied from interface:HierarchicalMessageSource
Set the parent that will be used to try to resolve messages that this object can't resolve.- Specified by:
setParentMessageSource
in interfaceHierarchicalMessageSource
- Parameters:
parent
- the parent MessageSource that will be used to resolve messages that this object can't resolve. May benull
, in which case no further resolution is possible.
-
getParentMessageSource
public MessageSource getParentMessageSource()
Description copied from interface:HierarchicalMessageSource
Return the parent of this MessageSource, ornull
if none.- Specified by:
getParentMessageSource
in interfaceHierarchicalMessageSource
- Returns:
- the parent message source
-
getMessage
public java.lang.String getMessage(java.lang.String code, java.lang.Object[] args, java.lang.String defaultMessage, java.util.Locale locale)
Description copied from interface:MessageSource
Try to resolve the message. Return default message if no message was found.- Specified by:
getMessage
in interfaceMessageSource
- Parameters:
code
- the code to lookup up, such as 'calculator.noRateSet'. Users of this class are encouraged to base message names on the relevant fully qualified class name, thus avoiding conflict and ensuring maximum clarity.args
- array of arguments that will be filled in for params within the message (params look like "{0}", "{1,date}", "{2,time}" within a message), ornull
if none.defaultMessage
- String to return if the lookup failslocale
- the Locale in which to do the lookup- Returns:
- the resolved message if the lookup was successful; otherwise the default message passed as a parameter
- See Also:
MessageFormat
-
getMessage
public java.lang.String getMessage(java.lang.String code, java.lang.Object[] args, java.util.Locale locale) throws NoSuchMessageException
Description copied from interface:MessageSource
Try to resolve the message. Treat as an error if the message can't be found.- Specified by:
getMessage
in interfaceMessageSource
- Parameters:
code
- the code to lookup up, such as 'calculator.noRateSet'args
- Array of arguments that will be filled in for params within the message (params look like "{0}", "{1,date}", "{2,time}" within a message), ornull
if none.locale
- the Locale in which to do the lookup- Returns:
- the resolved message
- Throws:
NoSuchMessageException
- if the message wasn't found- See Also:
MessageFormat
-
-