Class ReteBuilder
- java.lang.Object
- 
- jadex.rules.rulesystem.rete.builder.ReteBuilder
 
- 
 public class ReteBuilder extends java.lang.ObjectThe rete builder class has the purpose to generate a rete network for a condition.
- 
- 
Field SummaryFields Modifier and Type Field Description protected booleanindexingFlag to turn on/off indexing.protected booleannodesharingFlag to turn on/off nodesharing.protected booleannotjoinFlag to turn on/off placing join constraints in a not node (otherwise separate beta nodes will be created and not nodes will have no constraints).protected BuildReportreportThe build report.static booleanREPORTINGThe flag for turning on/off reporting.
 - 
Constructor SummaryConstructors Constructor Description ReteBuilder()Create a new rete builder.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddAlphaNode(IConstraintEvaluator[] evas, BuildContext context)Add a new alpha node.protected voidaddBetaNode(IConstraintEvaluator[] evas, ConstraintIndexer[] ids, BuildContext context)Add a new beta node.protected voidaddCollectNode(IConstraintEvaluator[] evas, int tuplecnt, BuildContext context)Add a new collect node.protected voidaddInitialFactNode(BuildContext context)Add an initial fact node.protected voidaddNotNode(IConstraintEvaluator[] evas, ConstraintIndexer[] ids, int tuplecnt, BuildContext context)Add a new not node.ReteNodeaddRule(ReteNode root, IRule rule)Add a new rule to the network.protected voidaddSplitNode(OAVAttributeType attr, java.lang.String[] binds, BuildContext context)Add a new split node.protected voidaddTerminalNode(IRule rule, BuildContext context)Add a new terminal node.protected voidaddTestNode(IConstraintEvaluator eva, BuildContext context)Add a new test node.protected voidaddTypeNode(OAVObjectType type, BuildContext context)Add a new type node.voidbuildAndCondition(AndCondition curcond, BuildContext context)Build an and condition.voidbuildCollectCondition(CollectCondition curcond, BuildContext context)Build a collect condition.voidbuildCondition(ICondition curcond, BuildContext context)Build any kind condition.protected java.util.ListbuildConstraintEvaluator(ICondition cond, IConstraint c, BuildContext context)Generate constraint evaluator for a constraint.protected java.util.ListbuildConstraintIndexer(ObjectCondition cond, IConstraint c, BuildContext context)Generate a constraint indexer for a top-level equal join.IValueExtractorbuildFunctionExtractor(int tupleindex, FunctionCall fc, int subindex, BuildContext context)Build a function extractor for a function call.voidbuildNotCondition(NotCondition curcond, BuildContext context)Build a not condition.voidbuildObjectCondition(ObjectCondition curcond, BuildContext context)Build an object condition.voidbuildOrCondition(OrCondition curcond, BuildContext context)Build an or condition.voidbuildTestCondition(TestCondition curcond, BuildContext context)Build a test condition.protected IValueExtractorbuildVariableExtractor(Variable var, BuildContext context)Build a variable extractor for an alpha or beta context.protected voidconnectLeft(INode source, INode consumer, BuildContext context)Connect two nodes by attaching the source to the left (tuple) input of the consumer.protected voidconnectRight(INode source, INode consumer, BuildContext context)Connect two nodes by attaching the source to the right (object) input of the consumer.IValueExtractorcreateArrayExtractor(int tupleindex, ArraySelector as, BuildContext context, boolean prefix)Build an array extractor for an array selector.IValueExtractorcreateMethodExtractor(int tupleindex, MethodCall mc, BuildContext context, boolean prefix)Build a method extractor for a method call.protected IValueExtractorcreateObjectExtractor(OAVAttributeType attr, java.lang.Object key)Create an object extractor for the given (OAV or Java) attribute.protected IValueExtractorcreatePrefixExtractor(OAVAttributeType attr, java.lang.Object key)Create a prefix extractor for the given (OAV or Java) attribute.protected IValueExtractorcreateTupleExtractor(int tupleindex, OAVAttributeType attr, java.lang.Object key)Create a tuple extractor for the given (OAV or Java) attribute.IValueExtractorcreateValueExtractor(int tupleindex, java.lang.Object valuesource, int subindex, BuildContext context, boolean prefix)Creates an appropriate extractor for the given parameters.BuildReportgetBuildReport()Get the build report.protected intgetChildCount(INode node)Count the number of children.protected IValueExtractorgetLeftVariableExtractor(BuildContext context, Variable var)Get the evaluator for the first occurrence of the given variable (when needed as left input).protected IValueExtractorgetRightVariableExtractor(BuildContext context, Variable var)Get the evaluator for the first occurrence of the given variable (when needed as right input).protected booleanisAlphaExecutable(ICondition cond, IConstraint c)Test if all needed variables are available from the condition directly.protected voidremoveNodeUsage(INode node)Remove a node usage.voidremoveRule(ReteNode root, IRule rule)Remove a rule from a rete network.
 
