public abstract class UserMessage extends Object
formatMessage(Locale)
). As each instance
is able to hold a specific raw string for various locales, the raw string to be used for display is
looked up according to the closest Locale
match.MessageFormat
mechanism to substitute the parameters encoded in the localized raw string.
Syntax limitation rules:
'
) using a second one.{
) using quote characters ('{'
).'{'[0-9]}
) by removing quotes.Throwable
. In this case, the display of the message usually
concatenates the throwable stack trace.MessageFormat
Modifier and Type | Method and Description |
---|---|
static UserMessageString |
createError(String message)
Shortcut for creating a simple error message.
|
static UserMessageString |
createError(String message,
Throwable anException)
Shortcut for creating a simple error message, with the
Throwable specified. |
static UserMessageString |
createFatal(String message)
Shortcut for creating a simple fatal error message.
|
static UserMessageString |
createFatal(String message,
Throwable anException)
Shortcut for creating a simple error message, with the
Throwable specified. |
static UserMessageString |
createInfo(String message)
Shortcut for creating a simple information message.
|
static UserMessageString |
createWarning(String message)
Shortcut for creating a simple warning message.
|
String |
formatMessage(Locale aLocale)
Formats this message for the specified locale.
|
abstract String |
getInternalId()
Returns a specific identifier for logging and technical auditing.
|
Severity |
getSeverity() |
Throwable |
getThrowable()
Returns the
Throwable which is associated to this message, or null
if none exists. |
boolean |
isError()
Returns
true if this message is an error. |
boolean |
isFatal()
Returns
true if this message is a fatal error. |
boolean |
isInfo()
Returns
true if this message is an information message. |
boolean |
isWarning()
Returns
true if this message is a warning. |
void |
setSeverity(Severity severity)
Sets the severity of this message.
|
void |
setSeverity(String aLabel)
Sets the severity using the specified severity label.
|
public static UserMessageString createFatal(String message)
public static UserMessageString createFatal(String message, Throwable anException)
Throwable
specified.public static UserMessageString createError(String message)
public static UserMessageString createError(String message, Throwable anException)
Throwable
specified.public static UserMessageString createInfo(String message)
public static UserMessageString createWarning(String message)
public String formatMessage(Locale aLocale)
public abstract String getInternalId()
null
if this message has no identifier (this
is the case for a UserMessageString
).public boolean isError()
true
if this message is an error.public boolean isFatal()
true
if this message is a fatal error.public boolean isInfo()
true
if this message is an information message.public boolean isWarning()
true
if this message is a warning.public Severity getSeverity()
setSeverity(Severity)
public void setSeverity(Severity severity)
Default severity is Severity.INFO
.
public void setSeverity(String aLabel)
Severity.parseLabel(String)
public Throwable getThrowable()
Throwable
which is associated to this message, or null
if none exists.