Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ru.dizpers.core;
- import org.apache.commons.jexl2.JexlContext;
- import org.apache.commons.jexl2.JexlContext;
- import org.apache.commons.jexl2.JexlEngine;
- import org.apache.commons.jexl2.JexlException;
- import org.apache.commons.jexl2.parser.ASTBitwiseXorNode;
- public class Interpreter extends org.apache.commons.jexl2.Interpreter {
- public Interpreter(JexlEngine jexl, JexlContext aContext) {
- super(jexl, aContext);
- }
- @Override
- public Object visit(ASTBitwiseXorNode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
- int n = 0;
- // coerce these two values longs and 'xor'.
- try {
- long l = arithmetic.toLong(left);
- n = 1;
- long r = arithmetic.toLong(right);
- return Double.valueOf(Math.pow(l, r));
- } catch (RuntimeException xrt) {
- throw new JexlException(node.jjtGetChild(n), "long coercion error", xrt);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment