org.kuali.student.common.messagebuilder.impl
Class AbstractMessageBuilder

java.lang.Object
  extended by org.kuali.student.common.messagebuilder.impl.AbstractMessageBuilder
Direct Known Subclasses:
MessageBuilderImpl

public abstract class AbstractMessageBuilder
extends Object

This AbstractMessageBuilder class builds a summary message from plain strings or Velocity template messages. Summary message is built from analysing the outcome of a boolean expression. If no language is specified then the default language locale is used.


Field Summary
private  String booleanExpression
           
private  String language
           
private  Map<String,Object> messageContextMap
           
private  Map<String,? extends BooleanMessage> messageMap
           
private  VelocityTemplateEngine templateEngine
           
private  MessageTreeBuilder treeNodeMessageBuilder
           
 
Constructor Summary
AbstractMessageBuilder(String language, MessageTreeBuilder treeNodeMessageBuilder)
          Constructor.
 
Method Summary
 BooleanFunctionResult build()
           
 BooleanFunctionResult build(String booleanExpression, Map<String,? extends BooleanMessage> messageMap)
          Builds and evaluates a boolean expression and returns the message and result of the expression.
 BooleanFunctionResult build(String booleanExpression, Map<String,? extends BooleanMessage> messageMap, Map<String,Object> messageContextMap)
          Builds and evaluates a boolean expression and returns the message and result of the expression.
private  BooleanMessage buildMessage(BooleanMessage message)
          Builds a failure/success message using the Velocity template engine.
private  Map<String,BooleanMessage> buildMessageMap()
          Builds message map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

templateEngine

private final VelocityTemplateEngine templateEngine

booleanExpression

private String booleanExpression

messageMap

private Map<String,? extends BooleanMessage> messageMap

messageContextMap

private Map<String,Object> messageContextMap

language

private String language

treeNodeMessageBuilder

private MessageTreeBuilder treeNodeMessageBuilder
Constructor Detail

AbstractMessageBuilder

public AbstractMessageBuilder(String language,
                              MessageTreeBuilder treeNodeMessageBuilder)
Constructor.

Parameters:
language - Language
treeNodeMessageBuilder - AST tree node Message builder
Method Detail

build

public BooleanFunctionResult build(String booleanExpression,
                                   Map<String,? extends BooleanMessage> messageMap)

Builds and evaluates a boolean expression and returns the message and result of the expression. Messages in the messageMap can also contain VTL (Velocity Template Language) but without any VTL keys

Note: Order of boolean operation: ANDs before ORs and operations inside parentheses before anything else.

Example 1: 'A AND B OR C AND D' internally evaluates to '(A AND B) OR (C AND D)'
booleanExpression = "A*B+C*D"
Example 2: '(M1 AND M2) OR M3'
booleanExpression = "(M1*M2)+M3"

Parameters:
booleanExpression - Boolean expression
messageMap - Contains a map of messages (or VTL)
Returns:
Boolean function result

build

public BooleanFunctionResult build(String booleanExpression,
                                   Map<String,? extends BooleanMessage> messageMap,
                                   Map<String,Object> messageContextMap)

Builds and evaluates a boolean expression and returns the message and result of the expression. Messages in the messageMap can also contain VTL (Velocity Template Language). messageContextMap contains Velocity key/value entries referenced in the messageMap.

Note: Order of boolean operation: ANDs before ORs and operations inside parentheses before anything else.

Example 1: 'A AND B OR C AND D' internally evaluates to '(A AND B) OR (C AND D)'
booleanExpression = "A*B+C*D"
Example 2: '(M1 AND M2) OR M3'
booleanExpression = "(M1*M2)+M3"

Parameters:
booleanExpression - Boolean expression
messageMap - Contains a map of messages (or VTL)
messageContextMap - Message contact map for Velocity Template Engine
Returns:
Boolean function result
Throws:
MessageBuilderException - Errors building message

build

public BooleanFunctionResult build()

buildMessageMap

private Map<String,BooleanMessage> buildMessageMap()
Builds message map. Also builds message map using velocity templates.

Returns:
Boolean message map

buildMessage

private BooleanMessage buildMessage(BooleanMessage message)
Builds a failure/success message using the Velocity template engine.

Parameters:
message - Boolean failure/success message
Returns:


Copyright © 2007-2011 The Kuali Foundation. All Rights Reserved.