I am using the following code to execute the statements
NashornSandbox sandbox = NashornSandboxes.create();
String input = "(20>=10 && 19<=20 || 33>30 ) && 233>30";
try {
// Evaluate the logical expression
Object result = sandbox.eval(input);
if (result instanceof Boolean) {
boolean booleanResult = (boolean) result;
System.out.println("Result: " + booleanResult);
} else {
System.out.println("Invalid expression: Result is not a boolean");
}
} catch (ScriptException e) {
System.out.println("Invalid expression: " + e.getMessage());
}
how to only allow execute logic expressions and prevent while,for,exist and everything else.