jeops.engine
Class RuleSorter

java.lang.Object
  |
  +--jeops.engine.RuleSorter
Direct Known Subclasses:
DefaultRuleSorter, LRURuleSorter, MRURuleSorter, NaturalRuleSorter, OneShotRuleSorter, PriorityRuleSorter

public abstract class RuleSorter
extends java.lang.Object

Abstract class that defines the methods needed by any rule sorter, used by the conflict set to choose the rule to be fired.

Version:
0.05 24 May 1999 The fireable rules became a hashtable (it was a Vector).
Author:
Carlos Figueira Filho (csff@di.ufpe.br)
See Also:
ConflictSet

Constructor Summary
RuleSorter()
          Class constructor.
 
Method Summary
 void flush()
          Removes all rules of this sorter.
 void insertRule(Rule rule)
          Inserts a rule in this sorter.
 boolean isEmpty()
          Checks whether this sorter has any rule to be fired.
abstract  Rule nextRule()
          Returns the next rule to be fired.
 void removeNonFireableRules()
          Re-test all instanciations of the rules to check whether they're still fireable, removing those that aren't anymore.
 void removeRule(Rule rule)
          Remove the given rule from the fireable rules.
 void removeRulesWith(java.lang.Object obj)
          Remove all rules from the fireable ones that uses the given object in its instantiations.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RuleSorter

public RuleSorter()
Class constructor.
Method Detail

flush

public void flush()
Removes all rules of this sorter.

insertRule

public void insertRule(Rule rule)
Inserts a rule in this sorter. The rule's symbolic table will be filled with the objects that made it fireable.
Parameters:
rule - the rule to be inserted.

isEmpty

public boolean isEmpty()
Checks whether this sorter has any rule to be fired.
Returns:
false if there is at least one fireable rule; true otherwise.

nextRule

public abstract 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.
Returns:
the rule to be fired, among those that have been inserted in this object, according to the policy defined in the subclass that implements this method.
Throws:
NoMoreRulesException - if there aren't any more rules to be fired.

removeNonFireableRules

public void removeNonFireableRules()
Re-test all instanciations of the rules to check whether they're still fireable, removing those that aren't anymore. This method tends to be a little slow, so it must be used with care.

removeRule

public void removeRule(Rule rule)
Remove the given rule from the fireable rules. This method will tipically be called by this class' subclasses, when returning a rule.
Parameters:
rule - the given rule

removeRulesWith

public void removeRulesWith(java.lang.Object obj)
Remove all rules from the fireable ones that uses the given object in its instantiations.
Parameters:
obj - the given object