Here you can find the source of evaluateJSExpression(String expr, Context cx, Scriptable scope)
public static boolean evaluateJSExpression(String expr, Context cx, Scriptable scope)
//package com.java2s; //License from project: Open Source License import org.mozilla.javascript.Context; import org.mozilla.javascript.Scriptable; public class Main { public static boolean evaluateJSExpression(String expr, Context cx, Scriptable scope) { boolean evalResult = true; if ((null == expr) || (expr.isEmpty())) { return evalResult; }//from w ww . j ava 2s . c o m try { Object result = cx.evaluateString(scope, expr, "policyExpression", 1, null); if (result != null && Context.toString(result).equals("true")) { evalResult = true; } else { evalResult = false; } } catch (Exception ex) { ex.printStackTrace(); evalResult = false; } return evalResult; } }