|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.resources.Messages
public class Messages
Wrapper around any Resources
object that performs message
string lookups from the Resources
instance, and parameter
replacement via java.text.MessageFormat
. For convenience,
the same functionality is also available via static methods that accept
a Resources
parameter.
Calls to getMessage()
variants without a Locale
argument are presumed to be requesting a message string in the default
Locale
for this JVM.
When a getString()
call to the underlying Resources
instance fails or returns null, a suitable error message String will be
returned.
Constructor Summary | |
---|---|
Messages(Resources resources)
Construct a Messages instance that wraps the specified
Resources instance. |
Method Summary | |
---|---|
String |
getMessage(Locale locale,
String key)
Return a text message for the specified key, for the specified Locale . |
String |
getMessage(Locale locale,
String key,
Object arg0)
Return a text message for the specified key, for the specified Locale , with parametric replacement. |
String |
getMessage(Locale locale,
String key,
Object[] args)
Return a text message for the specified key, for the specified Locale , with parametric replacement. |
static String |
getMessage(Resources resources,
Locale locale,
String key)
Return a text message for the specified key, for the specified Locale . |
static String |
getMessage(Resources resources,
Locale locale,
String key,
Object arg0)
Return a text message for the specified key, for the specified Locale , with parametric replacement. |
static String |
getMessage(Resources resources,
Locale locale,
String key,
Object[] args)
Return a text message for the specified key, for the specified Locale , with parametric replacement. |
static String |
getMessage(Resources resources,
String key)
Return a text message for the specified key, for the default Locale . |
static String |
getMessage(Resources resources,
String key,
Object arg0)
Return a text message for the specified key, for the default Locale , with parametric replacement. |
static String |
getMessage(Resources resources,
String key,
Object[] args)
Return a text message for the specified key, for the default Locale , with parametric replacement. |
String |
getMessage(String key)
Return a text message for the specified key, for the default Locale . |
String |
getMessage(String key,
Object arg0)
Return a text message for the specified key, for the default Locale , with parametric replacement. |
String |
getMessage(String key,
Object[] args)
Return a text message for the specified key, for the default Locale , with parametric replacement. |
static Messages |
getMessages(String name)
Convenience factory method to create a Messages instance
that wraps a Resources instance that contains message resources
for the specified properties file. |
Resources |
getResources()
Return the Resources instance that we are wrapping. |
static void |
setFactory(ResourcesFactory factory)
Set the ResourcesFactory that
will be used by the getMessages() method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Messages(Resources resources)
Construct a Messages
instance that wraps the specified
Resources
instance.
resources
- The Resources
instance from which
message strings are to be retrievedMethod Detail |
---|
public Resources getResources()
Return the Resources
instance that we are wrapping.
public String getMessage(String key)
Return a text message for the specified key, for the default
Locale
.
key
- Message key to retrieve
public String getMessage(Locale locale, String key)
Return a text message for the specified key, for the specified
Locale
.
locale
- Locale
for which to retrieve the messagekey
- Message key to retrieve
public String getMessage(String key, Object[] args)
Return a text message for the specified key, for the default
Locale
, with parametric replacement.
key
- Message key to retrieveargs
- Array of replacement values
public String getMessage(Locale locale, String key, Object[] args)
Return a text message for the specified key, for the specified
Locale
, with parametric replacement.
locale
- Locale
for which to retrieve the messagekey
- Message key to retrieveargs
- Array of replacement values
public String getMessage(String key, Object arg0)
Return a text message for the specified key, for the default
Locale
, with parametric replacement.
key
- Message key to retrievearg0
- Individual parameter replacement value
public String getMessage(Locale locale, String key, Object arg0)
Return a text message for the specified key, for the specified
Locale
, with parametric replacement.
locale
- Locale
for which to retrieve the messagekey
- Message key to retrievearg0
- Individual parameter replacement value
public static void setFactory(ResourcesFactory factory)
Set the ResourcesFactory
that
will be used by the getMessages()
method.
factory
- ResourcesFactory instance to set.public static String getMessage(Resources resources, String key)
Return a text message for the specified key, for the default
Locale
.
resources
- Resources
instance to retrieve the message fromkey
- Message key to retrieve
public static String getMessage(Resources resources, Locale locale, String key)
Return a text message for the specified key, for the specified
Locale
.
resources
- Resources
instance to retrieve the message fromlocale
- Locale
for which to retrieve the messagekey
- Message key to retrieve
public static String getMessage(Resources resources, String key, Object[] args)
Return a text message for the specified key, for the default
Locale
, with parametric replacement.
resources
- Resources
instance to retrieve the message fromkey
- Message key to retrieveargs
- Array of replacement values
public static String getMessage(Resources resources, Locale locale, String key, Object[] args)
Return a text message for the specified key, for the specified
Locale
, with parametric replacement.
resources
- Resources
instance to retrieve the message fromlocale
- Locale
for which to retrieve the messagekey
- Message key to retrieveargs
- Array of replacement values
public static String getMessage(Resources resources, String key, Object arg0)
Return a text message for the specified key, for the default
Locale
, with parametric replacement.
resources
- Resources
instance to retrieve the message fromkey
- Message key to retrievearg0
- Individual parameter replacement value
public static String getMessage(Resources resources, Locale locale, String key, Object arg0)
Return a text message for the specified key, for the specified
Locale
, with parametric replacement.
resources
- Resources
instance to retrieve the message fromlocale
- Locale
for which to retrieve the messagekey
- Message key to retrievearg0
- Individual parameter replacement value
public static Messages getMessages(String name)
Convenience factory method to create a Messages
instance
that wraps a Resources
instance that contains message resources
for the specified properties file. It is expected that the resources
for each package will be in properties files that are nested in the
package directory, with names like LocalStrings.properties
for the default messages, and names like
LocalStrings_en_US.properties
for messages localized to
a particular Locale
.
name
- Package + file name of the properties file for which
local message resources are desired (ie. org.apache.commons.resources.LocalStrings).
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |