IMC Epclient 5.0.3

at.spardat.enterprise.exc
Class Notification

java.lang.Object
  extended byat.spardat.enterprise.exc.Notification
All Implemented Interfaces:
INotification, java.io.Serializable
Direct Known Subclasses:
NotificationList

public class Notification
extends java.lang.Object
implements INotification, java.io.Serializable

This is a default implementation of INotification, see INotification.

The constructors expect a message in the form of a java.text.MessageFormat compliant string with optional parameters. Besides providing a message text, a code may be set using setCode(). The code may be used to discriminate different notifications. See below for a recommendation on how to structure the code.

The message must be set in the constructor, additional attributes are set using the set- methods that may be chained, see examples below. If the set methods are not called, the constructed Notification defaults to type T_ERROR with reaction R_OK. The default code is zero, the default short message is the empty string.

An instance of this class cannot be thrown since it is not an exception. If you want to use this class for exceptional purposes, use a subclass of BaseException, either AppException or SysException instead. These classes work much the same and effectively are wrapper around this class.

The following example creates a error notification with code 4711 and one supplied parameter:

 new Notification("Limit of {0} exceeded", "123").setCode(4711)
 
Here is a question where the recipient should be forced to answer with YES or NO:
 new Notification("Limit of {0} exceeded. \nDo u want to proceed?", "123")
     .setType (Notification.T_QUESTION)
     .setReaction (Notification.R_YES_NO)
 

Author:
YSD, 21.05.2003 18:30:37
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface at.spardat.enterprise.exc.INotification
R_ABORT, R_ABORT_RETRY_IGNORE, R_CANCEL, R_IGNORE, R_NO, R_OK, R_OK_CANCEL, R_RETRY, R_RETRY_CANCEL, R_YES, R_YES_NO, R_YES_NO_CANCEL, T_ERROR, T_INFORMATION, T_QUESTION, T_WARNING
 
Constructor Summary
Notification(java.lang.String message)
          Constructs and sets the message to the provided value.
Notification(java.lang.String message, java.util.Locale l, java.lang.Object[] params)
          Constructs and sets the message from a format string as defined in java.text.MessageFormat.
Notification(java.lang.String messageFmt, java.lang.Object param1)
          Constructs and sets the message of this from a one parameter java.text.MessageFormat compatible string.
Notification(java.lang.String messageFmt, java.lang.Object param1, java.lang.Object param2)
          Constructs and sets the message of this from a two parameter java.text.MessageFormat compatible string.
 
Method Summary
 int getCode()
          Returns the code set.
 java.lang.String getMessage()
          Returns a fully descriptive text of this notification.
 int getReaction()
          Returns the permissible user reaction to the notification which is one of the constants starting with R_.
 java.lang.String getShortMessage()
          Returns a short text explaining this notification.
 int getType()
          Returns the type of this notification, that is one of the constants with praefix T_.
 Notification setCode(int code)
          Sets the code.
 Notification setMessage(java.lang.String message)
          Constructs and sets the message to the provided value.
 Notification setMessage(java.lang.String message, java.util.Locale l, java.lang.Object[] params)
          Sets the message from a format string as defined in java.text.MessageFormat.
 Notification setMessage(java.lang.String messageFmt, java.lang.Object param1)
          Sets the message of this from a one parameter java.text.MessageFormat compatible string.
 Notification setMessage(java.lang.String messageFmt, java.lang.Object param1, java.lang.Object param2)
          Sets the message of this from a one parameter java.text.MessageFormat compatible string.
 Notification setReaction(int reaction)
          Sets one or a bit-or combination of the reaction constants of INotification.
 Notification setShortMessage(java.lang.String shortMessage)
          Sets the short message.
 Notification setType(int type)
          Sets the type which may be one of the T_-constants.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Notification

public Notification(java.lang.String messageFmt,
                    java.lang.Object param1,
                    java.lang.Object param2)
Constructs and sets the message of this from a two parameter java.text.MessageFormat compatible string.

Parameters:
messageFmt - format string as defined in java.text.MessageFormat.
param1 - first message parameter
param2 - second message parameter

Notification

