|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.kuali.student.common.ui.client.widgets.table.ExpressionParser
public class ExpressionParser
This is the parser for boolean expression. It checks the error, creates the Reverse Polish notation, merge the binary tree, sort the nodes.
Field Summary | |
---|---|
private List<String> |
errorMessageList
Error messages are stored in a list |
Constructor Summary | |
---|---|
ExpressionParser()
|
Method Summary | |
---|---|
private Node<Token> |
binaryTreeFromRPN(List<Node<Token>> rpnList)
Build the binary tree from list of tokens |
private void |
checkAnd(List<Token> tokenList,
int currentIndex)
|
private void |
checkCondition(List<Token> tokenList,
int currentIndex)
|
private void |
checkEndParenthesis(List<Token> tokenList,
int currentIndex)
|
private void |
checkOr(List<Token> tokenList,
int currentIndex)
|
private void |
checkStartParenthesis(List<Token> tokenList,
int currentIndex)
|
private int |
countToken(List<Token> tokenList,
int type)
|
private void |
errorCheck(List<Token> tokenList)
|
private int |
findNodeIndex(List<Node<Token>> nodeList,
int type)
|
private static Node |
getDeeperNode(List<Node> nodeList)
|
List<String> |
getErrorMessage()
It returns all error messages |
static String |
getExpressionString(Node root)
Create the boolean expression from tree |
private List<Node<Token>> |
getRPN(List<Node<Token>> nodeList)
If higher push to stack, else pop till less than or equal, add to list push to stack if ( push to stack if ) pop to list till (. |
private List<Token> |
getTokenList(List<String> tokenValueList)
|
private List<String> |
getTokenValue(String expression)
|
boolean |
hasError()
After parsing, it tells if the expression has error. |
private boolean |
hasParenthesis(List<Node<Token>> nodeList)
|
private int |
indexInInputTokenList(Token token,
List<Token> list)
Get the index of a token in the token list |
static Node<Token> |
mergeBinaryTree(Node<Token> binaryTree)
Merge the binary tree. |
private Node<Token> |
orderLeafChildren(Node<Token> binaryTree,
List<Token> tokenList)
Order the leaf children |
private Node<Token> |
orderNonLeafChildren(Node<Token> binaryTree,
List<Token> tokenList)
Order the nonleaf children |
private static boolean |
parentEqualsGrandParent(Node<Token> binaryTree)
|
Node<Token> |
parse(String expression)
Parse the boolean expression |
private void |
sequeceLeaves(List<Node> leafChildList,
List<Token> list)
Reorder the children |
private void |
sequeceNonLeaves(List<Node> nonLeafChildList,
List<Token> list)
Order the non leaves |
private List<Node<Token>> |
toNodeList(List<Token> tokenList)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private List<String> errorMessageList
Constructor Detail |
---|
public ExpressionParser()
Method Detail |
---|
public boolean hasError()
public List<String> getErrorMessage()
public Node<Token> parse(String expression)
public static String getExpressionString(Node root)
private Node<Token> orderNonLeafChildren(Node<Token> binaryTree, List<Token> tokenList)
private void sequeceNonLeaves(List<Node> nonLeafChildList, List<Token> list)
private Node<Token> orderLeafChildren(Node<Token> binaryTree, List<Token> tokenList)
private void sequeceLeaves(List<Node> leafChildList, List<Token> list)
private int indexInInputTokenList(Token token, List<Token> list)
private static Node getDeeperNode(List<Node> nodeList)
public static Node<Token> mergeBinaryTree(Node<Token> binaryTree)
private static boolean parentEqualsGrandParent(Node<Token> binaryTree)
private Node<Token> binaryTreeFromRPN(List<Node<Token>> rpnList)
private List<Node<Token>> getRPN(List<Node<Token>> nodeList)
private int findNodeIndex(List<Node<Token>> nodeList, int type)
private boolean hasParenthesis(List<Node<Token>> nodeList)
private List<Node<Token>> toNodeList(List<Token> tokenList)
private void errorCheck(List<Token> tokenList)
private int countToken(List<Token> tokenList, int type)
private void checkAnd(List<Token> tokenList, int currentIndex)
private void checkOr(List<Token> tokenList, int currentIndex)
private void checkStartParenthesis(List<Token> tokenList, int currentIndex)
private void checkEndParenthesis(List<Token> tokenList, int currentIndex)
private void checkCondition(List<Token> tokenList, int currentIndex)
private List<Token> getTokenList(List<String> tokenValueList)
private List<String> getTokenValue(String expression)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |