org.springframework.context.support
Class MessageSourceResourceBundle

java.lang.Object
  extended by java.util.ResourceBundle
      extended by org.springframework.context.support.MessageSourceResourceBundle

public class MessageSourceResourceBundle
extends java.util.ResourceBundle

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:
MessageSource, ResourceBundle, JstlUtils.exposeLocalizationContext(javax.servlet.http.HttpServletRequest, org.springframework.context.MessageSource)

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.ResourceBundle
java.util.ResourceBundle.Control
 
Field Summary
 
Fields inherited from class java.util.ResourceBundle
parent
 
Constructor Summary
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.
 
Method Summary
 java.util.Enumeration getKeys()
          This implementation returns null, 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 code)
          This implementation resolves the code in the MessageSource.
 
Methods inherited from class java.util.ResourceBundle
clearCache, clearCache, containsKey, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getObject, getString, getStringArray, handleKeySet, keySet, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageSourceResourceBundle

public MessageSourceResourceBundle(MessageSource source,
                                   java.util.Locale locale)
Create a new MessageSourceResourceBundle for the given MessageSource and Locale.

Parameters:
source - the MessageSource to retrieve messages from
locale - the Locale to retrieve messages for

MessageSourceResourceBundle

public MessageSourceResourceBundle(MessageSource source,
                                   java.util.Locale locale,
                                   java.util.ResourceBundle parent)
Create a new MessageSourceResourceBundle for the given MessageSource and Locale.

Parameters:
source - the MessageSource to retrieve messages from
locale - the Locale to retrieve messages for
parent - the parent ResourceBundle to delegate to if no local message found
Method Detail

handleGetObject

protected java.lang.Object handleGetObject(java.lang.String code)
This implementation resolves the code in the MessageSource. Returns null if the message could not be resolved.

Specified by:
handleGetObject in class java.util.ResourceBundle

getKeys

public java.util.Enumeration getKeys()
This implementation returns null, as a MessageSource does not allow for enumerating the defined message codes.

Specified by:
getKeys in class java.util.ResourceBundle

getLocale

public java.util.Locale getLocale()
This implementation exposes the specified Locale for introspection through the standard ResourceBundle.getLocale() method.

Overrides:
getLocale in class java.util.ResourceBundle