public class Message
extends sailpoint.tools.xml.AbstractXmlObject
implements sailpoint.tools.Localizable, java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
Message.Type
Type or severity of the message.
|
Constructor and Description |
---|
Message()
Default constructor
|
Message(Message.Type type,
java.lang.String key,
java.lang.Object... args)
Creates a new instance for the given type, key and set of parameters.
|
Message(Message.Type type,
java.lang.Throwable t)
Creates a message for the given exception.
|
Message(java.lang.String key,
java.lang.Object... args)
Creates Message instance with given
key and arguments.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object other)
For comparing messages for equality test to see if the key,
type and parameters are equal.
|
static Message |
error(java.lang.String key,
java.lang.Object... args) |
protected java.lang.String |
getBundleMessage(java.lang.String key,
java.util.Locale locale)
Gets message from the Internationalizer.
|
java.lang.String |
getKey()
Gets the message key.
|
java.lang.String |
getLocalizedMessage()
Gets message text localized for the default locale and server timezone.
|
java.lang.String |
getLocalizedMessage(java.util.Locale locale,
java.util.TimeZone timezone)
Creates localized text using the given locale and timezone.
|
java.lang.Integer |
getMaxLength()
Maximum size of the resulting message text string.
|
java.lang.String |
getMessage()
Returns message localized in US english.
|
java.util.List<java.lang.Object> |
getParameters()
Gets parameters to insert into the message when it is rendered.
|
Message.Type |
getType()
Gets the type of message.
|
static Message |
info(java.lang.String key,
java.lang.Object... args) |
boolean |
isError()
Convenience method to determine if this message
is an error.
|
boolean |
isPlainText()
Returns true if the message is plain text and does not match an
existing key in one of the message catalogs.
|
boolean |
isType(Message.Type theType)
Compares the given type to the instance's message type.
|
boolean |
isWarning()
Convenience method to determine if this message
is a warning.
|
static Message |
localize(java.lang.String key)
Localizes the given key.
|
static Message |
localize(java.lang.String key,
java.lang.Object[] arguments)
Localizes the given key with the given paramters.
|
void |
setKey(java.lang.String key)
Sets the message key.
|
void |
setMaxLength(java.lang.Integer maxLength)
Maximum size of the string.
|
void |
setParameters(java.util.List<java.lang.Object> parameters)
Sets parameters to insert into the message when it is rendered.
|
void |
setType(Message.Type type)
Sets the type of message.
|
java.lang.String |
toString()
Convenient so we can just print them.
|
static Message |
warn(java.lang.String key,
java.lang.Object... args)
Convenience constructors.
|
public Message()
public Message(java.lang.String key, java.lang.Object... args)
Type.Info
.key
- ResourceBundle essage key, or a plain text messageargs
- message format argspublic Message(Message.Type type, java.lang.String key, java.lang.Object... args)
type
- Message type: Warn, Error, etc.key
- ResourceBundle message key, or a plain text messageargs
- Any parameters to be inserted into the message.
The list can be made up of any object. If the parameter is another
Message, it will be localized, if not we will call toString()
to get the value.public Message(Message.Type type, java.lang.Throwable t)
If the throwable instance is an instance or subclass of sailpoint.tools.GeneralException
the message is set using AbstractLocalizableException.getMessageInstance()
.
If the exception is any other type, a generic exception message is used, in the form of
'An unexpected error occurred: exception.getLocalizedMessage()
used to populate the exception text parameter.
type
- Message type: Warn, Error, etc. If null, Error is used.t
- Exception instance to to create a message from. Can be null, but
should not be.public static Message warn(java.lang.String key, java.lang.Object... args)
public static Message error(java.lang.String key, java.lang.Object... args)
public static Message info(java.lang.String key, java.lang.Object... args)
public static Message localize(java.lang.String key)
public static Message localize(java.lang.String key, java.lang.Object[] arguments)
public java.lang.String getMessage()
public java.lang.String getLocalizedMessage()
getLocalizedMessage
in interface sailpoint.tools.Localizable
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getLocalizedMessage(java.util.Locale locale, java.util.TimeZone timezone)
getLocalizedMessage
in interface sailpoint.tools.Localizable
locale
- Locale to use. If null the default locale is used.timezone
- TimeZone to use. If null the server timezone is used.protected java.lang.String getBundleMessage(java.lang.String key, java.util.Locale locale)
key
- The key to look uplocale
- Locale topublic void setKey(java.lang.String key)
key
- ResourceBundle message key, or a plain text messagepublic java.lang.String getKey()
public Message.Type getType()
public void setType(Message.Type type)
type
- Message type: Warn, Error, etc.public boolean isType(Message.Type theType)
theType
- The type to compare. If null, false is returned.public boolean isPlainText()
public void setParameters(java.util.List<java.lang.Object> parameters)
parameters
- Parameters to insert into the messagepublic java.util.List<java.lang.Object> getParameters()
public java.lang.Integer getMaxLength()
public void setMaxLength(java.lang.Integer maxLength)
public boolean isError()
public boolean isWarning()
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object