jeops.engine
Class NaturalRuleSorter

java.lang.Object
  |
  +--jeops.engine.RuleSorter
        |
        +--jeops.engine.NaturalRuleSorter

public class NaturalRuleSorter
extends RuleSorter

A rule sorter that will fire each pair (rule, instanciations) only once, that is, no rule will fire twice with the same list of objects. In spite of what happens in other implementations of the rule sorter, the control of which rules belong to the conflict set here is done entirely in the insertion of the rule in this sorter. The nextRule() operation will only retrieve the first one and take it out of the set.

Version:
0.01 13 Dez 1998
Author:
Carlos Figueira Filho (csff@di.ufpe.br)
See Also:
ConflictSet

Constructor Summary
NaturalRuleSorter()
          Class constructor.
 
Method Summary
 void flush()
          Removes all rules of this sorter.
 void insertRule(Rule rule)
          Inserts a rule in this sorter.
 Rule nextRule()
          Returns the next rule to be fired.
 void ruleRemoved(java.lang.String ruleName)
          Callback method, used to inform this class that a rule was removed from this sorter.
 
Methods inherited from class jeops.engine.RuleSorter
isEmpty, removeNonFireableRules, removeRule, removeRulesWith
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NaturalRuleSorter

public NaturalRuleSorter()
Class constructor.
Method Detail

flush

public void flush()
Removes all rules of this sorter. Also, clears the history of the rules that have already been fired.
Overrides:
flush in class RuleSorter

insertRule

public void insertRule(Rule rule)
Inserts a rule in this sorter.
Overrides:
insertRule in class RuleSorter
Parameters:
rule - the rule to be inserted.

nextRule

public Rule nextRule()
              throws NoMoreRulesException
Returns the next rule to be fired. In the return of this method, the symbolic table of the table shall be correctly filled.
Overrides:
nextRule in class RuleSorter
Returns:
the rule to be fired, among those that have been inserted in this object, according to the policy defined in this class.

ruleRemoved

public void ruleRemoved(java.lang.String ruleName)
Callback method, used to inform this class that a rule was removed from this sorter. It won't be needed.
Parameters:
ruleName - the name of the removed rule.