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

java.lang.Object
  extended by org.kuali.student.common.messagebuilder.impl.SimpleBooleanMessageBuilder
All Implemented Interfaces:
MessageTreeBuilder

public class SimpleBooleanMessageBuilder
extends Object
implements MessageTreeBuilder

This class creates success messages for boolean binary tree nodes. Default display is a single line message (e.g. A OR (B AND (C OR D))). To display as multiple lines where each operator and message is on its own line. set the following:

 INDENT_CHAR = ' '
 INDENT_NUMBER_OF_SPACES = 4
 BOOLEAN_OPERATOR_PREFIX = "\n"
 BOOLEAN_OPERATOR_SUFFIX = "\n"
 Example:
 
    MATH101
 OR
        (MATH201
    AND
            (MATH301
        OR
            MATH401))
 


Field Summary
private static String BOOLEAN_OPERATOR_PREFIX
           
private static String BOOLEAN_OPERATOR_SUFFIX
           
private  String booleanOperatorPrefix
           
private  BooleanOperators booleanOperators
          Boolean operators to use in creating the success message
private  String booleanOperatorSuffix
           
private static char INDENT_CHAR
           
private static int INDENT_NUMBER_OF_SPACES
           
private static String INDENT_STRING
           
private  int indentCharacter
           
private  int indentNumberOfSpaces
           
private  String indentString
           
private  int parentCount
           
 
Constructor Summary
SimpleBooleanMessageBuilder(BooleanOperators bo)
          Creates a success message builder with boolean operators to use in building the success message.
SimpleBooleanMessageBuilder(String andOperator, String orOperator)
          Creates a success message builder with boolean operators to use in building the success message.
 
Method Summary
private  void buildAndNodeSuccessMessage(BooleanNode node)
          Builds a success message for an AND node (b-tree node) where left node and right node are true.
 String buildMessage(BooleanNode node)
          Builds and sets the success message for a single boolean node (b-tree node).
 String buildMessage(List<BooleanNode> nodeList)
          Builds and sets the success message for each of the boolean nodes (binary tree) in the nodeList.
private  void buildOrNodeSuccessMessage(BooleanNode node)
          Builds a success message for an OR node (b-tree node) where left node and right node are true.
private  void countParents(BooleanNode node)
           
private  String getIndent(BooleanNode node, int multiplier)
           
private static String getString(int charCount, char indentChr)
           
 void setBooleanOperatorPrefix(String booleanOperatorPrefix)
           
 void setBooleanOperatorSuffix(String booleanOperatorSuffix)
           
 void setIndentCharacter(int indentChar)
           
 void setIndentNumberOfSpaces(int indentNumberOfSpaces)
           
 void setIndentString(String indentString)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INDENT_CHAR

private static final char INDENT_CHAR
See Also:
Constant Field Values

INDENT_NUMBER_OF_SPACES

private static final int INDENT_NUMBER_OF_SPACES
See Also:
Constant Field Values

INDENT_STRING

private static final String INDENT_STRING

BOOLEAN_OPERATOR_PREFIX

private static final String BOOLEAN_OPERATOR_PREFIX
See Also:
Constant Field Values

BOOLEAN_OPERATOR_SUFFIX

private static final String BOOLEAN_OPERATOR_SUFFIX
See Also:
Constant Field Values

indentCharacter

private int indentCharacter

indentNumberOfSpaces

private int indentNumberOfSpaces

indentString

private String indentString

booleanOperatorPrefix

private String booleanOperatorPrefix

booleanOperatorSuffix

private String booleanOperatorSuffix

booleanOperators

private BooleanOperators booleanOperators
Boolean operators to use in creating the success message


parentCount

private int parentCount
Constructor Detail

SimpleBooleanMessageBuilder

public SimpleBooleanMessageBuilder(String andOperator,
                                   String orOperator)
Creates a success message builder with boolean operators to use in building the success message.

Parameters:
andOperator - AND logical operator
orOperator - OR logical operator

SimpleBooleanMessageBuilder

public SimpleBooleanMessageBuilder(BooleanOperators bo)
Creates a success message builder with boolean operators to use in building the success message.

Parameters:
bo - Boolean operators to build success message
Method Detail

setIndentCharacter

public void setIndentCharacter(int indentChar)

setIndentNumberOfSpaces

public void setIndentNumberOfSpaces(int indentNumberOfSpaces)

setIndentString

public void setIndentString(String indentString)

setBooleanOperatorPrefix

public void setBooleanOperatorPrefix(String booleanOperatorPrefix)

setBooleanOperatorSuffix

public void setBooleanOperatorSuffix(String booleanOperatorSuffix)

buildMessage

public String buildMessage(List<BooleanNode> nodeList)
                    throws MessageBuilderException
Builds and sets the success message for each of the boolean nodes (binary tree) in the nodeList.

Specified by:
buildMessage in interface MessageTreeBuilder
Parameters:
nodeList - List of boolean nodes
Returns:
Complete success message
Throws:
MessageBuilderException

buildMessage

public String buildMessage(BooleanNode node)
Builds and sets the success message for a single boolean node (b-tree node).

Parameters:
node - Boolean node

buildAndNodeSuccessMessage

private void buildAndNodeSuccessMessage(BooleanNode node)
Builds a success message for an AND node (b-tree node) where left node and right node are true.

Parameters:
node - Boolean node

buildOrNodeSuccessMessage

private void buildOrNodeSuccessMessage(BooleanNode node)
Builds a success message for an OR node (b-tree node) where left node and right node are true.

Parameters:
node -

countParents

private void countParents(BooleanNode node)

getIndent

private String getIndent(BooleanNode node,
                         int multiplier)

getString

private static String getString(int charCount,
                                char indentChr)


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