mauda.plugin
Class KBFormulaEvaluator

java.lang.Object
  extended by mauda.plugin.KBFormulaEvaluator
Direct Known Subclasses:
FibHeapKBFormulaEvaluator

public class KBFormulaEvaluator
extends java.lang.Object

Evaluator for formulas from Knowledge-Bases. Every PlugIn must have a class, who extends this class.

Author:
Markus Krebs

Field Summary
 java.lang.String filledFormula
          Contains the currently filled Formula.
 
Constructor Summary
KBFormulaEvaluator(Exercise exercise)
          Creates a KBFormulaEvaluator
 
Method Summary
 boolean evaluate(java.lang.String formula)
          Evaluates a delivered formula
 boolean evaluateFilledFormula(java.lang.String formula)
          Evaluates a comletely filled formula.
 java.lang.String getConstant(java.lang.String c)
          Gets the value of constant.
 java.lang.String getSpecialConstant(java.lang.String sc)
          Gets a plugin-specific constant like:
subop[current].param2.pre.isroot
This expression cannot completely evaluated by this evaluator, because he understands pre.isroot not.
 boolean isFinishOperationState()
          Gets the finish-operation-state
 void setFinishOperationState(boolean b)
          Sets following state for the FormulaEvaluator:
The student wants to process the next Operation, because he thinks the current is complete.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filledFormula

public java.lang.String filledFormula
Contains the currently filled Formula. (for debugging-purposes)

Constructor Detail

KBFormulaEvaluator

public KBFormulaEvaluator(Exercise exercise)
Creates a KBFormulaEvaluator

Parameters:
exercise - Exercise
Method Detail

setFinishOperationState

public void setFinishOperationState(boolean b)
Sets following state for the FormulaEvaluator:
The student wants to process the next Operation, because he thinks the current is complete. E.g.: He has pressed "Finish Operation...".
In this case the knowledge-base have to proof for missing suboperations, which is a special-state of the Formula- Evaluator.
Internally that means, that following variables in the formulas are set:

Parameters:
b - true if want to switch in finish-operation-state, false otherwise

isFinishOperationState

public boolean isFinishOperationState()
Gets the finish-operation-state

Returns:
true if in finish-operation-state, false otherwise

evaluate

public boolean evaluate(java.lang.String formula)
Evaluates a delivered formula

Parameters:
formula - Formual to evaluate
Returns:
true if formula is true, false otherwise

getConstant

public java.lang.String getConstant(java.lang.String c)
Gets the value of constant.
E.g.: subop[current].id can be evaluated to cut.

Parameters:
c - the constant
Returns:
evaluated constant

getSpecialConstant

public java.lang.String getSpecialConstant(java.lang.String sc)
Gets a plugin-specific constant like:
subop[current].param2.pre.isroot
This expression cannot completely evaluated by this evaluator, because he understands pre.isroot not. Therefore the expression subop[current].param2 will be evaluated by this evaluator e.g. in 2, and then 2[5].pre.isroot will be transmitted to the plugin-specific evaluatore, who can evaluate this formula in e.g. TRUE. The number in brackets is needed to identify from which data-structure in the history the information should retrieved.

Parameters:
sc - constant
Returns:
evaluated constant

evaluateFilledFormula

public boolean evaluateFilledFormula(java.lang.String formula)
Evaluates a comletely filled formula. E.g.: TRUE AND NOT TRUE AND NOT newfheapmeld = cut

Parameters:
formula - Filled formula
Returns:
true if formula is true, false otherwise