org.apache.tapestry.engine
Class ComponentMessages

java.lang.Object
  extended by org.apache.tapestry.engine.ComponentMessages
All Implemented Interfaces:
IMessages

public class ComponentMessages
extends Object
implements IMessages

Implementation of IMessages. This is basically a wrapper around an instance of Properties. This ensures that the properties are, in fact, read-only (which ensures that they don't have to be synchronized).

Since:
2.0.4
Author:
Howard Lewis Ship

Constructor Summary
ComponentMessages(Locale locale, Properties properties)
           
 
Method Summary
 String format(String key, Object argument)
          Convienience method for invoking IMessages.format(String, Object[]).
 String format(String key, Object[] arguments)
          Formats a string, using MessageFormat.format(java.lang.String, java.lang.Object[]).
 String format(String key, Object argument1, Object argument2)
          Convienience method for invoking IMessages.format(String, Object[]).
 String format(String key, Object argument1, Object argument2, Object argument3)
          Convienience method for invoking IMessages.format(String, Object[]).
 String getMessage(String key)
          Searches for a localized string with the given key.
 String getMessage(String key, String defaultValue)
          Searches for a localized string with the given key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentMessages

public ComponentMessages(Locale locale,
                         Properties properties)
Method Detail

getMessage

public String getMessage(String key,
                         String defaultValue)
Description copied from interface: IMessages
Searches for a localized string with the given key. If not found, then the default value (which should already be localized) is returned. Passing a default of null is useful when trying to determine if the strings contains a given key.

Specified by:
getMessage in interface IMessages

getMessage

public String getMessage(String key)
Description copied from interface: IMessages
Searches for a localized string with the given key. If not found, a modified version of the key is returned (all upper-case and surrounded by square brackets).

Specified by:
getMessage in interface IMessages

format

public String format(String key,
                     Object argument1,
                     Object argument2,
                     Object argument3)
Description copied from interface: IMessages
Convienience method for invoking IMessages.format(String, Object[]).

Specified by:
format in interface IMessages

format

public String format(String key,
                     Object argument1,
                     Object argument2)
Description copied from interface: IMessages
Convienience method for invoking IMessages.format(String, Object[]).

Specified by:
format in interface IMessages

format

public String format(String key,
                     Object argument)
Description copied from interface: IMessages
Convienience method for invoking IMessages.format(String, Object[]).

Specified by:
format in interface IMessages

format

public String format(String key,
                     Object[] arguments)
Description copied from interface: IMessages
Formats a string, using MessageFormat.format(java.lang.String, java.lang.Object[]).

In addition, special processing occurs for any of the arguments that inherit from Throwable: such arguments are replaced with the Throwable's message (if non blank), or the Throwable's class name (if the message is blank).

Specified by:
format in interface IMessages
Parameters:
key - the key used to obtain a localized pattern using IMessages.getMessage(String)
arguments - passed to the formatter