Questions tagged [jexl]

JEXL is a library intended to facilitate the implementation of dynamic and scripting features in applications and frameworks written in Java.

JEXL is a library intended to facilitate the implementation of dynamic and scripting features in applications and frameworks written in Java.

From the official documentation:

JEXL implements an Expression Language based on some extensions to the JSTL Expression Language supporting most of the constructs seen in shell-script or ECMAScript. Its goal is to expose scripting features usable by technical operatives or consultants working with enterprise platforms.

The library exposes a small footprint API - the core features fit in 3 classes and 10 methods - that can be used in various conditions:

  • Scripting features:
    • Your application lets (advanced) users evaluate or define some simple expressions like computation formulas.
  • Module or component configuration:
    • Your application has configuration files (eventually generated by a design module) consumed by the end-user module that would benefit from variables and expressions.
    • When it would be convenient to use IOC but overall complexity doesn't require (or can't depend upon) a full-blown library (Spring, Guice...).
  • Loose-coupling of interfaces and implementations or duck-typing:
    • You have optional classes that your code cant consider as compilation dependencies.
    • You have to integrate and call "legacy" code or use components that you don't want to strongly depend upon.
  • Simple template capabilities:
    • Your application has basic template requirements and JSPs or Velocity would be overkill or too inconvenient to deploy.

JEXL name stands for Java EXpression Language, a simple expression language originally inspired by Apache Velocity and the Expression Language defined in the JavaServer Pages Standard Tag Library version 1.1 (JSTL) and JavaServer Pages version 2.0 (JSP). JEXL 2.0 added features inspired by Unified EL. The syntax is now close to a mix of ECMAScript and "shell-script" making it easy to master by technical operatives or consultants. The objects exposed and their behavior obviously need to be documented though...

The API and the expression language exploit Java-beans naming patterns through introspection to expose property getters and setters. It also considers public class fields as properties and allows to invoke any accessible method.

JEXL attempts to bring some of the lessons learned by the Velocity community about expression languages in templating to a wider audience. Commons Jelly needed Velocity-ish method access, it just had to have it.

It must be noted that JEXL is not a compatible implementation of EL as defined in JSTL 1.1 (JSR-052) or JSP 2.0 (JSR-152). For a compatible implementation of these specifications, see the Commons EL project.

79 questions
0
votes
1 answer

how to set {} to map instead of set in Apache JEXL syntax

I know that {} means set and {:} means map in JEXL. And [] mean array[] and [...] means ArrayList in JEXL. But I want to change {} from set to map and [] from array to arraylist. How to do this? Thanks
ishua
  • 1
  • 1
0
votes
1 answer

Jexl expression string with stream, map and collect is throwing org.apache.commons.jexl3.JexlException$Parsing Exception

I have a method evaluateExpression present in a different library and that library is using Jexl3 for evaluating expressionString passed to evaluateExpression method. inputMap contains the object that is used for evaluating the expressionString on.…
Gowtham Kesa
  • 99
  • 2
  • 18
0
votes
1 answer

Override assigns & IN operator behaviour in JEXL3

I am trying to Override assign operator(=) in JEXL3 with equals functionality to make it support SQL like statements to support below statement: WHERE A=B And SQL like IN operator support in JEXL3 so that it should support below…
100rabh
  • 6,156
  • 5
  • 27
  • 41
0
votes
1 answer

How to access varname when the RHS value resolution set(varname, rhs) encounters a runtime exception, in Apache JEXL3?

For the following a statement in a jexl script, routeX = Telemat.locate(map, vehicle, newLatLong); With that JEXL in the following order goes on to resolve Telemat.locate(map, vehicle, newLatLong). inquire the has('routeX'), so that my Java code…
Blessed Geek
  • 21,058
  • 23
  • 106
  • 176
0
votes
1 answer

JEXL how to replace dot with a custom separator

I'm using JEXL to evalute a String as below: 'GroupName'.'ProductName'.'item'.'fields'.'duration' where GroupName and ProductName are String variables while the rest are fixed strings. I built a context as: Map>…
Enzo
  • 35
  • 2
  • 8
0
votes
1 answer

JEXL: How to customize property accessors

I've got data objects, which you could think of as a "simplified map". There are methods get(String), and put(String,Object), but that's basically it. Now, I'd like to use JEXL to evaluate complex expressions on my data objects. I can do so by…
user1774051
  • 843
  • 1
  • 6
  • 18
0
votes
1 answer

Java compatible simple expression language

I am building a system in Scala for feature engineering where the end user API receives aggregations on list of objects/events. For example, a client of this tool might pass into it a function that given an array of past pageviews for a specific…
0
votes
1 answer

Where does JEXL store local vars and by what mechanism are local vars assigned?

Apache JEXL script engine invokes the setter method of the context to consummate an assignment made in script. The context I supply would take over to store the assignment. a = mylib.hello(); What is the equivalent of a context when a local var is…
Blessed Geek
  • 21,058
  • 23
  • 106
  • 176
0
votes
1 answer

How to set Jetty to use non-strict evaluation mode in Jexl?

We're trying to move a website built mostly from JSPs from Websphere to Jetty. We're having a problem with NullPointerException evaluating EL code in test attributes: The problem is that the…
DavidW
  • 1,413
  • 10
  • 17
0
votes
1 answer

How to Escape a While Controller after 10 Minutes

I've created a While Controller in Apache JMeter that I want to run for 10 minutes or until an exit condition is met. However the following function doesn't work. ${__jexl3( ("${start}" + 600000) > "${__time()}" || "${exit}" )} I'm new to…
Stackosaurus
  • 33
  • 1
  • 8
0
votes
2 answers

Get expression values in JEXL

Having the following JEXL expression: String expression = "myVar >= 12345 && mySecondVar <= 56789"; I can call createScript and getVariables to get myVar and mySecondVar as values, such as: Set> expressionVars =…
Manuel S.
  • 411
  • 8
  • 21
0
votes
0 answers

Boolean short circuit

Jexl already supports boolean short circuiting Expression = A || B if A = True, B doesn't have to be set. However if A = False and B is not set, the evaluation throws JexlException exception - undefined variable B. The use case is to lazily evaluate…
0
votes
1 answer

How to Evaluate the Java syntax using Apache JEXL

I tried to use JEXL to evaluate the syntax but not getting through. Want your help guys to get it executed. I want to evaluate dynamic replace statement (.replace("\u00A0","")) coming through ajax. In Java - removeSpecialChars =…
Sks
  • 612
  • 7
  • 23
0
votes
1 answer

JXLS Transformer object is not getting initialized

I am trying to use JXLS with my custom evaluator for Excel downloads, following this official page. I have no clue why is it not providing me Transformer object. Trying to figure out from exceptions since a long time but unable to resolve…
Pratik
  • 908
  • 2
  • 11
  • 34
0
votes
2 answers

How to use Array in JEXL?

Using JEXL, I am trying to initialize array and than adding elements into it, however below code gives me 'unsolvable property '0' error. var abc=[]; abc[0]=5; 1) How can I initialize empty array and keep adding values in it? 2) Can I use it like…
Pratik
  • 908
  • 2
  • 11
  • 34