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
EmptyMessageSourcethat 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.StringgetMessage(java.lang.String code, java.lang.Object[] args, java.lang.String defaultMessage, java.util.Locale locale)Try to resolve the message.java.lang.StringgetMessage(java.lang.String code, java.lang.Object[] args, java.util.Locale locale)Try to resolve the message.MessageSourcegetParentMessageSource()Return the parent of this MessageSource, ornullif none.voidsetParentMessageSource(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:HierarchicalMessageSourceSet the parent that will be used to try to resolve messages that this object can't resolve.- Specified by:
setParentMessageSourcein 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:HierarchicalMessageSourceReturn the parent of this MessageSource, ornullif none.- Specified by:
getParentMessageSourcein 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:MessageSourceTry to resolve the message. Return default message if no message was found.- Specified by:
getMessagein 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), ornullif 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 NoSuchMessageExceptionDescription copied from interface:MessageSourceTry to resolve the message. Treat as an error if the message can't be found.- Specified by:
getMessagein 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), ornullif 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
-
-