public class MessageSourceResourceBundle
extends java.util.ResourceBundle
MessageSource
as a ResourceBundle
.
Used for example to expose a Spring MessageSource to JSTL web views.MessageSource
,
ResourceBundle
,
JstlUtils.exposeLocalizationContext(HttpServletRequest, org.springframework.context.MessageSource)
Modifier and Type | Field and Description |
---|---|
private java.util.Locale |
locale |
private MessageSource |
messageSource |
Constructor and Description |
---|
MessageSourceResourceBundle(MessageSource source,
java.util.Locale locale)
Create a new MessageSourceResourceBundle for the given MessageSource and Locale.
|
MessageSourceResourceBundle(MessageSource source,
java.util.Locale locale,
java.util.ResourceBundle parent)
Create a new MessageSourceResourceBundle for the given MessageSource and Locale.
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(java.lang.String key)
This implementation checks whether the target MessageSource can resolve
a message for the given key, translating
NoSuchMessageException
accordingly. |
java.util.Enumeration<java.lang.String> |
getKeys()
This implementation throws
UnsupportedOperationException ,
as a MessageSource does not allow for enumerating the defined message codes. |
java.util.Locale |
getLocale()
This implementation exposes the specified Locale for introspection
through the standard
ResourceBundle.getLocale() method. |
protected java.lang.Object |
handleGetObject(java.lang.String key)
This implementation resolves the code in the MessageSource.
|
private final MessageSource messageSource
private final java.util.Locale locale
public MessageSourceResourceBundle(MessageSource source, java.util.Locale locale)
source
- the MessageSource to retrieve messages fromlocale
- the Locale to retrieve messages forpublic MessageSourceResourceBundle(MessageSource source, java.util.Locale locale, java.util.ResourceBundle parent)
source
- the MessageSource to retrieve messages fromlocale
- the Locale to retrieve messages forparent
- the parent ResourceBundle to delegate to if no local message foundprotected java.lang.Object handleGetObject(java.lang.String key)
null
if the message could not be resolved.handleGetObject
in class java.util.ResourceBundle
public boolean containsKey(java.lang.String key)
NoSuchMessageException
accordingly. In contrast to ResourceBundle's default implementation in
JDK 1.6, this does not rely on the capability to enumerate message keys.containsKey
in class java.util.ResourceBundle
public java.util.Enumeration<java.lang.String> getKeys()
UnsupportedOperationException
,
as a MessageSource does not allow for enumerating the defined message codes.getKeys
in class java.util.ResourceBundle
public java.util.Locale getLocale()
ResourceBundle.getLocale()
method.getLocale
in class java.util.ResourceBundle