Available from ApplicationObjectSupport, but also reusable as a standalone helper to delegate to in application objects.
ApplicationObjectSupport#getMessageSourceAccessor
| Modifier and Type | Field and Description |
|---|---|
| private final Locale | |
| private final MessageSource |
| Access | Constructor and Description |
|---|---|
| public | MessageSourceAccessor(MessageSource
the MessageSource to wrap messageSource)Create a new MessageSourceAccessor, using LocaleContextHolder's locale as default locale. |
| public | MessageSourceAccessor(MessageSource
the MessageSource to wrap messageSource, Locale the default locale to use for message access defaultLocale)Create a new MessageSourceAccessor, using the given default locale. |
| Modifier and Type | Method and Description |
|---|---|
| protected Locale | |
| public String | Returns: the messagethe code of the message code, String the String to return if the lookup fails defaultMessage)Retrieve the message for the given code and the default Locale. |
| public String | Returns: the messagethe code of the message code, String the String to return if the lookup fails defaultMessage, Locale the Locale in which to do lookup locale)Retrieve the message for the given code and the given Locale. |
| public String | Returns: the messagethe code of the message code, Object[] arguments for the message, or args, String null if nonethe String to return if the lookup fails defaultMessage)Retrieve the message for the given code and the default Locale. |
| public String | Returns: the messagethe code of the message code, Object[] arguments for the message, or args, String null if nonethe String to return if the lookup fails defaultMessage, Locale the Locale in which to do lookup locale)Retrieve the message for the given code and the given Locale. |
| public String | Returns: the messagethe code of the message code)Retrieve the message for the given code and the default Locale. |
| public String | Returns: the messagethe code of the message code, Locale the Locale in which to do lookup locale)Retrieve the message for the given code and the given Locale. |
| public String | Returns: the messagethe code of the message code, Object[] arguments for the message, or args)null if noneRetrieve the message for the given code and the default Locale. |
| public String | Returns: the messagethe code of the message code, Object[] arguments for the message, or args, Locale null if nonethe Locale in which to do lookup locale)Retrieve the message for the given code and the given Locale. |
| public String | Returns: the messagethe MessageSourceResolvable resolvable)Retrieve the given MessageSourceResolvable (e.g. an ObjectError instance) in the default Locale. |
| public String | Returns: the messagethe MessageSourceResolvable resolvable, Locale the Locale in which to do lookup locale)Retrieve the given MessageSourceResolvable (e.g. an ObjectError instance) in the given Locale. |
| defaultLocale | back to summary |
|---|---|
| private final Locale defaultLocale
| |
| messageSource | back to summary |
|---|---|
| private final MessageSource messageSource | |
| MessageSourceAccessor | back to summary |
|---|---|
| public MessageSourceAccessor(MessageSource messageSource) Create a new MessageSourceAccessor, using LocaleContextHolder's locale as default locale.
| |
| MessageSourceAccessor | back to summary |
|---|---|
| public MessageSourceAccessor(MessageSource messageSource, Locale defaultLocale) Create a new MessageSourceAccessor, using the given default locale.
| |
| getDefaultLocale | back to summary |
|---|---|
| protected Locale getDefaultLocale() Return the default locale to use if no explicit locale has been given. The default implementation returns the default locale passed into the corresponding constructor, or LocaleContextHolder's locale as fallback. Can be overridden in subclasses. | |
| getMessage | back to summary |
|---|---|
| public String getMessage(String code, String defaultMessage) Retrieve the message for the given code and the default Locale. | |
| getMessage | back to summary |
|---|---|
| public String getMessage(String code, String defaultMessage, Locale locale) Retrieve the message for the given code and the given Locale. | |
| getMessage | back to summary |
|---|---|
| public String getMessage(String code, Object[] args, String defaultMessage) Retrieve the message for the given code and the default Locale. | |
| getMessage | back to summary |
|---|---|
| public String getMessage(String code, Object[] args, String defaultMessage, Locale locale) Retrieve the message for the given code and the given Locale. | |
| getMessage | back to summary |
|---|---|
| public String getMessage(String code) throws NoSuchMessageException Retrieve the message for the given code and the default Locale.
| |
| getMessage | back to summary |
|---|---|
| public String getMessage(String code, Locale locale) throws NoSuchMessageException Retrieve the message for the given code and the given Locale.
| |
| getMessage | back to summary |
|---|---|
| public String getMessage(String code, Object[] args) throws NoSuchMessageException Retrieve the message for the given code and the default Locale.
| |
| getMessage | back to summary |
|---|---|
| public String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException Retrieve the message for the given code and the given Locale.
| |
| getMessage | back to summary |
|---|---|
| public String getMessage(MessageSourceResolvable resolvable) throws NoSuchMessageException Retrieve the given MessageSourceResolvable (e.g. an ObjectError instance) in the default Locale.
| |
| getMessage | back to summary |
|---|---|
| public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException Retrieve the given MessageSourceResolvable (e.g. an ObjectError instance) in the given Locale.
| |