/** * Finds the node causing a NPE for diadic operators. * @param xrt the RuntimeException * @param node the parent node * @param left the left argument * @param right the right argument * @return the left, right or parent node */ protected JexlNode findNullOperand(RuntimeException xrt, JexlNode node, Object left, Object right) { if (xrt instanceof ArithmeticException && JexlException.NULL_OPERAND == xrt.getMessage()) { if (left == null) { return node.jjtGetChild(0); } if (right == null) { return node.jjtGetChild(1); } } return node; }
/** * Resolves a namespace, eventually allocating an instance using context as constructor argument. * The lifetime of such instances span the current expression or script evaluation. * * @param prefix the prefix name (may be null for global namespace) * @param node the AST node * @return the namespace instance */ protected Object resolveNamespace(String prefix, JexlNode node) { Object namespace = null;
/** * Interpret the given script/expression. * <p> * If the underlying JEXL engine is silent, errors will be logged through its logger as info. * </p> * @param node the script or expression to interpret. * @return the result of the interpretation. * @throws JexlException if any error occurs during interpretation. */ public Object interpret(JexlNode node) { try { return node.jjtAccept(this, null); } catch (JexlException.Return xreturn) { Object value = xreturn.getValue(); return value; } catch (JexlException xjexl) { if (silent) { logger.warn(xjexl.getMessage(), xjexl.getCause()); return null; } throw xjexl; } readonlyly { functors = null; parameters = null; registers = null; } }