org.apache.hivemind.impl
Class AbstractMessages

java.lang.Object
  extended by org.apache.hivemind.impl.AbstractMessages
All Implemented Interfaces:
Messages
Direct Known Subclasses:
MessageFormatter, ModuleMessages

public abstract class AbstractMessages
extends java.lang.Object
implements Messages

Abstract base class for implementations of Messages. Subclasses must provide getLocale()and findMessage(String) implementations.

Since:
1.1
Author:
Howard M. Lewis Ship

Constructor Summary
AbstractMessages()
           
 
Method Summary
 boolean containsMessage(java.lang.String key)
          Returns true if the given key is associated with a message, false otherwise.
protected abstract  java.lang.String findMessage(java.lang.String key)
          Concrete implementations must implement this method.
 java.lang.String format(java.lang.String key, java.lang.Object arg0)
          Convienience method for invoking Messages.format(String, Object[]).
 java.lang.String format(java.lang.String key, java.lang.Object[] args)
          Formats a string, using MessageFormat.format(java.lang.String, java.lang.Object[]).
 java.lang.String format(java.lang.String key, java.lang.Object arg0, java.lang.Object arg1)
          Convienience method for invoking Messages.format(String, Object[]).
 java.lang.String format(java.lang.String key, java.lang.Object arg0, java.lang.Object arg1, java.lang.Object arg2)
          Convienience method for invoking Messages.format(String, Object[]).
protected abstract  java.util.Locale getLocale()
          Concrete implementations must provide a non-null Locale.
 java.lang.String getMessage(java.lang.String key)
          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

AbstractMessages

public AbstractMessages()
Method Detail

format

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

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

format

public final java.lang.String format(java.lang.String key,
                                     java.lang.Object arg0)
Description copied from interface: Messages
Convienience method for invoking Messages.format(String, Object[]).

Specified by:
format in interface Messages

format

public final java.lang.String format(java.lang.String key,
                                     java.lang.Object arg0,
                                     java.lang.Object arg1)
Description copied from interface: Messages
Convienience method for invoking Messages.format(String, Object[]).

Specified by:
format in interface Messages

format

public final java.lang.String format(java.lang.String key,
                                     java.lang.Object arg0,
                                     java.lang.Object arg1,
                                     java.lang.Object arg2)
Description copied from interface: Messages
Convienience method for invoking Messages.format(String, Object[]).

Specified by:
format in interface Messages

containsMessage

public final boolean containsMessage(java.lang.String key)
Description copied from interface: Messages
Returns true if the given key is associated with a message, false otherwise.

Specified by:
containsMessage in interface Messages
Since:
1.2

getMessage

public final java.lang.String getMessage(java.lang.String key)
Description copied from interface: Messages
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 Messages

getLocale

protected abstract java.util.Locale getLocale()
Concrete implementations must provide a non-null Locale.


findMessage

protected abstract java.lang.String findMessage(java.lang.String key)
Concrete implementations must implement this method.

Note: starting with release 1.2, it is no longer considered an error if the key does not match a known message (i.e., due to containsMessage(String)). Prior to 1.2, some implementations would log an error in that situation.

Parameters:
key -
Returns:
the localized message for the key, or null if no such message exists.


Copyright © 2003-2007 Apache Software Foundation. All Rights Reserved.