org.activemath.exercises.openmath
Class OpenMathService

java.lang.Object
  extended by org.activemath.exercises.openmath.OpenMathService
Direct Known Subclasses:
ArithmeticExpressionEvaluator, CasExpressionEvaluator, ExerciseGeneratorTools, FeedbackGenerator, LogicExpressionEvaluator, MathDoxService, OmegaTutorService

public class OpenMathService
extends Object

OpenMathService root class.

Version:
$Revision: 1.21 $ $Date: 2009/10/25 17:57:59 $

Field Summary
protected  String comparatorCD
           
protected  String comparatorName
           
protected  String context
           
protected  ExpressionTransformer expressionTransformer
           
protected static OpenMath om
           
protected static org.jdom.xpath.XPath xpathError
           
protected static org.jdom.xpath.XPath xpathHint
           
protected static org.jdom.xpath.XPath xpathQuit
           
 
Constructor Summary
OpenMathService()
           
 
Method Summary
protected static void abort(String message)
          Abort and display a critical error to the user, by throwing a RuntimeException.
static void console(String[] args, OpenMathService service)
           
 org.jdom.Element evaluate(org.jdom.Element expressionOmobj, Map variables)
          Evaluate the expression, and return its value as the JDom tree of the OpenMath XML with the result.
 boolean evaluateEquivalence(org.jdom.Element a, org.jdom.Element b, Map variables)
          Test whether two expressions are equivalent.
 boolean selectContext(String context)
          Select the evaluation context.
 void setComparator(String cd, String name)
          Set the OpenMath symbol for the comparison operator.
 void setExpressionTransformer(ExpressionTransformer transformer)
          Set the expression transformer applied to the input and/or output of the service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

om

protected static OpenMath om

xpathQuit

protected static final org.jdom.xpath.XPath xpathQuit

xpathHint

protected static final org.jdom.xpath.XPath xpathHint

xpathError

protected static final org.jdom.xpath.XPath xpathError

context

protected String context

comparatorCD

protected String comparatorCD

comparatorName

protected String comparatorName

expressionTransformer

protected ExpressionTransformer expressionTransformer
Constructor Detail

OpenMathService

public OpenMathService()
Method Detail

console

public static void console(String[] args,
                           OpenMathService service)

selectContext

public boolean selectContext(String context)
Select the evaluation context.

Parameters:
contextName - name of the context
Returns:
true if the service can select the requested context, false otherwise

evaluate

public org.jdom.Element evaluate(org.jdom.Element expressionOmobj,
                                 Map variables)
Evaluate the expression, and return its value as the JDom tree of the OpenMath XML with the result.

Returns:
OMOBJ element (with OM namespace) containing the value.

evaluateEquivalence

public boolean evaluateEquivalence(org.jdom.Element a,
                                   org.jdom.Element b,
                                   Map variables)
Test whether two expressions are equivalent.

Returns:
true if the expressions are equivalent, and false otherwise.

setComparator

public void setComparator(String cd,
                          String name)
Set the OpenMath symbol for the comparison operator. If any of the parameters is null, the default comparator is used, which normally means "arith1:minus".

Parameters:
cd - OpenMath Content Dictionary for the comparator symbol.
name - OpenMath symbol name for the comparator symbol.

setExpressionTransformer

public void setExpressionTransformer(ExpressionTransformer transformer)
Set the expression transformer applied to the input and/or output of the service. If this function is not called, or the given transformer is null, no transformation will be done.

Parameters:
transformer - instance of the expression transformer. Can be null.

abort

protected static void abort(String message)
Abort and display a critical error to the user, by throwing a RuntimeException.

Parameters:
message - description of the problem.