org.iscreen.mvel
Class MvelMessage

java.lang.Object
  extended by org.iscreen.mvel.MvelMessage
All Implemented Interfaces:
FailureMessage
Direct Known Subclasses:
MvelResourceMessage

public class MvelMessage
extends java.lang.Object
implements FailureMessage

Author:
Shellman, Dan

Field Summary
protected  java.lang.Object contextBean
           
protected  java.util.Map extraMessages
           
protected  int severityLevel
           
protected  java.lang.String template
           
 
Constructor Summary
protected MvelMessage()
          For sub-classes to over-ride how this works.
  MvelMessage(java.lang.String theTemplate, int severity)
          Default constructor.
 
Method Summary
 void addMessage(java.lang.String name, MvelMessage extraMessage)
          Adds an additional message.
 java.lang.Object getContextBean()
          Returns the OGNL root previously set using the setOgnlRoot() method.
 java.util.Map getExtraMessages()
          Retrieves additional messages that are associated with the failure.
 java.lang.String getMessage()
          Generates a message based upon the template of this message and the OGNL root passed in to the setOgnlRoot() method.
 java.lang.String getMessage(java.lang.Object context, java.util.Locale locale)
          Generates a message based upon the template of this message and the OGNL root passed in.
 int getSeverity()
          Retrieves the failure's severity level.
 java.lang.String getTemplate(java.util.Locale locale)
          Returns the template previously set during construction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

template

protected java.lang.String template

contextBean

protected java.lang.Object contextBean

severityLevel

protected int severityLevel

extraMessages

protected java.util.Map extraMessages
Constructor Detail

MvelMessage

public MvelMessage(java.lang.String theTemplate,
                   int severity)
Default constructor.


MvelMessage

protected MvelMessage()
For sub-classes to over-ride how this works.

Method Detail

getMessage

public java.lang.String getMessage()
Generates a message based upon the template of this message and the OGNL root passed in to the setOgnlRoot() method. If the OGNL root object is null, then this method will return the template unchanged.

Returns:
Returns the message, which is constructed based upon the OGNL root and the template.

getExtraMessages

public java.util.Map getExtraMessages()
Description copied from interface: FailureMessage
Retrieves additional messages that are associated with the failure. These additional messages are based upon a name and can be found in the config as sub-elements to the 'failure' element.

Specified by:
getExtraMessages in interface FailureMessage
Returns:
Returns a map of message names to messages. The messages are, themselves, FailureMessage objects.

addMessage

public void addMessage(java.lang.String name,
                       MvelMessage extraMessage)
Adds an additional message.

Parameters:
name - The name of the message.
extraMessage - The extra message.

getMessage

public java.lang.String getMessage(java.lang.Object context,
                                   java.util.Locale locale)
Generates a message based upon the template of this message and the OGNL root passed in. If the OGNL root is null, then the OGNL root passed in to the setOgnlRoot() method is used. If that's null, then the template is returned unchanged.

Specified by:
getMessage in interface FailureMessage
Parameters:
context - The OGNL root to use for generating the message.
locale - The locale use for localizing the message.
Returns:
Returns the message, which is constructed based upon the OGNL root passed in and the template.

getSeverity

public int getSeverity()
Description copied from interface: FailureMessage
Retrieves the failure's severity level. The higher the severity level (numerically), the "worse" the failure. See the constants defined in this interface for "standard" severity levels.

Specified by:
getSeverity in interface FailureMessage
Returns:
Returns the failure's severity level.

getContextBean

public java.lang.Object getContextBean()
Returns the OGNL root previously set using the setOgnlRoot() method.

Returns:
Returns the OGNL root for this message.

getTemplate

public java.lang.String getTemplate(java.util.Locale locale)
Returns the template previously set during construction.

Parameters:
locale - The locale to use.
Returns:
Returns the template.