Package org.zkoss.mesg
Class Messages
java.lang.Object
org.zkoss.mesg.Messages
- All Implemented Interfaces:
MessageConst
The message manager.
This class manages how an message is retrieved based on the message code
and the locale.
Note: unlike MessageFormat's default behavior, all null objects are treated as an empty string rather than "null".
- Author:
- tomyeh
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThe formatter used byget(int, Object[], Locale)to format the specified object.Nested classes/interfaces inherited from interface org.zkoss.mesg.MessageConst
MessageConst.Aide, MessageConst.BundleInfo -
Field Summary
Fields inherited from interface org.zkoss.mesg.MessageConst
NULL_CODE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final Stringget(int code) Gets a message based on the specified code without formating arguments.static final StringGets a message based on the locale of current user with ONE format-argument.static final StringGets a message based on the locale of current user.static StringGets a message based on the specified code.static Messages.FormatterReturns the formatter used byget(int, Object[], Locale), or null if not set.static final intgetType(int code) Gets the message type of the specified code.static voidSets the formatter used byget(int, Object[], Locale).
-
Constructor Details
-
Messages
protected Messages()
-
-
Method Details
-
get
Gets a message based on the specified code without formating arguments.Equivalent to get(code, null).
-
get
Gets a message based on the locale of current user with ONE format-argument. -
get
Gets a message based on the locale of current user.Equivalent to get(code, fmtArgs, current_locale). The current_locale argument depends on the implementation.
-
get
Gets a message based on the specified code. If not found, returns an error message to denote it.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.- Parameters:
code- the codefmtArgs- the argument lists to format the messagelocale- the locale of the message to load- Returns:
- the message; never be null
-
getFormatter
Returns the formatter used byget(int, Object[], Locale), or null if not set. -
setFormatter
Sets the formatter used byget(int, Object[], Locale).Default: null.
-
getType
public static final int getType(int code) Gets the message type of the specified code.
-