Package sailpoint.tools
Class Message
java.lang.Object
sailpoint.tools.xml.AbstractXmlObject
sailpoint.tools.Message
- All Implemented Interfaces:
Serializable,sailpoint.tools.Localizable,sailpoint.tools.xml.PersistentXmlObject
public class Message
extends sailpoint.tools.xml.AbstractXmlObject
implements sailpoint.tools.Localizable, Serializable
A class containing all the elements needed to generate localized message text,
including the key of the message and any parameters which should be injected
into the message string.
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionMessage()Default constructorCreates Message instance with given key and arguments.Message(Message.Type type, String key, Object... args) Creates a new instance for the given type, key and set of parameters.Message(Message.Type type, Throwable t) Creates a message for the given exception. -
Method Summary
Modifier and TypeMethodDescriptionbooleanFor comparing messages for equality test to see if the key, type and parameters are equal.static Messageprotected StringgetBundleMessage(String key, Locale locale) Gets message from the Internationalizer.getKey()Gets the message key.Gets message text localized for the default locale and server timezone.getLocalizedMessage(Locale locale, TimeZone timezone) Creates localized text using the given locale and timezone.Maximum size of the resulting message text string.Returns message localized in US english.Gets parameters to insert into the message when it is rendered.getType()Gets the type of message.static MessagebooleanisError()Convenience method to determine if this message is an error.booleanReturns true if the message is plain text and does not match an existing key in one of the message catalogs.booleanisType(Message.Type theType) Compares the given type to the instance's message type.booleanConvenience method to determine if this message is a warning.static MessageLocalizes the given key.static MessageLocalizes the given key with the given paramters.voidSets the message key.voidsetMaxLength(Integer maxLength) Maximum size of the string.voidsetParameters(List<Object> parameters) Sets parameters to insert into the message when it is rendered.voidsetType(Message.Type type) Sets the type of message.toString()Convenient so we can just print them.static MessageConvenience constructors.Methods inherited from class sailpoint.tools.xml.AbstractXmlObject
deepCopy, getOriginalXml, parseXml, parseXml, parseXml, setOriginalXml, toXml, toXml, toXml, writeXml
-
Constructor Details
-
Message
public Message()Default constructor -
Message
Creates Message instance with given key and arguments. Message key can be a valid key from a resource bundle, or plain text. Message type is defaulted toType.Info.- Parameters:
key- ResourceBundle essage key, or a plain text messageargs- message format args
-
Message
Creates a new instance for the given type, key and set of parameters.- Parameters:
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.
-
Message
Creates a message for the given exception.If the throwable instance is an instance or subclass of
sailpoint.tools.GeneralExceptionthe message is set usingAbstractLocalizableException.getMessageInstance(). If the exception is any other type, a generic exception message is used, in the form of 'An unexpected error occurred:' with the text fromexception.getLocalizedMessage()used to populate the exception text parameter.- Parameters:
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.
-
-
Method Details
-
warn
Convenience constructors. -
error
-
info
-
localize
Localizes the given key. This method is ideally suited for use in Beanshell since Beanshell does not support varargs. -
localize
Localizes the given key with the given paramters. This method is ideally suited for use in Beanshell since Beanshell does not support varargs. -
getMessage
Returns message localized in US english. Used for logging messages.- Returns:
- Message localized for USofA.
-
getLocalizedMessage
Gets message text localized for the default locale and server timezone.- Specified by:
getLocalizedMessagein interfacesailpoint.tools.Localizable- Returns:
- message localized for the default locale and timezone.
-
toString
Convenient so we can just print them. -
getLocalizedMessage
Creates localized text using the given locale and timezone.- Specified by:
getLocalizedMessagein interfacesailpoint.tools.Localizable- Parameters:
locale- Locale to use. If null the default locale is used.timezone- TimeZone to use. If null the server timezone is used.- Returns:
- localized message text.
-
getBundleMessage
Gets message from the Internationalizer. This method is overridden in unit tests so that we do no rely on any external resource bundles.- Parameters:
key- The key to look uplocale- Locale to- Returns:
- String message for the given key and locale.
-
setKey
Sets the message key. If the key is not found in a resource bundle, it will be returned when the message is rendered, so the key argument can also be a plain text message.- Parameters:
key- ResourceBundle message key, or a plain text message
-
getKey
Gets the message key. The key can be a valid key from a ResourceBundle, or plain text.- Returns:
- Message key, or a plain text message
-
getType
Gets the type of message.- Returns:
- Message type: Warn, Error, etc.
-
setType
Sets the type of message.- Parameters:
type- Message type: Warn, Error, etc.
-
isType
Compares the given type to the instance's message type.- Parameters:
theType- The type to compare. If null, false is returned.- Returns:
- True if theType matches the instances type.
-
isPlainText
public boolean isPlainText()Returns true if the message is plain text and does not match an existing key in one of the message catalogs.- Returns:
- true if the message does not match a key in the message catalogs.
-
setParameters
Sets parameters to insert into the message when it is rendered. These parameters can be other Message instances, LocalizedDates Dates, Numbers, String or Throwables. Any other object will be converted to a string using the toString() method. Nulls are treated as an empty string.- Parameters:
parameters- Parameters to insert into the message
-
getParameters
Gets parameters to insert into the message when it is rendered. These parameters can be other Message instances, LocalizedDates Dates, Numbers, String or Throwables. Any other object will be converted to a string using the toString() method. Nulls are treated as an empty string.- Returns:
- Parameters to insert into the message
-
getMaxLength
Maximum size of the resulting message text string. If Null message will not be truncated. -
setMaxLength
Maximum size of the string. Resulting message text will be truncated at this length and formatted into MessageKeys.MSG_TRUNCATED. !!Note that that the formatted message can be longer than the maxlength due to the addition of the content of MSG_TRUNCATED. -
isError
public boolean isError()Convenience method to determine if this message is an error.- Returns:
- True if message Type==Error
-
isWarning
public boolean isWarning()Convenience method to determine if this message is a warning.- Returns:
- True if message Type==Warn
-
equals
For comparing messages for equality test to see if the key, type and parameters are equal.
-