- 
- 
- 
Field Detail- 
REPORTINGpublic static final boolean REPORTING The flag for turning on/off reporting.- See Also:
- Constant Field Values
 
 - 
indexingprotected boolean indexing Flag to turn on/off indexing.
 - 
nodesharingprotected boolean nodesharing Flag to turn on/off nodesharing.
 - 
notjoinprotected boolean notjoin Flag to turn on/off placing join constraints in a not node (otherwise separate beta nodes will be created and not nodes will have no constraints).
 - 
reportprotected BuildReport report The build report.
 
- 
 - 
Method Detail- 
addRulepublic ReteNode addRule(ReteNode root, IRule rule) Add a new rule to the network.- Parameters:
- root- The root node (when null a new network will be created).
- rule- The rule to add.
 
 - 
removeRulepublic void removeRule(ReteNode root, IRule rule) Remove a rule from a rete network.- Parameters:
- root- The root node.
- rule- The rule to remove.
 
 - 
getBuildReportpublic BuildReport getBuildReport() Get the build report.- Returns:
- The build report.
 
 - 
buildConditionpublic void buildCondition(ICondition curcond, BuildContext context) Build any kind condition.
 - 
buildAndConditionpublic void buildAndCondition(AndCondition curcond, BuildContext context) Build an and condition.
 - 
buildOrConditionpublic void buildOrCondition(OrCondition curcond, BuildContext context) Build an or condition.
 - 
buildNotConditionpublic void buildNotCondition(NotCondition curcond, BuildContext context) Build a not condition.
 - 
buildObjectConditionpublic void buildObjectCondition(ObjectCondition curcond, BuildContext context) Build an object condition.- Parameters:
- curcond- the object condition.
- context- The build context.
 
 - 
buildTestConditionpublic void buildTestCondition(TestCondition curcond, BuildContext context) Build a test condition.
 - 
buildCollectConditionpublic void buildCollectCondition(CollectCondition curcond, BuildContext context) Build a collect condition.
 - 
removeNodeUsageprotected void removeNodeUsage(INode node) Remove a node usage.- Parameters:
- node- The node usage to remove.
 
 - 
getChildCountprotected int getChildCount(INode node) Count the number of children.- Parameters:
- node- The node.
- Returns:
- The number of children.
 
 - 
connectLeftprotected void connectLeft(INode source, INode consumer, BuildContext context) Connect two nodes by attaching the source to the left (tuple) input of the consumer.- Parameters:
- source- The source node.
- consumer- The consumer node.
 
 - 
connectRightprotected void connectRight(INode source, INode consumer, BuildContext context) Connect two nodes by attaching the source to the right (object) input of the consumer.- Parameters:
- source- The source node.
- consumer- The consumer node.
 
 - 
buildConstraintIndexerprotected java.util.List buildConstraintIndexer(ObjectCondition cond, IConstraint c, BuildContext context) Generate a constraint indexer for a top-level equal join.
 - 
buildConstraintEvaluatorprotected java.util.List buildConstraintEvaluator(ICondition cond, IConstraint c, BuildContext context) Generate constraint evaluator for a constraint.- Parameters:
- cond- The object condition.
- c- The constraint.
- context- The build context.
- Returns:
- The constraint evaluator.
 
 - 
buildFunctionExtractorpublic IValueExtractor buildFunctionExtractor(int tupleindex, FunctionCall fc, int subindex, BuildContext context) Build a function extractor for a function call.- Parameters:
- fc- The function call.
- Returns:
- The function call.
 
 - 
buildVariableExtractorprotected IValueExtractor buildVariableExtractor(Variable var, BuildContext context) Build a variable extractor for an alpha or beta context. If it is a beta context the function determines if the variable value is available from the left or from the right.- Parameters:
- var- The variable.
- context- The build context.
- alpha- Is the extractor for alpha or beta context.
 
 - 
