Example usage for org.apache.commons.math3.exception MathRuntimeException getMessage

List of usage examples for org.apache.commons.math3.exception MathRuntimeException getMessage

Introduction

In this page you can find the example usage for org.apache.commons.math3.exception MathRuntimeException getMessage.

Prototype

@Override
public String getMessage() 

Source Link

Usage

From source file:org.matheclipse.commons.parser.util.Console.java

/**
 * Evaluates the given string-expression and returns the result in string
 * form./* w w w .  ja v  a2s.co m*/
 * 
 * @param strEval
 * @return the result in string for
 */
public String interpreter(final String strEval) {
    try {
        if (fComplexEvaluatorMode) {
            ComplexEvaluator engine = new ComplexEvaluator(true);
            Parser p = new Parser(engine.isRelaxedSyntax());
            ASTNode obj = p.parse(strEval);
            if (obj instanceof FunctionNode) {
                obj = engine.optimizeFunction((FunctionNode) obj);
            }
            Complex c = engine.evaluateNode(obj);
            return ComplexEvaluator.toString(c);
        } else {
            DoubleEvaluator engine = new DoubleEvaluator(true);
            double d = engine.evaluate(strEval);
            return Double.toString(d);
        }
    } catch (MathRuntimeException e) {
        System.err.println();
        System.err.println(e.getMessage());
    } catch (RuntimeException e) {
        e.printStackTrace();
    }
    return "";
}