org.drools.reteoo
Class Builder

java.lang.Object
  extended by org.drools.reteoo.Builder

public class Builder
extends Object

Builds the Rete-OO network for a RuleSet.

Author:
bob mcwhirter TODO Make joinForCondition actually be intelligent enough to build optimal joins. Currently using forgy's original description of 2-input nodes, which I feel (but don't know for sure, is sub-optimal.
See Also:
RuleSet

Constructor Summary
Builder()
          Construct a Builder against an existing Rete network.
Builder(RuleBaseContext ruleBaseContext)
          Construct a Builder against an existing Rete network.
 
Method Summary
protected  void addRule(Rule rule)
          Add a Rule to the network.
 void addRuleSet(RuleSet ruleSet)
          Add a RuleSet to the network.
 RuleBase buildRuleBase()
          Build the RuleBase.
(package private)  List createParameterNodes(Rule rule)
          Create the ParameterNode s for the Rule, and link into the network.
(package private)  TupleSource findMatchingTupleSourceForCondition(Condition condition, List sources)
          Locate a TupleSource suitable for attaching the Condition and remove it.
(package private)  boolean matches(Condition condition, Set declarations)
          Determine if a set of Declarations match those required by a Condition.
 void setConflictResolver(ConflictResolver conflictResolver)
          Set the ConflictResolver.
 void setFactHandleFactory(FactHandleFactory factHandleFactory)
          Set the FactHandleFactory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Builder

public Builder()
Construct a Builder against an existing Rete network.


Builder

public Builder(RuleBaseContext ruleBaseContext)
Construct a Builder against an existing Rete network.

Method Detail

buildRuleBase

public RuleBase buildRuleBase()
Build the RuleBase.

Returns:
The rule-base.

setFactHandleFactory

public void setFactHandleFactory(FactHandleFactory factHandleFactory)
Set the FactHandleFactory.

Parameters:
factHandleFactory - The fact handle factory.

setConflictResolver

public void setConflictResolver(ConflictResolver conflictResolver)
Set the ConflictResolver.

Parameters:
conflictResolver - The conflict resolver.

addRuleSet

public void addRuleSet(RuleSet ruleSet)
                throws RuleIntegrationException,
                       RuleSetIntegrationException
Add a RuleSet to the network.

Parameters:
ruleSet - The rule-set to add.
Throws:
RuleIntegrationException - if an error prevents complete construction of the network for the Rule.
RuleSetIntegrationException

addRule

protected void addRule(Rule rule)
                throws RuleIntegrationException
Add a Rule to the network.

Parameters:
rule - The rule to add.
Throws:
RuleIntegrationException - if an error prevents complete construction of the network for the Rule.

createParameterNodes

List createParameterNodes(Rule rule)
Create the ParameterNode s for the Rule, and link into the network.

Parameters:
rule - The rule.
Returns:
A Set of ParameterNodes created and linked into the network.

findMatchingTupleSourceForCondition

TupleSource findMatchingTupleSourceForCondition(Condition condition,
                                                List sources)
Locate a TupleSource suitable for attaching the Condition and remove it.

Parameters:
condition - The Condition to attach.
sources - Candidate TupleSources.
Returns:
Matching TupleSource if a suitable one can be found, else null.

matches

boolean matches(Condition condition,
                Set declarations)
Determine if a set of Declarations match those required by a Condition.

Parameters:
condition - The Condition.
declarations - The set of Declarations to compare against.
Returns:
true if the set of Declarations is a super-set of the Declarations required by the Condition.


Copyright © 2001-2005 The Codehaus. All Rights Reserved.