isAlphaExecutableprotected boolean isAlphaExecutable(ICondition cond, IConstraint c) Test if all needed variables are available from the condition directly. All variables must be declared as BoundConstraints with equal operator in this object condition.- Returns:
- True, if can be evaluated in alpha network.
 
 - 
addTypeNodeprotected void addTypeNode(OAVObjectType type, BuildContext context) Add a new type node.- Parameters:
- type- The type node.
- context- the build context.
 
 - 
addAlphaNodeprotected void addAlphaNode(IConstraintEvaluator[] evas, BuildContext context) Add a new alpha node.- Parameters:
- eva- The constraint evaluator.
- context- The build context.
 
 - 
addSplitNodeprotected void addSplitNode(OAVAttributeType attr, java.lang.String[] binds, BuildContext context) Add a new split node.- Parameters:
- attr- The attribute.
- binds- The binding variable codes.
- context- The build context.
 
 - 
addBetaNodeprotected void addBetaNode(IConstraintEvaluator[] evas, ConstraintIndexer[] ids, BuildContext context) Add a new beta node.- Parameters:
- evas- The constraint evaluators.
- ids- The constraint indexers.
- context- The build context.
 
 - 
addNotNodeprotected void addNotNode(IConstraintEvaluator[] evas, ConstraintIndexer[] ids, int tuplecnt, BuildContext context) Add a new not node.- Parameters:
- evas- The constraint evaluators.
- ids- The constraint indexers.
- context- The build context.
 
 - 
addInitialFactNodeprotected void addInitialFactNode(BuildContext context) Add an initial fact node.- Parameters:
- context- The build context.
 
 - 
addTestNodeprotected void addTestNode(IConstraintEvaluator eva, BuildContext context) Add a new test node.- Parameters:
- eva- The constraint evaluator.
- context- The build context.
 
 - 
addCollectNodeprotected void addCollectNode(IConstraintEvaluator[] evas, int tuplecnt, BuildContext context) Add a new collect node.- Parameters:
- eva- The constraint evaluator.
- context- The build context.
 
 - 
addTerminalNodeprotected void addTerminalNode(IRule rule, BuildContext context) Add a new terminal node.- Parameters:
- rule- The rule.
- context- The build context.
 
 - 
getRightVariableExtractorprotected IValueExtractor getRightVariableExtractor(BuildContext context, Variable var) Get the evaluator for the first occurrence of the given variable (when needed as right input).- Parameters:
- var- The variable.
- Returns:
- The extractor for the first occurrence.
 
 - 
getLeftVariableExtractorprotected IValueExtractor getLeftVariableExtractor(BuildContext context, Variable var) Get the evaluator for the first occurrence of the given variable (when needed as left input).- Parameters:
- var- The variable.
- Returns:
- The extractor for the first occurrence.
 
 - 
createValueExtractorpublic IValueExtractor createValueExtractor(int tupleindex, java.lang.Object valuesource, int subindex, BuildContext context, boolean prefix) Creates an appropriate extractor for the given parameters.- Parameters:
- tupleindex- The tuple index (-1 for none).
- attr- The attribute.
- subindex- The subindex when multisplit (-1 for none).
- Returns:
- The value extractor.
 
 - 
createMethodExtractorpublic IValueExtractor createMethodExtractor(int tupleindex, MethodCall mc, BuildContext context, boolean prefix) Build a method extractor for a method call.- Parameters:
- mc- The method call.
- Returns:
- The method call.
 
 - 
createArrayExtractorpublic IValueExtractor createArrayExtractor(int tupleindex, ArraySelector as, BuildContext context, boolean prefix) Build an array extractor for an array selector.- Parameters:
- as- The array selector.
- Returns:
- The value extractor.
 
 - 
createObjectExtractorprotected IValueExtractor createObjectExtractor(OAVAttributeType attr, java.lang.Object key) Create an object extractor for the given (OAV or Java) attribute.- Parameters:
- attr- The attribute.
- Returns:
- The extractor.
 
 - 
createTupleExtractorprotected IValueExtractor createTupleExtractor(int tupleindex, OAVAttributeType attr, java.lang.Object key) Create a tuple extractor for the given (OAV or Java) attribute.- Parameters:
- attr- The attribute.
- Returns:
- The extractor.
 
 - 
createPrefixExtractorprotected IValueExtractor createPrefixExtractor(OAVAttributeType attr, java.lang.Object key) Create a prefix extractor for the given (OAV or Java) attribute.- Parameters:
- attr- The attribute.
- Returns:
- The extractor.
 
 
- 
 
-