public Notification(java.lang.String messageFmt,
                    java.lang.Object param1)
Constructs and sets the message of this from a one parameter java.text.MessageFormat compatible string.

Parameters:
messageFmt - format string as defined in java.text.MessageFormat.
param1 - message parameter

Notification

public Notification(java.lang.String message)
Constructs and sets the message to the provided value.

Parameters:
message - message text.

Notification

public Notification(java.lang.String message,
                    java.util.Locale l,
                    java.lang.Object[] params)
Constructs and sets the message from a format string as defined in java.text.MessageFormat. The required parameters must be contained in the params array.

Parameters:
message - format string as defined in java.text.MessageFormat or plain text that is not a MessageFormat, depending on params
l - a java.util.Locale to format locale dependent data types or null if the params do not contain local specifics.
params - the parameters of the message. If params is null, message is not subject to MessageFormat-processing. If params is not null, message must be compliant to java.text.MessageFormat.
Method Detail

setMessage

public Notification setMessage(java.lang.String message,
                               java.util.Locale l,
                               java.lang.Object[] params)
Sets the message from a format string as defined in java.text.MessageFormat. The required parameters must be contained in the params array.

Parameters:
message - format string as defined in java.text.MessageFormat or plain text that is not a MessageFormat, depending on params
l - a java.util.Locale to format locale dependent data types or null if the params do not contain local specifics.
params - the parameters of the message. If params is null, message is not subject to MessageFormat-processing. If params is not null, message must be compliant to java.text.MessageFormat.
Returns:
this

setMessage

public Notification setMessage(java.lang.String messageFmt,
                               java.lang.Object param1,
                               java.lang.Object param2)
Sets the message of this from a one parameter java.text.MessageFormat compatible string.

Parameters:
messageFmt - format string as defined in java.text.MessageFormat.
param1 - message parameter
param2 - message parameter
Returns:
this

setMessage

public Notification setMessage(java.lang.String messageFmt,
                               java.lang.Object param1)
Sets the message of this from a one parameter java.text.MessageFormat compatible string.

Parameters:
messageFmt - format string as defined in java.text.MessageFormat.
param1 - message parameter
Returns:
this

setMessage

public Notification setMessage(java.lang.String message)
Constructs and sets the message to the provided value.

Parameters:
message - text to set
Returns:
this

setCode

public Notification setCode(int code)
Sets the code. The code must be greater than zero.

See Also:
getCode()

getCode

public int getCode()
Returns the code set. The code should be used to discrimitate amongst different kinds of notifications.

Specified by:
getCode in interface INotification

setReaction

public Notification setReaction(int reaction)
Sets one or a bit-or combination of the reaction constants of INotification.

Returns:
this
See Also:
INotification.getReaction()

setShortMessage

public Notification setShortMessage(java.lang.String shortMessage)
Sets the short message.

See Also:
INotification.getShortMessage()

setType

public Notification setType(int type)
Sets the type which may be one of the T_-constants.

Returns:
this
See Also:
INotification.getType()

getType

public int getType()
Description copied from interface: INotification
Returns the type of this notification, that is one of the constants with praefix T_. If no type is set, this defaults to T_ERROR.

Specified by:
getType in interface INotification
See Also:
INotification.getType()

getReaction

public int getReaction()
Description copied from interface: INotification
Returns the permissible user reaction to the notification which is one of the constants starting with R_. You will get a bit or combination of constants. If you did set a constant that combines some others, like R_YES_NO, the bit or combination of R_YES and R_NO is returned.

Specified by:
getReaction in interface INotification
See Also:
INotification.getReaction()

getShortMessage

public java.lang.String getShortMessage()
Description copied from interface: INotification
Returns a short text explaining this notification. This text is optional. If not set, it defaults to a text derived from type. The returned String is never null.

Specified by:
getShortMessage in interface INotification
See Also:
INotification.getShortMessage()

getMessage

public java.lang.String getMessage()
Description copied from interface: INotification
Returns a fully descriptive text of this notification. The returned text is never null.

Specified by:
getMessage in interface INotification
See Also:
INotification.getMessage()

IMC Epclient 5.0.3