Package org.openl.rules.cmatch.algorithm
Class MatchAlgorithmCompiler
- java.lang.Object
-
- org.openl.rules.cmatch.algorithm.MatchAlgorithmCompiler
-
- All Implemented Interfaces:
IMatchAlgorithmCompiler
- Direct Known Subclasses:
ScoreAlgorithmCompiler,WeightAlgorithmCompiler
public class MatchAlgorithmCompiler extends Object implements IMatchAlgorithmCompiler
-
-
Field Summary
Fields Modifier and Type Field Description protected static List<ColumnDefinition>MATCH_COLUMN_DEFINITIONstatic StringNAMESstatic StringOPERATIONstatic StringVALUES
-
Constructor Summary
Constructors Constructor Description MatchAlgorithmCompiler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidassignExecutor(ColumnMatch columnMatch)protected MatchNodebuildTree(List<TableRow> rows, MatchNode[] nodes)Builds tree based on indentation of each row.protected voidcheckRowName(TableRow row, String expectedName)protected voidcheckSpecialRows(ColumnMatch columnMatch)voidcompile(IBindingContext bindingContext, ColumnMatch columnMatch)protected List<ColumnDefinition>getColumnDefinition()protected intgetSpecialRowCount()protected voidparseCheckValues(IBindingContext bindingContext, ColumnMatch columnMatch, TableRow row, MatchNode node, int retValuesCount)Parses CheckValues for node(row).protected voidparseSpecialRows(IBindingContext bindingContext, ColumnMatch columnMatch)Compiles (parses) return values based on return type.protected Object[]parseValues(IBindingContext bindingContext, ColumnMatch columnMatch, TableRow row, IOpenClass openClass)protected MatchNode[]prepareNodes(IBindingContext bindingContext, ColumnMatch columnMatch, ArgumentsHelper argumentsHelper, int retValuesCount)Prepares Nodes.protected voidsetMetaInfoForConstant(IBindingContext bindingContext, ColumnMatch columnMatch, SubValue sv, ConstantOpenField constantOpenField)protected voidvalidateTree(MatchNode rootNode, List<TableRow> rows, MatchNode[] nodes)Checks that tree is consistent.
-
-
-
Field Detail
-
NAMES
public static final String NAMES
- See Also:
- Constant Field Values
-
OPERATION
public static final String OPERATION
- See Also:
- Constant Field Values
-
VALUES
public static final String VALUES
- See Also:
- Constant Field Values
-
MATCH_COLUMN_DEFINITION
protected static final List<ColumnDefinition> MATCH_COLUMN_DEFINITION
-
-
Method Detail
-
assignExecutor
protected void assignExecutor(ColumnMatch columnMatch)
-
buildTree
protected MatchNode buildTree(List<TableRow> rows, MatchNode[] nodes) throws SyntaxNodeException
Builds tree based on indentation of each row.- Parameters:
nodes- (special rows must be null)- Returns:
- root of tree
- Throws:
SyntaxNodeException
-
checkRowName
protected void checkRowName(TableRow row, String expectedName) throws SyntaxNodeException
- Throws:
SyntaxNodeException
-
checkSpecialRows
protected void checkSpecialRows(ColumnMatch columnMatch) throws SyntaxNodeException
- Throws:
SyntaxNodeException
-
compile
public void compile(IBindingContext bindingContext, ColumnMatch columnMatch) throws SyntaxNodeException
- Specified by:
compilein interfaceIMatchAlgorithmCompiler- Throws:
SyntaxNodeException
-
getColumnDefinition
protected List<ColumnDefinition> getColumnDefinition()
-
getSpecialRowCount
protected int getSpecialRowCount()
-
parseCheckValues
protected void parseCheckValues(IBindingContext bindingContext, ColumnMatch columnMatch, TableRow row, MatchNode node, int retValuesCount)
Parses CheckValues for node(row). It is up to matcher (type of variable in 'names') how to parse it.
-
parseSpecialRows
protected void parseSpecialRows(IBindingContext bindingContext, ColumnMatch columnMatch) throws SyntaxNodeException
Compiles (parses) return values based on return type.- Throws:
SyntaxNodeException
-
parseValues
protected Object[] parseValues(IBindingContext bindingContext, ColumnMatch columnMatch, TableRow row, IOpenClass openClass) throws SyntaxNodeException
- Throws:
SyntaxNodeException
-
setMetaInfoForConstant
protected void setMetaInfoForConstant(IBindingContext bindingContext, ColumnMatch columnMatch, SubValue sv, ConstantOpenField constantOpenField)
-
prepareNodes
protected MatchNode[] prepareNodes(IBindingContext bindingContext, ColumnMatch columnMatch, ArgumentsHelper argumentsHelper, int retValuesCount) throws SyntaxNodeException
Prepares Nodes. Check names, operations and assigns matchers.Special rows are ignored. That is why first n elements in return array is always null.
- Returns:
- array of nodes, elements corresponds rows
- Throws:
SyntaxNodeException
-
validateTree
protected void validateTree(MatchNode rootNode, List<TableRow> rows, MatchNode[] nodes) throws SyntaxNodeException
Checks that tree is consistent.- Parameters:
rootNode- root of treerows- rows to point out errors- Throws:
SyntaxNodeException
-
-