Class MessageSourceResourceBundle
java.lang.Object
java.util.ResourceBundle
org.springframework.context.support.MessageSourceResourceBundle
Helper class that allows for accessing a Spring
MessageSource
as a ResourceBundle
.
Used for example to expose a Spring MessageSource to JSTL web views.- Since:
- 27.02.2003
- Author:
- Juergen Hoeller
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.ResourceBundle
ResourceBundle.Control
-
Field Summary
Fields inherited from class java.util.ResourceBundle
parent
-
Constructor Summary
ConstructorDescriptionMessageSourceResourceBundle
(MessageSource source, Locale locale) Create a new MessageSourceResourceBundle for the given MessageSource and Locale.MessageSourceResourceBundle
(MessageSource source, Locale locale, ResourceBundle parent) Create a new MessageSourceResourceBundle for the given MessageSource and Locale. -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(String key) This implementation checks whether the target MessageSource can resolve a message for the given key, translatingNoSuchMessageException
accordingly.getKeys()
This implementation throwsUnsupportedOperationException
, as a MessageSource does not allow for enumerating the defined message codes.This implementation exposes the specified Locale for introspection through the standardResourceBundle.getLocale()
method.handleGetObject
(String key) This implementation resolves the code in the MessageSource.Methods inherited from class java.util.ResourceBundle
clearCache, clearCache, getBaseBundleName, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getObject, getString, getStringArray, handleKeySet, keySet, setParent
-
Constructor Details
-
MessageSourceResourceBundle
Create a new MessageSourceResourceBundle for the given MessageSource and Locale.- Parameters:
source
- the MessageSource to retrieve messages fromlocale
- the Locale to retrieve messages for
-
MessageSourceResourceBundle
Create a new MessageSourceResourceBundle for the given MessageSource and Locale.- Parameters:
source
- the MessageSource to retrieve messages fromlocale
- the Locale to retrieve messages forparent
- the parent ResourceBundle to delegate to if no local message found
-
-
Method Details
-
handleGetObject
This implementation resolves the code in the MessageSource. Returnsnull
if the message could not be resolved.- Specified by:
handleGetObject
in classResourceBundle
-
containsKey
This implementation checks whether the target MessageSource can resolve a message for the given key, translatingNoSuchMessageException
accordingly. In contrast to ResourceBundle's default implementation in JDK 1.6, this does not rely on the capability to enumerate message keys.- Overrides:
containsKey
in classResourceBundle
-
getKeys
This implementation throwsUnsupportedOperationException
, as a MessageSource does not allow for enumerating the defined message codes.- Specified by:
getKeys
in classResourceBundle
-
getLocale
This implementation exposes the specified Locale for introspection through the standardResourceBundle.getLocale()
method.- Overrides:
getLocale
in classResourceBundle
-