public class Messages extends java.lang.Object implements MessageConst
Note: unlike MessageFormat's default behavior, all null objects are treated as an empty string rather than "null".
Modifier and Type | Class and Description |
---|---|
static interface |
Messages.Formatter
The formatter used by
get(int, Object[], Locale) to
format the specified object. |
MessageConst.Aide, MessageConst.BundleInfo
NULL_CODE
Modifier | Constructor and Description |
---|---|
protected |
Messages() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
get(int code)
Gets a message based on the specified code without formating arguments.
|
static java.lang.String |
get(int code,
java.lang.Object fmtArg)
Gets a message based on the locale of current user with
ONE format-argument.
|
static java.lang.String |
get(int code,
java.lang.Object[] fmtArgs)
Gets a message based on the locale of current user.
|
static java.lang.String |
get(int code,
java.lang.Object[] fmtArgs,
java.util.Locale locale)
Gets a message based on the specified code.
|
static Messages.Formatter |
getFormatter()
Returns the formatter used by
get(int, Object[], Locale) ,
or null if not set. |
static int |
getType(int code)
Gets the message type of the specified code.
|
static void |
setFormatter(Messages.Formatter fmt)
Sets the formatter used by
get(int, Object[], Locale) . |
public static final java.lang.String get(int code)
Equivalent to get(code, null).
public static final java.lang.String get(int code, java.lang.Object fmtArg)
public static final java.lang.String get(int code, java.lang.Object[] fmtArgs)
Equivalent to get(code, fmtArgs, current_locale). The current_locale argument depends on the implementation.
public static java.lang.String get(int code, java.lang.Object[] fmtArgs, java.util.Locale locale)
If fmtArgs is not null,
MessageFormats.format(java.lang.String, java.lang.Object[], java.util.Locale)
is called to format
the message. However, unlike MessageFormat's default behavior,
all null objects are treated as an empty string rather than "null".
It also recognizes Objects.UNKNOWN
.
code
- the codefmtArgs
- the argument lists to format the messagelocale
- the locale of the message to loadpublic static Messages.Formatter getFormatter()
get(int, Object[], Locale)
,
or null if not set.public static void setFormatter(Messages.Formatter fmt)
get(int, Object[], Locale)
.
Default: null.
public static final int getType(int code)
Copyright © 2005-2011 Potix Corporation. All Rights Reserved.