jexl

How to connect two numeric string in jexl?

纵饮孤独 提交于 2021-02-07 21:56:08
问题 For example: @Test public void test2() { JexlEngine jexl = new JexlEngine(); jexl.setLenient(false); jexl.setSilent(false); JexlContext jc = new MapContext(); Expression exp = jexl.createExpression("\"1\"+\"1\""); System.out.println(exp.evaluate(jc)); } actual result is: 2 my expected result is: "11" Please tell me what's wrong in the above example. And how can I get my expected result. Thanks! 回答1: Taking a look at http://svn.apache.org/viewvc/commons/proper/jexl/tags/COMMONS_JEXL_2_1_1/src

How to connect two numeric string in jexl?

浪尽此生 提交于 2021-02-07 21:55:21
问题 For example: @Test public void test2() { JexlEngine jexl = new JexlEngine(); jexl.setLenient(false); jexl.setSilent(false); JexlContext jc = new MapContext(); Expression exp = jexl.createExpression("\"1\"+\"1\""); System.out.println(exp.evaluate(jc)); } actual result is: 2 my expected result is: "11" Please tell me what's wrong in the above example. And how can I get my expected result. Thanks! 回答1: Taking a look at http://svn.apache.org/viewvc/commons/proper/jexl/tags/COMMONS_JEXL_2_1_1/src

Operator overloading/definition for custom classes in Jexl3

浪尽此生 提交于 2021-01-27 20:04:51
问题 I am trying to implement a custom class that should behave like Boolean in Jexl expressions: Example: Object result = jexl.createExpression("a || b").evaluate(context) Where a and b are instances of a custom class that contains an boolean and extra information that should be carried through the evaluated expresssion so that it can be accessed in the end in result . I have read that Jexl3 should support operator overloading and it seems to have all the necessary structures for defining own

Can't create JexlEngine object

依然范特西╮ 提交于 2019-12-23 03:03:12
问题 I write the following class: import org.apache.commons.jexl2.*; public class NelderMead { // контсанты private static int M = 3; private static double E = 0.005; private static double A = 1.000; private static double B = 0.500; private static double Y = 2.000; // переменные private JexlEngine jexl = new JexlEngine(); private Expression func; private String funcString = ""; private MapContext[] iterations; public NelderMead(){ this.jexl = new JexlEngine(); } public NelderMead(String funcString

Catch exception thrown by custom function in JEXL

允我心安 提交于 2019-12-12 01:23:11
问题 I added some functions to the JEXL engine wich can be used in the JEXL expressions: Map<String, Object> functions = new HashMap<String, Object>(); mFunctions = new ConstraintFunctions(); functions.put(null, mFunctions); mEngine.setFunctions(functions); However, some functions can throw exceptions, for example: public String chosen(String questionId) throws NoAnswerException { Question<?> question = mQuestionMap.get(questionId); SingleSelectAnswer<?> answer = (SingleSelectAnswer<?>) question

Does anyone have any simple JEXL examples using a loop. I am looking to iterate around a simple Array to output various string values?

匆匆过客 提交于 2019-12-10 23:35:36
问题 Does anyone have any simple JEXL examples using a loop. I am looking to iterate around a simple object arraylist to output various string values? 回答1: A full example with input for 452' is here : public static void testSimpleList() { List<String> list = new ArrayList<String>(); list.add("one"); list.add("two"); JexlContext jexlContext = new MapContext(); jexlContext.set("list", list);; Map<String, Object> functions1 = new HashMap<String, Object>(); functions1.put("system", System.out);

Can't create JexlEngine object

回眸只為那壹抹淺笑 提交于 2019-12-06 16:27:51
I write the following class: import org.apache.commons.jexl2.*; public class NelderMead { // контсанты private static int M = 3; private static double E = 0.005; private static double A = 1.000; private static double B = 0.500; private static double Y = 2.000; // переменные private JexlEngine jexl = new JexlEngine(); private Expression func; private String funcString = ""; private MapContext[] iterations; public NelderMead(){ this.jexl = new JexlEngine(); } public NelderMead(String funcString){ this.jexl = new JexlEngine(); this.setFunc(funcString); } public void setFunc(String funcString){

How do you create a secure JEXL (scripting) sandbox?

天涯浪子 提交于 2019-12-01 05:47:33
I'm creating a sandbox for JEXL scripts to execute in so that a malicious user can't access data outside the variables we give them access to and also can't perform a DOS attack on the server. I'd like to document this for anybody else also doing this and also get other people's input into the approach. The following is a list of the things I'm aware of that needs to be addressed: Only allow instantiating classes using 'new' that are on a whitelist. Do not allow accessing the getClass method on any class because then forName can be called and any class can be accessed. Restrict access to

How do you create a secure JEXL (scripting) sandbox?

巧了我就是萌 提交于 2019-12-01 02:07:34
问题 I'm creating a sandbox for JEXL scripts to execute in so that a malicious user can't access data outside the variables we give them access to and also can't perform a DOS attack on the server. I'd like to document this for anybody else also doing this and also get other people's input into the approach. The following is a list of the things I'm aware of that needs to be addressed: Only allow instantiating classes using 'new' that are on a whitelist. Do not allow accessing the getClass method