org.pm4j.core.pm.api
Class PmMessageUtil

java.lang.Object
  extended by org.pm4j.core.pm.api.PmMessageUtil

public class PmMessageUtil
extends java.lang.Object


Constructor Summary
PmMessageUtil()
           
 
Method Summary
static void clearPmInvalidValues(PmObject pm)
          Clears not yet validated values within the scope of this PM.
static java.util.List<PmMessage> clearPmMessages(PmObject pm)
          Clears the messages within the scope and returns all messages for this PM scope existing before this call.
static PmMessage findMostSevereMessage(PmObject pm)
           
static java.util.List<PmMessage> getPmErrors(PmObject pm)
           
static java.util.List<PmMessage> getPmInfos(PmObject pm)
           
static java.util.List<PmMessage> getPmMessages(PmObject pm)
           
static java.util.List<PmMessage> getPmWarnings(PmObject pm)
           
static PmMessage makeExceptionMsg(PmObject pm, PmMessage.Severity severity, java.lang.Throwable e)
          Generates a standard exception message and propagates it to the PM conversation.
static PmMessage makeMsg(PmObject pm, PmMessage.Severity severity, java.lang.String key, java.lang.Object... resArgs)
          Generates a message and propagates it to the PM conversation.
static PmMessage makeMsgOneMany(PmObject pm, PmMessage.Severity severity, java.lang.String keybase, int number, java.lang.Object... resArgs)
          Generates a message and propagates it to the PM session
static PmMessage makeMsgOneMany(PmObject pm, java.lang.String keybase, int number, java.lang.Object... resArgs)
          Generates an INFO message and propagates it to the PM session
static void makeOptionalInfoMsg(PmObject pm, java.lang.String key, java.lang.Object... msgArgs)
          Provides a success message when a string resource for the given key is defined.
static org.pm4j.core.exception.PmResourceData makeRequiredWarning(PmAttr<?> pm)
          Generates a warning that indicates that a required value is not provided.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PmMessageUtil

public PmMessageUtil()
Method Detail

makeMsg

public static PmMessage makeMsg(PmObject pm,
                                PmMessage.Severity severity,
                                java.lang.String key,
                                java.lang.Object... resArgs)
Generates a message and propagates it to the PM conversation.

Parameters:
severity - Message severity.
key - The message resource key.
resArgs - The arguments for the resource string.
Returns:
The generated message.

makeExceptionMsg

public static PmMessage makeExceptionMsg(PmObject pm,
                                         PmMessage.Severity severity,
                                         java.lang.Throwable e)
Generates a standard exception message and propagates it to the PM conversation.

Parameters:
pm - The exception related PM.
severity - Message severity.
key - The message resource key.
resArgs - The arguments for the resource string.
Returns:
The generated message.

makeMsgOneMany

public static PmMessage makeMsgOneMany(PmObject pm,
                                       java.lang.String keybase,
                                       int number,
                                       java.lang.Object... resArgs)
Generates an INFO message and propagates it to the PM session

Parameters:
keybase - The message resource key
number - depending on the number the postfix 'one' or 'many' is added to keybase
resArgs - The arguments for the resource string.
Returns:
The generated message.

makeMsgOneMany

public static PmMessage makeMsgOneMany(PmObject pm,
                                       PmMessage.Severity severity,
                                       java.lang.String keybase,
                                       int number,
                                       java.lang.Object... resArgs)
Generates a message and propagates it to the PM session

Parameters:
severity - Message severity.
keybase - The message resource key
number - depending on the number the postfix 'one' or 'many' is added to keybase
resArgs - The arguments for the resource string.
Returns:
The generated message.

makeOptionalInfoMsg

public static void makeOptionalInfoMsg(PmObject pm,
                                       java.lang.String key,
                                       java.lang.Object... msgArgs)
Provides a success message when a string resource for the given key is defined.

Parameters:
key - The resource key to be searched for.
msgArgs - Optional message arguments.

makeRequiredWarning

public static org.pm4j.core.exception.PmResourceData makeRequiredWarning(PmAttr<?> pm)
Generates a warning that indicates that a required value is not provided.

For attributes with options the resource #MSGKEY_VALIDATION_MISSING_REQUIRED_SELECTION is used.
For attributes without options the resource #MSGKEY_VALIDATION_MISSING_REQUIRED_VALUE is used.

When a custom resource key with the postfix #RESKEY_POSTFIX_REQUIRED_MSG is provided, that key will be used for message generation.

Returns:
The resource data for the required attribute value warning.

getPmMessages

public static java.util.List<PmMessage> getPmMessages(PmObject pm)

getPmErrors

public static java.util.List<PmMessage> getPmErrors(PmObject pm)
Returns:
Error messages that are related to this presentation model.
In case of no messages an empty collection.

getPmWarnings

public static java.util.List<PmMessage> getPmWarnings(PmObject pm)
Returns:
Warning messages that are related to this presentation model.
In case of no messages an empty collection.

getPmInfos

public static java.util.List<PmMessage> getPmInfos(PmObject pm)
Returns:
Info messages that are related to this presentation model.
In case of no messages an empty collection.

findMostSevereMessage

public static PmMessage findMostSevereMessage(PmObject pm)
Parameters:
pm - The PM to get the most severe message for.
Returns:
The most severe message for the given PM or null if there is no message for the given PM.

clearPmMessages

public static java.util.List<PmMessage> clearPmMessages(PmObject pm)
Clears the messages within the scope and returns all messages for this PM scope existing before this call.

Any invalid attribute values within the PM scope are also cleaned by cleaning the corresponding error messages.

Returns:
All messages that are related to this presentation model.
In case of no messages an empty collection.

clearPmInvalidValues

public static void clearPmInvalidValues(PmObject pm)
Clears not yet validated values within the scope of this PM.