Save This Page
Home » spring-framework-2.5.5-with-dependencies » org.springframework » context » support » [javadoc | source]
org.springframework.context.support
abstract public class: MessageSourceSupport [javadoc | source]
java.lang.Object
   org.springframework.context.support.MessageSourceSupport

Direct Known Subclasses:
    StaticMessageSource, ReloadableResourceBundleMessageSource, DelegatingMessageSource, ResourceBundleMessageSource, AbstractMessageSource

Base class for message source implementations, providing support infrastructure such as java.text.MessageFormat handling but not implementing concrete methods defined in the org.springframework.context.MessageSource .

AbstractMessageSource derives from this class, providing concrete getMessage implementations that delegate to a central template method for message code resolution.

Field Summary
protected final  Log logger    Logger available to subclasses 
Method from org.springframework.context.support.MessageSourceSupport Summary:
createMessageFormat,   formatMessage,   isAlwaysUseMessageFormat,   renderDefaultMessage,   resolveArguments,   setAlwaysUseMessageFormat
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.context.support.MessageSourceSupport Detail:
 protected MessageFormat createMessageFormat(String msg,
    Locale locale) 
    Create a MessageFormat for the given message and Locale.
 protected String formatMessage(String msg,
    Object[] args,
    Locale locale) 
    Format the given message String, using cached MessageFormats. By default invoked for passed-in default messages, to resolve any argument placeholders found in them.
 protected boolean isAlwaysUseMessageFormat() 
    Return whether to always apply the MessageFormat rules, parsing even messages without arguments.
 protected String renderDefaultMessage(String defaultMessage,
    Object[] args,
    Locale locale) 
    Render the given default message String. The default message is passed in as specified by the caller and can be rendered into a fully formatted default message shown to the user.

    The default implementation passes the String to formatMessage, resolving any argument placeholders found in them. Subclasses may override this method to plug in custom processing of default messages.

 protected Object[] resolveArguments(Object[] args,
    Locale locale) 
    Template method for resolving argument objects.

    The default implementation simply returns the given argument array as-is. Can be overridden in subclasses in order to resolve special argument types.

 public  void setAlwaysUseMessageFormat(boolean alwaysUseMessageFormat) 
    Set whether to always apply the MessageFormat rules, parsing even messages without arguments.

    Default is "false": Messages without arguments are by default returned as-is, without parsing them through MessageFormat. Set this to "true" to enforce MessageFormat for all messages, expecting all message texts to be written with MessageFormat escaping.

    For example, MessageFormat expects a single quote to be escaped as "''". If your message texts are all written with such escaping, even when not defining argument placeholders, you need to set this flag to "true". Else, only message texts with actual arguments are supposed to be written with MessageFormat escaping.