Class AbstractMessages
- java.lang.Object
-
- org.apache.tapestry5.commons.util.AbstractMessages
-
- All Implemented Interfaces:
Messages
- Direct Known Subclasses:
MapMessages,MessagesImpl
public abstract class AbstractMessages extends java.lang.Object implements Messages
Abstract implementation ofMessagesthat doesn't know where values come from (that information is supplied in a subclass, via thevalueForKey(String)method).
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractMessages(java.util.Locale locale)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancontains(java.lang.String key)Returns true if the bundle contains the named key.java.lang.Stringformat(java.lang.String key, java.lang.Object... args)Convenience for accessing a formatter and formatting a localized message with arguments.java.lang.Stringget(java.lang.String key)Returns the localized message for the given key.MessageFormattergetFormatter(java.lang.String key)Returns a formatter for the message, which can be used to substitute arguments (as perFormatter).protected abstract java.lang.StringvalueForKey(java.lang.String key)Invoked to provide the value for a particular key.
-
-
-
Constructor Detail
-
AbstractMessages
protected AbstractMessages(java.util.Locale locale)
-
-
Method Detail
-
valueForKey
protected abstract java.lang.String valueForKey(java.lang.String key)
Invoked to provide the value for a particular key. This may be invoked multiple times even for the same key. The implementation should ignore the case of the key.- Parameters:
key- the key to obtain a value for (case insensitive)- Returns:
- the value for the key, or null if this instance can not provide the value
-
contains
public boolean contains(java.lang.String key)
Description copied from interface:MessagesReturns true if the bundle contains the named key.
-
get
public java.lang.String get(java.lang.String key)
Description copied from interface:MessagesReturns the localized message for the given key. If catalog does not contain such a key, then a modified version of the key is returned (converted to upper case and enclosed in brackets).
-
getFormatter
public MessageFormatter getFormatter(java.lang.String key)
Description copied from interface:MessagesReturns a formatter for the message, which can be used to substitute arguments (as perFormatter).- Specified by:
getFormatterin interfaceMessages- Returns:
- formattable object
-
-