|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.context.support.MessageSourceAccessor
public class MessageSourceAccessor
Helper class for easy access to messages from a MessageSource, providing various overloaded getMessage methods.
Available from ApplicationObjectSupport, but also reusable as a standalone helper to delegate to in application objects.
ApplicationObjectSupport.getMessageSourceAccessor()
Field Summary | |
---|---|
private java.util.Locale |
defaultLocale
|
private MessageSource |
messageSource
|
Constructor Summary | |
---|---|
MessageSourceAccessor(MessageSource messageSource)
Create a new MessageSourceAccessor, using LocaleContextHolder's locale as default locale. |
|
MessageSourceAccessor(MessageSource messageSource,
java.util.Locale defaultLocale)
Create a new MessageSourceAccessor, using the given default locale. |
Method Summary | |
---|---|
protected java.util.Locale |
getDefaultLocale()
Return the default locale to use if no explicit locale has been given. |
java.lang.String |
getMessage(MessageSourceResolvable resolvable)
Retrieve the given MessageSourceResolvable (e.g. |
java.lang.String |
getMessage(MessageSourceResolvable resolvable,
java.util.Locale locale)
Retrieve the given MessageSourceResolvable (e.g. |
java.lang.String |
getMessage(java.lang.String code)
Retrieve the message for the given code and the default Locale. |
java.lang.String |
getMessage(java.lang.String code,
java.util.Locale locale)
Retrieve the message for the given code and the given Locale. |
java.lang.String |
getMessage(java.lang.String code,
java.lang.Object[] args)
Retrieve the message for the given code and the default Locale. |
java.lang.String |
getMessage(java.lang.String code,
java.lang.Object[] args,
java.util.Locale locale)
Retrieve the message for the given code and the given Locale. |
java.lang.String |
getMessage(java.lang.String code,
java.lang.Object[] args,
java.lang.String defaultMessage)
Retrieve the message for the given code and the default Locale. |
java.lang.String |
getMessage(java.lang.String code,
java.lang.Object[] args,
java.lang.String defaultMessage,
java.util.Locale locale)
Retrieve the message for the given code and the given Locale. |
java.lang.String |
getMessage(java.lang.String code,
java.lang.String defaultMessage)
Retrieve the message for the given code and the default Locale. |
java.lang.String |
getMessage(java.lang.String code,
java.lang.String defaultMessage,
java.util.Locale locale)
Retrieve the message for the given code and the given Locale. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final MessageSource messageSource
private final java.util.Locale defaultLocale
Constructor Detail |
---|
public MessageSourceAccessor(MessageSource messageSource)
messageSource
- the MessageSource to wrapLocaleContextHolder.getLocale()
public MessageSourceAccessor(MessageSource messageSource, java.util.Locale defaultLocale)
messageSource
- the MessageSource to wrapdefaultLocale
- the default locale to use for message accessMethod Detail |
---|
protected java.util.Locale getDefaultLocale()
The default implementation returns the default locale passed into the corresponding constructor, or LocaleContextHolder's locale as fallback. Can be overridden in subclasses.
MessageSourceAccessor(org.springframework.context.MessageSource, java.util.Locale)
,
LocaleContextHolder.getLocale()
public java.lang.String getMessage(java.lang.String code, java.lang.String defaultMessage)
code
- code of the messagedefaultMessage
- String to return if the lookup fails
public java.lang.String getMessage(java.lang.String code, java.lang.String defaultMessage, java.util.Locale locale)
code
- code of the messagedefaultMessage
- String to return if the lookup failslocale
- Locale in which to do lookup
public java.lang.String getMessage(java.lang.String code, java.lang.Object[] args, java.lang.String defaultMessage)
code
- code of the messageargs
- arguments for the message, or null
if nonedefaultMessage
- String to return if the lookup fails
public java.lang.String getMessage(java.lang.String code, java.lang.Object[] args, java.lang.String defaultMessage, java.util.Locale locale)
code
- code of the messageargs
- arguments for the message, or null
if nonedefaultMessage
- String to return if the lookup failslocale
- Locale in which to do lookup
public java.lang.String getMessage(java.lang.String code) throws NoSuchMessageException
code
- code of the message
NoSuchMessageException
- if not foundpublic java.lang.String getMessage(java.lang.String code, java.util.Locale locale) throws NoSuchMessageException
code
- code of the messagelocale
- Locale in which to do lookup
NoSuchMessageException
- if not foundpublic java.lang.String getMessage(java.lang.String code, java.lang.Object[] args) throws NoSuchMessageException
code
- code of the messageargs
- arguments for the message, or null
if none
NoSuchMessageException
- if not foundpublic java.lang.String getMessage(java.lang.String code, java.lang.Object[] args, java.util.Locale locale) throws NoSuchMessageException
code
- code of the messageargs
- arguments for the message, or null
if nonelocale
- Locale in which to do lookup
NoSuchMessageException
- if not foundpublic java.lang.String getMessage(MessageSourceResolvable resolvable) throws NoSuchMessageException
resolvable
- the MessageSourceResolvable
NoSuchMessageException
- if not foundpublic java.lang.String getMessage(MessageSourceResolvable resolvable, java.util.Locale locale) throws NoSuchMessageException
resolvable
- the MessageSourceResolvablelocale
- Locale in which to do lookup
NoSuchMessageException
- if not found
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |