public abstract class ReconExpression
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected boolean |
compiled
set to true after the expression has been compiled; adding to the input
expression will reset the flag
|
protected java.lang.String |
expressionTag
the name of the expression object from th database
|
protected java.util.List |
infixTokens
the input expression in infix notation
|
protected ReconInfo |
reconInfo |
protected BinaryTreeNode |
rootNode
the root of the compiled binary tree
|
static int |
TOKEN_CONSTANT |
static int |
TOKEN_DATASET1_FIELD |
static int |
TOKEN_DATASET2_FIELD |
static int |
TOKEN_HIGHEST_VALUE
the highest numerical value of the tag that a valid expression token can have
|
static int |
TOKEN_INVALID |
static int |
TOKEN_LEFT_PARENTHESIS |
static int |
TOKEN_LOWEST_VALUE
the lowest numerical value the tag that a valid expression token can have
|
static int |
TOKEN_OPERATOR |
static int |
TOKEN_RIGHT_PARENTHESIS |
static int |
TOKEN_VALUE
a value to compare against in an expression
|
java.util.List |
validOperators
the allowed operators
|
Constructor and Description |
---|
ReconExpression(ReconInfo reconInfo) |
Modifier and Type | Method and Description |
---|---|
void |
addExpressionToken(int tokenType,
java.lang.String tokenValue)
Append a token at the end of the expresion.
|
void |
addExpressionToken(int tokenType,
java.lang.String tokenValue,
java.lang.String tokenUnit)
Append a token at the end of the expresion.
|
protected void |
compileExpression() |
protected BinaryTreeNode |
convertInfixToExpressionTree()
Loops through this list of infix expressions from left to right according
to the following steps.
|
protected void |
convertTreeToInfixString(BinaryTreeNode root,
java.lang.StringBuffer ret,
boolean topLevel)
Traverse the binary tree using a recursive algorithm
|
protected ReconOperator |
findOperator(int tokenType,
java.lang.String tokenValue,
java.util.List containingExpressionOperators) |
protected java.lang.String |
getAndOrAttributeName()
Overridable to adapt for eventual attribute name difference
|
java.util.Set |
getAttributeSet(boolean getLeftSide,
boolean stripPrefixes) |
java.util.Map |
getAttributeToUnitMap(boolean getLeftSide,
boolean stripPrefixes) |
protected java.lang.String |
getCloseParentheses(MboRemote clause)
Overridable to allow subclsasses adapt for eventual attribute name
difference
|
java.lang.String |
getCompiledExpressionAsString() |
java.lang.String |
getExpressionTag() |
protected java.lang.String |
getExpressionTag(MboRemote clause)
Overridable to allow subclsasses adapt for eventual attribute name
difference
|
protected java.lang.String |
getOpenParentheses(MboRemote clause)
Overridable to allow subclsasses adapt for eventual attribute name
difference
|
protected int |
getSequenceNum(MboRemote clause)
Overridable to allow subclsasses adapt for eventual attribute name
difference
|
protected java.util.List |
handleLogicalAnd(java.util.List rightResult,
java.util.List leftResult) |
protected java.util.List |
handleLogicalOperator(BinaryTreeNode operatorNode,
java.util.List rightResult,
java.util.List leftResult) |
protected java.util.List |
handleLogicalOr(java.util.List rightResult,
java.util.List leftResult) |
protected static void |
popLinkPush(java.util.Stack operatorStack,
java.util.Stack nodeStack)
Pop off remaining operator in the operator stack, create a binary tree
node, link its children, and push onto the result stack
|
void |
prepareAttributeIndexes(ReconValueSet leadingSet,
ReconValueSet subordinateSet)
Modifies the comparison operators to use indexes into the attribute arrays
instead of attribute names - done for performance reasons
|
static void |
processInfixExpression(java.util.Stack operatorStack,
java.util.Stack nodeStack,
ReconExpressionToken currentToken) |
static void |
processOperatorToken(java.util.Stack operatorStack,
java.util.Stack nodeStack,
ReconExpressionToken currentToken) |
static void |
processRightParenthesisToken(java.util.Stack operatorStack,
java.util.Stack nodeStack) |
protected abstract void |
readClause(MboRemote clause) |
protected void |
readExpression(java.util.List reconLinkSet)
Coded readExpression to read Values from the MBO Set (srini) Added
Validation checks and exception handling (srini) 7/21/04
|
void |
readExpression(MboSetRemote reconLinkSet)
The reason why this method exisits: It is not possible to sort the MBO set
itself, because this code is called to validate the rule.
|
void |
reset()
Start over
|
void |
setExpressionTag(java.lang.String expressionTag) |
protected void |
walkTreeReplaceAttributeNamesWithIndexes(BinaryTreeNode root,
ReconValueSet leadingSet,
ReconValueSet subordinateSet)
Traverse the binary tree using a recursive algorithm
|
protected void |
walkTreeToGetAttribSet(BinaryTreeNode root,
java.util.Set attribSet,
boolean getLeftSide)
Recurse the tree to build a set of unique left or right sides
|
protected void |
walkTreeToGetAttribToUnitMap(BinaryTreeNode root,
java.util.Map attributeToUnitMap,
boolean getLeftSide)
Recurse the tree to build a map unique left or right sides to their unit names
|
public static final int TOKEN_INVALID
public static final int TOKEN_LEFT_PARENTHESIS
public static final int TOKEN_RIGHT_PARENTHESIS
public static final int TOKEN_OPERATOR
public static final int TOKEN_CONSTANT
public static final int TOKEN_DATASET1_FIELD
public static final int TOKEN_DATASET2_FIELD
public static final int TOKEN_VALUE
public static final int TOKEN_LOWEST_VALUE
public static final int TOKEN_HIGHEST_VALUE
public java.util.List validOperators
protected BinaryTreeNode rootNode
protected java.util.List infixTokens
protected boolean compiled
protected java.lang.String expressionTag
protected ReconInfo reconInfo
public ReconExpression(ReconInfo reconInfo)
public void setExpressionTag(java.lang.String expressionTag)
public java.lang.String getExpressionTag()
public java.lang.String getCompiledExpressionAsString()
protected void compileExpression() throws MXException
MXException
protected ReconOperator findOperator(int tokenType, java.lang.String tokenValue, java.util.List containingExpressionOperators) throws MXException
MXException
public void addExpressionToken(int tokenType, java.lang.String tokenValue) throws MXException
MXException
public void addExpressionToken(int tokenType, java.lang.String tokenValue, java.lang.String tokenUnit) throws MXException
MXException
public void prepareAttributeIndexes(ReconValueSet leadingSet, ReconValueSet subordinateSet) throws MXException
leadingSet
- subordinateSet
- MXException
protected java.lang.String getExpressionTag(MboRemote clause) throws MXException, java.rmi.RemoteException
clause
- the MboRemoteMXException
java.rmi.RemoteException
protected int getSequenceNum(MboRemote clause) throws MXException, java.rmi.RemoteException
clause
- the MboRemoteMXException
java.rmi.RemoteException
protected java.lang.String getOpenParentheses(MboRemote clause) throws MXException, java.rmi.RemoteException
clause
- the MboRemoteMXException
java.rmi.RemoteException
protected java.lang.String getCloseParentheses(MboRemote clause) throws MXException, java.rmi.RemoteException
clause
- the MboRemoteMXException
java.rmi.RemoteException
protected java.lang.String getAndOrAttributeName()
public void readExpression(MboSetRemote reconLinkSet) throws MXException, java.rmi.RemoteException
MXException
java.rmi.RemoteException
protected abstract void readClause(MboRemote clause) throws MXException, java.rmi.RemoteException
MXException
java.rmi.RemoteException
protected void readExpression(java.util.List reconLinkSet) throws MXException, java.rmi.RemoteException
MXException
java.rmi.RemoteException
public void reset()
public static void processOperatorToken(java.util.Stack operatorStack, java.util.Stack nodeStack, ReconExpressionToken currentToken) throws MXException
operatorStack
- stack containing operators found so farnodeStack
- resulting stack where each object is a
BinaryTreeNodecurrentToken
- the current token expression being processedMXException
for processing step #'s.
2) Token is an operator:
a) pop all operators that have equal or higher precedence from the
operator stack
b) push operators onto result stack
c) push current operator onto the operator stack
public static void processRightParenthesisToken(java.util.Stack operatorStack, java.util.Stack nodeStack)
operatorStack
- stack containing operators found so farnodeStack
- resulting stack where each object is a
BinaryTreeNodefor processing step #'s.
4) Token is right parenthesis:
a) Pop all operators from operator stack.
b) Push onto resulting stack, until a matching left parenthesis found
- do not include the pair of matching parentheses
public static void processInfixExpression(java.util.Stack operatorStack, java.util.Stack nodeStack, ReconExpressionToken currentToken) throws MXException
operatorStack
- stack containing operators found so farnodeStack
- resulting stack where each object is a
BinaryTreeNodecurrentToken
- the current token expression being processedMXException
for processing step #'s.
protected BinaryTreeNode convertInfixToExpressionTree() throws MXException
MXException
protected void convertTreeToInfixString(BinaryTreeNode root, java.lang.StringBuffer ret, boolean topLevel)
evaluateTree
protected static void popLinkPush(java.util.Stack operatorStack, java.util.Stack nodeStack)
operatorStack
- stack containing operators found so farnodeStack
- resulting stack where each object is a
BinaryTreeNode with links to its left and right
child nodesprotected void walkTreeReplaceAttributeNamesWithIndexes(BinaryTreeNode root, ReconValueSet leadingSet, ReconValueSet subordinateSet)
evaluateTree
public java.util.Set getAttributeSet(boolean getLeftSide, boolean stripPrefixes)
getLeftSide
- stripPrefixes
- public java.util.Map getAttributeToUnitMap(boolean getLeftSide, boolean stripPrefixes)
getLeftSide
- stripPrefixes
- protected void walkTreeToGetAttribSet(BinaryTreeNode root, java.util.Set attribSet, boolean getLeftSide)
root
- -
the root node of the treeattribSet
- -
output set to be added togetLeftSide
- When true, get the RIGHT token - because the tree is built
backwardsprotected void walkTreeToGetAttribToUnitMap(BinaryTreeNode root, java.util.Map attributeToUnitMap, boolean getLeftSide)
root
- -
the root node of the treeattribMap
- -
output set to be added togetLeftSide
- When true, get the RIGHT token - because the tree is built
backwardsprotected java.util.List handleLogicalOperator(BinaryTreeNode operatorNode, java.util.List rightResult, java.util.List leftResult) throws MXApplicationException
MXApplicationException
protected java.util.List handleLogicalAnd(java.util.List rightResult, java.util.List leftResult)
rightResult
- leftResult
- protected java.util.List handleLogicalOr(java.util.List rightResult, java.util.List leftResult)
rightResult
- leftResult
-