org.springframework.context.support
Class StaticMessageSource
java.lang.Object
org.springframework.context.support.AbstractMessageSource
org.springframework.context.support.StaticMessageSource
- All Implemented Interfaces:
- HierarchicalMessageSource, MessageSource
- public class StaticMessageSource
- extends AbstractMessageSource
Simple implementation of MessageSource that allows messages
to be held in a Java object, and added programmatically.
This MessageSource supports internationalization.
Intended for testing rather than use in production systems.
- Author:
- Rod Johnson, Juergen Hoeller
Method Summary |
void |
addMessage(java.lang.String code,
java.util.Locale locale,
java.lang.String message)
Associate the given message with the given code. |
protected java.text.MessageFormat |
resolveCode(java.lang.String code,
java.util.Locale locale)
Subclasses must implement this method to resolve a message.
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
StaticMessageSource
public StaticMessageSource()
resolveCode
protected java.text.MessageFormat resolveCode(java.lang.String code,
java.util.Locale locale)
- Description copied from class:
AbstractMessageSource
- Subclasses must implement this method to resolve a message.
Returns a MessageFormat instance rather than a message String,
to allow for appropriate caching of MessageFormats in subclasses.
- Specified by:
resolveCode
in class AbstractMessageSource
- Parameters:
code
- the code of the message to resolvelocale
- the Locale to resolve the code for
(subclasses are encouraged to support internationalization)
- Returns:
- the MessageFormat for the message, or null if not found
addMessage
public void addMessage(java.lang.String code,
java.util.Locale locale,
java.lang.String message)
- Associate the given message with the given code.
- Parameters:
code
- lookup codelocale
- locale message should be found withinmessage
- message associated with this lookup code
toString
public java.lang.String toString()
Copyright (C) 2003-2004 The Spring Framework Project.