View Javadoc

1   /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.student.common.messagebuilder;
17  
18  import java.util.Map;
19  
20  import org.kuali.student.common.messagebuilder.booleanmessage.MessageContainer;
21  import org.kuali.student.common.messagebuilder.booleanmessage.ast.BooleanFunctionResult;
22  import org.kuali.student.common.messagebuilder.impl.exceptions.MessageBuilderException;
23  
24  public interface MessageBuilder {
25      /**
26       * <p>Builds and evaluates a boolean expression and returns the message and result 
27       * of the expression.</p>
28       * <p><b>Note:</b> Order of boolean operation: ANDs before ORs and operations 
29       * inside parentheses before anything else.</p> 
30  	 * Example 1: 'A AND B OR C AND D' internally evaluates to '(A AND B) OR (C AND D)'
31  	 * <pre><code>booleanExpression</code> = "A*B+C*D"</pre>
32       * Example 2: '(M1 AND M2) OR M3' 
33       * <pre><code>booleanExpression</code> = "(M1*M2)+M3"</pre>
34       * 
35       * @param booleanRule Boolean expression
36       * @param messageContainer Contains a list of messages
37       * @return Boolean function result
38       * @throws MessageBuilderException Errors building message
39       */
40      public BooleanFunctionResult build(String booleanRule, MessageContainer messageContainer);
41  
42      /**
43       * <p>Builds and evaluates a boolean expression and returns the message and result 
44       * of the expression.</p>
45       * <p><b>Note:</b> Order of boolean operation: ANDs before ORs and operations 
46       * inside parentheses before anything else.</p>
47       * <p>if <code>messageContainer</code> contains any velocity templates 
48       * with keys/tokens then <code>messageContextMap</code> must be set.</p>
49  	 * Example 1: 'A AND B OR C AND D' internally evaluates to '(A AND B) OR (C AND D)'
50  	 * <pre><code>booleanExpression</code> = "A*B+C*D"</pre>
51       * Example 2: '(M1 AND M2) OR M3' 
52       * <pre><code>booleanExpression</code> = "(M1*M2)+M3"</pre>
53       * 
54       * @param booleanRule Boolean expression
55       * @param messageContainer Contains a list of messages
56       * @param messageContextMap Message context template map
57       * @return Boolean function result
58       * @throws MessageBuilderException Errors building message
59       */
60      public BooleanFunctionResult build(String booleanRule, MessageContainer messageContainer, Map<String, Object> messageContextMap);
61  
62      /**
63       * Builds a message from a list of message using a boolean expression. 
64       * Example: (M1 AND M2) OR M3 -> (M1*M2)+M3
65       * 
66       * @param booleanRule Boolean expression
67       * @param messageContainer Contains a list of messages
68       * @return A message
69       * @throws MessageBuilderException Errors building message
70       */
71      public String buildMessage(String booleanRule, MessageContainer messageContainer);
72  }