com.sap.tc.cmi.messages

Interface ICMIMessage

All Known Subinterfaces:
ICMIMessage02

public interface ICMIMessage

A text provided by a model and intended to be displayed to an end user. A message specifies how severe it is, whether it is related to an object, as well as its lifetime.

Messages can be retrieved from any model entity that implements ICMIMessageProvider.

For each distinct message requiring display to an end user, one and only one instance of an ICMIMessage should exist. CMI therefore requires, that equality is relevant for ICMIMessage objects. If two messages are equal, message consumers are encouraged to display only one of them. CMI implementations are free to ensure this by overriding equals(Object) and hashCode() or to guarantee unique instances of message objects and rely on the default implementation of equals(Object) and hashCode().

Since:
NW NewYork

Type Classification Type Classification:

This interface is part of the Common Model Interface and is intended to be implemented by applications.


Field Summary
static Object[] NO_PARAMETERS
           
 
Method Summary
 CMIMessageLifetime getLifetime()
          Lifetime of this message as described by CMIMessageLifetime.
 String getMessageKey()
          Returns a key for the (unparameterized) text of message (optional information).
 Object[] getParameters()
           
 CMIMessageSeverity getSeverity()
          Severity of this message as described by CMIMessageSeverity.
 String getText()
          Returns the text part of this message.
 String getText(Locale locale, TimeZone tz)
          Expanded text for this message in the given locale and formatted for the given timezone (optional operation).
 String getTextPattern()
           
 boolean isObjectRelated()
          Indicates whether at least one of the message providers containing this message can relate it to a model object.
 boolean isProcessed()
          Whether or not the message already has been processed (displayed).
 boolean markAsProcessed()
          Marks this message as processed, so that future calls of isProcessed() return true.
 

Field Detail

NO_PARAMETERS

static final Object[] NO_PARAMETERS
Method Detail

getSeverity

CMIMessageSeverity getSeverity()
Severity of this message as described by CMIMessageSeverity.


getLifetime

CMIMessageLifetime getLifetime()
Lifetime of this message as described by CMIMessageLifetime.


isObjectRelated

boolean isObjectRelated()
Indicates whether at least one of the message providers containing this message can relate it to a model object. Note that even for a return value of true, not every message provider must be able to relate the message to a model object. Especially, if the set of isited message managers is not complete, none of them might be able to resolve the model object relationship.

Returns:
true, if message is somehow related to an object.

isProcessed

boolean isProcessed()
Whether or not the message already has been processed (displayed). In scenarios with multiple message consumers, the processed flag helps to avoid the display of message duplicates.


markAsProcessed

boolean markAsProcessed()
Marks this message as processed, so that future calls of isProcessed() return true. If the processed flag has already been set before calling this method, false is returned (indicating no change), true otherwise.

Message consumers typically should use this method and its result to check whether they have to process a message or not:

   ICMIMessage message = ...
   if ( message.markAsProcessed() ) {
     // process it as no one has done so before
   }
 

Returns:
true, if this message has been marked for the first time.

getMessageKey

String getMessageKey()
Returns a key for the (unparameterized) text of message (optional information). If no key can be provided, null should be returned

The intention behind the key is that a key is stable over time while the text is not/has not to be stable. Applications that must check whether they received a specific message must not check the text, but check the text key instead.

Keys might be structured, but the structure is not defined by CMI. Model implementations must document how their text keys are structured.


getText

String getText()
Returns the text part of this message. The text is already expanded, that is if the corresponding message in the backend contained parameters, then these parameters have already been replaced by the concrete values as returned by getVars().


getText

String getText(Locale locale,
               TimeZone tz)
Expanded text for this message in the given locale and formatted for the given timezone (optional operation). If a model type can't provide message texts in a locale/timezone other than the default locale/timezone, it must throw an UnsupportedOperationException.

Throws:
UnsupportedOperationException - if the model type doesn't support localized messages.

getTextPattern

String getTextPattern()

getParameters

Object[] getParameters()
Access Rights

This class can be accessed from:


SC DC Public Part ACH
[sap.com] FRAMEWORK [sap.com] tc/cm/ejb/api api BC-JAS-EJB
[sap.com] FRAMEWORK [sap.com] tc/cmi default BC-WD-JAV-RUN


Copyright 2014 SAP AG Complete Copyright Notice