com.interface21.context.support
Class StaticMessageSource

java.lang.Object
  |
  +--com.interface21.context.support.AbstractNestingMessageSource
        |
        +--com.interface21.context.support.StaticMessageSource
All Implemented Interfaces:
MessageSource, NestingMessageSource

public class StaticMessageSource
extends AbstractNestingMessageSource

Simple implementation of NestingMessageSource that allows messages to be held in a Java object, and added programmatically. This class now supports internationalization.

Intended for testing, rather than use production systems.

Author:
Rod Johnson

Constructor Summary
StaticMessageSource()
           
 
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.lang.String resolve(java.lang.String code, java.util.Locale locale)
          Subclasses must implement this method to resolve a message
 
Methods inherited from class com.interface21.context.support.AbstractNestingMessageSource
escape, getDefaultLocale, getMessage, getMessage, getMessage, localeKey, messageKey, messageKey, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StaticMessageSource

public StaticMessageSource()
Method Detail

resolve

protected java.lang.String resolve(java.lang.String code,
                                   java.util.Locale locale)
Description copied from class: AbstractNestingMessageSource
Subclasses must implement this method to resolve a message
Overrides:
resolve in class AbstractNestingMessageSource
See Also:
AbstractNestingMessageSource.messageKey(Locale, String)

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 code
locale - locale message should be found within
message - message associated with this lookup code


Rod Johnson and Spring contributors 2001-2003.