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

java.lang.Object
  extended by org.kuali.student.common.messagebuilder.impl.AbstractMessageBuilder
      extended by org.kuali.student.common.messagebuilder.impl.MessageBuilderImpl
All Implemented Interfaces:
MessageBuilder

public class MessageBuilderImpl
extends AbstractMessageBuilder
implements MessageBuilder

This MessageBuilder class builds a summary message from plain strings or templates. Summary message is built from analysing the outcome of a boolean expression.


Constructor Summary
MessageBuilderImpl(String language, MessageTreeBuilder treeNodeMessageBuilder)
          Constructor.
 
Method Summary
 BooleanFunctionResult build(String booleanRule, MessageContainer messageContainer)
          Builds and evaluates a boolean expression and returns the message and result of the expression.
 BooleanFunctionResult build(String booleanRule, MessageContainer messageContainer, Map<String,Object> messageContextMap)
          Builds and evaluates a boolean expression and returns the message and result of the expression.
 String buildMessage(String booleanRule, MessageContainer messageContainer)
          Builds a message from a list of messages using a boolean expression.
 
Methods inherited from class org.kuali.student.common.messagebuilder.impl.AbstractMessageBuilder
build, build, build
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageBuilderImpl

public MessageBuilderImpl(String language,
                          MessageTreeBuilder treeNodeMessageBuilder)
Constructor.

Parameters:
language - String Boolean operators' language (English and/or)
treeNodeMessageBuilder - AST tree node Message builder
Method Detail

build

public BooleanFunctionResult build(String booleanRule,
                                   MessageContainer messageContainer)

Builds and evaluates a boolean expression and returns the message and result of the expression.

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"

Specified by:
build in interface MessageBuilder
Parameters:
booleanRule - Boolean expression
messageContainer - Contains a list of messages
Returns:
Boolean function result
Throws:
MessageBuilderException - Errors building message

build

public BooleanFunctionResult build(String booleanRule,
                                   MessageContainer messageContainer,
                                   Map<String,Object> messageContextMap)

Builds and evaluates a boolean expression and returns the message and result of the expression.

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

if messageContainer contains any velocity templates with keys/tokens then messageContextMap must be set.

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"

Specified by:
build in interface MessageBuilder
Parameters:
booleanRule - Boolean expression
messageContainer - Contains a list of messages
messageContextMap - Message context template map
Returns:
Boolean function result
Throws:
MessageBuilderException - Errors building message

buildMessage

public String buildMessage(String booleanRule,
                           MessageContainer messageContainer)
Builds a message from a list of messages using a boolean expression. Example: (M1 AND M2) OR M3 -> (M1*M2)+M3

Specified by:
buildMessage in interface MessageBuilder
Parameters:
booleanRule - Boolean expression
messageContainer - Contains a list of messages
Returns:
A message
Throws:
MessageBuilderException - Errors building message


Copyright © 2004-2013 The Kuali Foundation. All Rights Reserved.