-
Notifications
You must be signed in to change notification settings - Fork 0
7) Usings Maps:
pranithcodes edited this page Apr 6, 2018
·
1 revision
public static void main(String[] args) {
Map<String, String> hashMap = new HashMap<String, String>();
JexlContext context = new MapContext();
context.set("map", hashMap);
JexlEngine jexl = new JexlBuilder().create();
JexlExpression e = jexl.createExpression("map.put(\"name\",\"JEXL TUTORIAL\")");
e.evaluate(context);
System.out.println("The value that is evaluated by jexl::\t" + hashMap.get("name"));
}
In the above example, we have took a simple HashMap(hashMap) and put it into jexlContext as “map”. Then jexlExpression “map.put("name","JEXL TUTORIAL")” will set the Key-value into hashMap. So, after evalution, the instance of hashMap is not empty.
Output: The value that is evaluated by jexl:: JEXL TUTORIAL