Package com.onwbp.base.text
Class UserMessage
java.lang.Object
com.onwbp.base.text.UserMessage
- Direct Known Subclasses:
 UserMessageLocalized,UserMessageRef,UserMessageString
Common abstract class for holding a text message. This text can be defined in several languages.
 A message instance has the following features:
 
- It is displayed according to a given locale (see method 
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 closestLocalematch. - A message instance may hold parameters. If this is the case, the display uses a limited
 
MessageFormatmechanism to substitute the parameters encoded in the localized raw string. Syntax limitation rules:- Format type and style are not managed.
 - Escapes single quote (
') using a second one. - Escapes entering curly brackets (
{) using quote characters ('{'). - Reverses escape for (
'{'[0-9]}) by removing quotes. 
 - A message instance may hold a 
Throwable. In this case, the display of the message usually concatenates the throwable stack trace. - A message instance may also hold a severity. The severity is usually used to categorize the message in the context of a validation.
 
- See Also:
 
- 
Method Summary
Modifier and TypeMethodDescriptionstatic UserMessageStringcreateError(String message) Shortcut for creating a simple error message.static UserMessageStringcreateError(String message, Throwable anException) Shortcut for creating a simple error message, with theThrowablespecified.static UserMessageStringcreateFatal(String message) Shortcut for creating a simple fatal error message.static UserMessageStringcreateFatal(String message, Throwable anException) Shortcut for creating a simple error message, with theThrowablespecified.static UserMessageStringcreateInfo(String message) Shortcut for creating a simple information message.static UserMessageStringcreateWarning(String message) Shortcut for creating a simple warning message.formatMessage(Locale aLocale) Formats this message for the specified locale.abstract StringReturns a specific identifier for logging and technical auditing.Returns theThrowablewhich is associated to this message, ornullif none exists.booleanisError()Returnstrueif this message is an error.booleanisFatal()Returnstrueif this message is a fatal error.booleanisInfo()Returnstrueif this message is an information message.booleanReturnstrueif this message is a warning.voidsetSeverity(Severity severity) Sets the severity of this message.voidsetSeverity(String aLabel) Sets the severity using the specified severity label. 
- 
Method Details
- 
createFatal
Shortcut for creating a simple fatal error message. - 
createFatal
Shortcut for creating a simple error message, with theThrowablespecified. - 
createError
Shortcut for creating a simple error message. - 
createError
Shortcut for creating a simple error message, with theThrowablespecified. - 
createInfo
Shortcut for creating a simple information message. - 
createWarning
Shortcut for creating a simple warning message. - 
formatMessage
Formats this message for the specified locale. - 
getInternalId
Returns a specific identifier for logging and technical auditing. Returnsnullif this message has no identifier (this is the case for aUserMessageString). - 
isError
public boolean isError()Returnstrueif this message is an error. - 
isFatal
public boolean isFatal()Returnstrueif this message is a fatal error. - 
isInfo
public boolean isInfo()Returnstrueif this message is an information message. - 
isWarning
public boolean isWarning()Returnstrueif this message is a warning. - 
getSeverity
- See Also:
 
 - 
setSeverity
Sets the severity of this message.Default severity is
Severity.INFO. - 
setSeverity
Sets the severity using the specified severity label.- See Also:
 
 - 
getThrowable
Returns theThrowablewhich is associated to this message, ornullif none exists. 
 -