0

I use JEXL3 to convert user input as string to a math function, I would like to use ^ as Math.pow() so I read about extending JexlArithemtic to override bitwiseXor like here: http://apache-commons.680414.n4.nabble.com/JEXL-Evaluating-math-expression-td4112606.html

This example is for Jexl2 and I use Jexl3, if I try to override:

class JexlArithmeticWithPow(lenient: Boolean) : JexlArithmetic(lenient) {

    override fun bitwiseXor(left: Any, right: Any): Any { //bitwiseXor is final and cannot be overriden
        val l = toDouble(left)
        val r = toDouble(right)
        return Math.pow(l, r)
    }

}

Is there another possibility to convert ^to Math.pow instead of bitwiseXor?

binaryBigInt
  • 1,526
  • 2
  • 18
  • 44

1 Answers1

0

In JEXL3, the JexlArithmetic method bitwiseXor has been deprecated (and made final); replacement method is public Object xor(Object left, Object right);. Note that with JEXL3, you may want to only add an overload to that method for numbers, ie public Object xor(Number left, Number right);.

henrib
  • 187
  • 6