com.mockrunner.struts
Class MapMessageResources

java.lang.Object
  extended by org.apache.struts.util.MessageResources
      extended by com.mockrunner.struts.MapMessageResources
All Implemented Interfaces:
java.io.Serializable

public class MapMessageResources
extends org.apache.struts.util.MessageResources

This implementation of MessageResources takes the messages from a Map and can be used for testing purposes. The Map can also be filled with the contents of a property file. Note: This implementation ignores the specified Locale.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.struts.util.MessageResources
config, defaultFactory, defaultLocale, factory, formats, returnNull
 
Constructor Summary
MapMessageResources()
          Creates an empty resources object
MapMessageResources(java.util.Map messages)
          Creates a resources object based on the specified map.
MapMessageResources(java.util.Map messages, org.apache.struts.util.MessageResourcesFactory factory, java.lang.String config)
          Creates a resources object based on the specified map.
MapMessageResources(java.util.Map messages, org.apache.struts.util.MessageResourcesFactory factory, java.lang.String config, boolean returnNull)
          Creates a resources object based on the specified map.
 
Method Summary
 void clear()
          Clears all messages.
 java.lang.String getMessage(java.util.Locale locale, java.lang.String key)
          Returns the message for the specified key.
 void putMessage(java.lang.String key, java.lang.String value)
          Adds a message for the specified key.
 void putMessages(java.io.File propertyFile)
          Loads a property file and adds all messages from the file.
 void putMessages(java.util.Map messages)
          Adds all messages in the specified map.
 void putMessages(java.lang.String propertyFileName)
          Loads a property file and adds all messages from the file.
 
Methods inherited from class org.apache.struts.util.MessageResources
escape, getConfig, getFactory, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessageResources, getReturnNull, isEscape, isPresent, isPresent, localeKey, log, log, messageKey, messageKey, setEscape, setReturnNull
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapMessageResources

public MapMessageResources()
Creates an empty resources object


MapMessageResources

public MapMessageResources(java.util.Map messages)
Creates a resources object based on the specified map.

Parameters:
messages - the map of messages

MapMessageResources

public MapMessageResources(java.util.Map messages,
                           org.apache.struts.util.MessageResourcesFactory factory,
                           java.lang.String config)
Creates a resources object based on the specified map.

Parameters:
messages - the map of messages
factory - the MessageResourcesFactory that created us
config - the configuration parameter

MapMessageResources

public MapMessageResources(java.util.Map messages,
                           org.apache.struts.util.MessageResourcesFactory factory,
                           java.lang.String config,
                           boolean returnNull)
Creates a resources object based on the specified map.

Parameters:
messages - the map of messages
factory - the MessageResourcesFactory that created us
config - the configuration parameter
returnNull - the returnNull property
Method Detail

getMessage

public java.lang.String getMessage(java.util.Locale locale,
                                   java.lang.String key)
Returns the message for the specified key. The locale is ignored.

Specified by:
getMessage in class org.apache.struts.util.MessageResources
Parameters:
locale - the locale (ignored)
key - the message key
Returns:
the message

putMessage

public void putMessage(java.lang.String key,
                       java.lang.String value)
Adds a message for the specified key.

Parameters:
key - the message key
value - the message

putMessages

public void putMessages(java.util.Map messages)
Adds all messages in the specified map.

Parameters:
messages - the message map

putMessages

public void putMessages(java.lang.String propertyFileName)
Loads a property file and adds all messages from the file.

Parameters:
propertyFileName - the file name

putMessages

public void putMessages(java.io.File propertyFile)
Loads a property file and adds all messages from the file.

Parameters:
propertyFile - the file

clear

public void clear()
Clears all messages.