jeops.engine
Class Rule

java.lang.Object
  |
  +--jeops.engine.Rule

public class Rule
extends java.lang.Object
implements java.lang.Cloneable

This class models a rule to be evaluated in the inference engine.

Version:
0.12 First version with comments in English.
Author:
Carlos Figueira Filho (csff@di.ufpe.br)
See Also:
RuleBase

Constructor Summary
Rule(java.lang.String name, int priority)
          Creates an empty rule, given its name and priority.
 
Method Summary
 void addAction(RuleAction action)
          Adds a new action to this rule.
 void addDeclaration(RuleDeclaration decl)
          Adds a new declaration to this rule.
 void addLocalDeclaration(RuleLocalDeclaration decl)
          Adds a new local declaration to this rule.
 void addPrecondition(Precondition prec)
          Adds a new precondition to this rule.
 java.lang.Object clone()
          Clones this rule.
 void dump()
          Prints the tree for the expression of this precondition.
 void dump(int spaces)
          Prints the tree for the expression of this precondition.
 boolean equals(java.lang.Object obj)
          Compares this rule with the given object.
 void evaluateLocalDeclarations()
          Deprecated. Replaced by evaluateLocalDeclarations(int).
 void evaluateLocalDeclarations(int line)
          Evaluates the local declarations of this tule.
 void fire(KnowledgeBase base)
          Fires this rule.
 java.util.Vector getDeclarations()
          Returns the declarations of this rule.
 java.lang.String getName()
          Returns the name of this rule.
 int getPriority()
          Returns the priority of this rule.
 SymbolicTable getTable()
          Returns the symbolic table to be used in this rule.
 int hashCode()
          Returns a code used to store this rule in a hashtable.
 boolean isFireable()
          Checks whether the preconditions of this rule are (all) true.
 boolean isFireable(int linha)
          Checks whether the preconditions in a given line of this rule are (all) true.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rule

public Rule(java.lang.String name,
            int priority)
Creates an empty rule, given its name and priority.
Parameters:
name - this rule's name
priority - this rule's priority.
Method Detail

addAction

public void addAction(RuleAction action)
Adds a new action to this rule.
Parameters:
action - the new action.

addDeclaration

public void addDeclaration(RuleDeclaration decl)
Adds a new declaration to this rule.
Parameters:
decl - the new declaration.

addLocalDeclaration

public void addLocalDeclaration(RuleLocalDeclaration decl)
Adds a new local declaration to this rule.
Parameters:
decl - the new local declaration.

addPrecondition

public void addPrecondition(Precondition prec)
Adds a new precondition to this rule.
Parameters:
prec - the new precondition.

clone

public java.lang.Object clone()
Clones this rule.
Returns:
a clone of this rule.

dump

public void dump()
Prints the tree for the expression of this precondition. Useful for debugging.

dump

public void dump(int spaces)
Prints the tree for the expression of this precondition. Useful for debugging.
Parameters:
spaces - the identation for the printed output.

equals

public boolean equals(java.lang.Object obj)
Compares this rule with the given object.
Overrides:
equals in class java.lang.Object
Parameters:
obj - the object being compared to this rule.
Returns:
true if this rule is equal to the given object; false otherwise.

evaluateLocalDeclarations

public void evaluateLocalDeclarations()
                               throws MethodEvaluationException,
                                      FieldAccessException
Deprecated. Replaced by evaluateLocalDeclarations(int).

Evaluates the local declarations of this tule. Prior to invoking this method, the symbolic table must be correctly filled.
Throws:
MethodEvaluationException - se is there was an error while evaluating.
FieldAccessException - se is there was an error while evaluating.
See Also:
evaluateLocalDeclarations(int).

evaluateLocalDeclarations

public void evaluateLocalDeclarations(int line)
                               throws MethodEvaluationException,
                                      FieldAccessException
Evaluates the local declarations of this tule. Prior to invoking this method, the symbolic table must be correctly filled until the given line.
Parameters:
line - the given line.
Throws:
MethodEvaluationException - se is there was an error while evaluating.
FieldAccessException - se is there was an error while evaluating.

fire

public void fire(KnowledgeBase base)
          throws RuleNotFiredException
Fires this rule. Prior to invoking this method, the symbolic table must be correctly filled.
Parameters:
base - The knowledge base over which this rule will act.
Throws:
RuleNotFiredException - if the rule couldn't be fired

getDeclarations

public java.util.Vector getDeclarations()
Returns the declarations of this rule.
Returns:
the declarations of this rule.

getName

public java.lang.String getName()
Returns the name of this rule.
Returns:
the name of this rule.

getPriority

public int getPriority()
Returns the priority of this rule.
Returns:
the priority of this rule.

getTable

public SymbolicTable getTable()
Returns the symbolic table to be used in this rule.
Returns:
the symbolic table to be used in this rule.

hashCode

public int hashCode()
Returns a code used to store this rule in a hashtable.
Overrides:
hashCode in class java.lang.Object
Returns:
a hashcode for this rule.

isFireable

public boolean isFireable()
Checks whether the preconditions of this rule are (all) true. When this method is called, the symbolic table must be correctly filled.
Returns:
true if the rule can be fired; false otherwise.
See Also:
isFireable(int)

isFireable

public boolean isFireable(int linha)
Checks whether the preconditions in a given line of this rule are (all) true. When this method is called, the symbolic table must be correctly filled for the declarations of lines prior to the given one.
Returns:
true if the premisses in that line are true'; false otherwise.
See Also:
isFireable()