|
The Spring Framework | |||||||||
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()
Constructor Summary | |
---|---|
MessageSourceAccessor(MessageSource messageSource)
Create a new MessageSourceAccessor, using LocaleContextHolder's locale as default locale. |
|
MessageSourceAccessor(MessageSource messageSource,
Locale defaultLocale)
Create a new MessageSourceAccessor, using the given default locale. |
Method Summary | |
---|---|
protected Locale |
getDefaultLocale()
Return the default locale to use if no explicit locale has been given. |
String |
getMessage(MessageSourceResolvable resolvable)
Retrieve the given MessageSourceResolvable (e.g. an ObjectError instance) in the default Locale. |
String |
getMessage(MessageSourceResolvable resolvable,
Locale locale)
Retrieve the given MessageSourceResolvable (e.g. an ObjectError instance) in the given Locale. |
String |
getMessage(String code)
Retrieve the message for the given code and the default Locale. |
String |
getMessage(String code,
Locale locale)
Retrieve the message for the given code and the given Locale. |
String |
getMessage(String code,
Object[] args)
Retrieve the message for the given code and the default Locale. |
String |
getMessage(String code,
Object[] args,
Locale locale)
Retrieve the message for the given code and the given Locale. |
String |
getMessage(String code,
Object[] args,
String defaultMessage)
Retrieve the message for the given code and the default Locale. |
String |
getMessage(String code,
Object[] args,
String defaultMessage,
Locale locale)
Retrieve the message for the given code and the given Locale. |
String |
getMessage(String code,
String defaultMessage)
Retrieve the message for the given code and the default Locale. |
String |
getMessage(String code,
String defaultMessage,
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 |
Constructor Detail |
---|
public MessageSourceAccessor(MessageSource messageSource)
messageSource
- the MessageSource to wrapLocaleContextHolder.getLocale()
public MessageSourceAccessor(MessageSource messageSource, Locale defaultLocale)
messageSource
- the MessageSource to wrapdefaultLocale
- the default locale to use for message accessMethod Detail |
---|
protected 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 String getMessage(String code, String defaultMessage)
code
- code of the messagedefaultMessage
- String to return if the lookup fails
public String getMessage(String code, String defaultMessage, Locale locale)
code
- code of the messagedefaultMessage
- String to return if the lookup failslocale
- Locale in which to do lookup
public String getMessage(String code, Object[] args, String defaultMessage)
code
- code of the messageargs
- arguments for the message, or null
if nonedefaultMessage
- String to return if the lookup fails
public String getMessage(String code, Object[] args, String defaultMessage, 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 String getMessage(String code) throws NoSuchMessageException
code
- code of the message
NoSuchMessageException
- if not foundpublic String getMessage(String code, Locale locale) throws NoSuchMessageException
code
- code of the messagelocale
- Locale in which to do lookup
NoSuchMessageException
- if not foundpublic String getMessage(String code, Object[] args) throws NoSuchMessageException
code
- code of the messageargs
- arguments for the message, or null
if none
NoSuchMessageException
- if not foundpublic String getMessage(String code, Object[] args, 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 String getMessage(MessageSourceResolvable resolvable) throws NoSuchMessageException
resolvable
- the MessageSourceResolvable
NoSuchMessageException
- if not foundpublic String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException
resolvable
- the MessageSourceResolvablelocale
- Locale in which to do lookup
NoSuchMessageException
- if not found
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |