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

Spring annotation to create a jexl2.Expression

I’m trying to understand a piece of Spring code that I need to adapt. I have: The corresponding class has a…
Yves
  • 21
  • 1
  • 4
0
votes
1 answer

JEXL3 - Unabled to override bitwiseXor in JexlArithemtic?

I use JEXL3 to convert user input as string to a math function, I would like to use ^ as Math.pow() so I read about extending JexlArithemtic to override bitwiseXor like here:…
binaryBigInt
  • 1,526
  • 2
  • 18
  • 44
0
votes
1 answer

JEXL3 - euler function

Is it possible to parse functions with an e (as the euler function) in it? Such as: x*e I get undefined variable e with this: var jexl = JexlBuilder().create() var jexlEpxression = jexl.createExpression("x*e") //still works var jexlContext =…
binaryBigInt
  • 1,526
  • 2
  • 18
  • 44
0
votes
1 answer

Use different quotation mark when evaluating a string using JEXL

The Requirement is to use JEXL to evaluate a java method from a file with a string parameter as below: object.method("argument"); But, sometimes my String argument is written with different quotation marks: object.method(«argument»); According to…
GaspardP
  • 880
  • 1
  • 12
  • 24
0
votes
1 answer

Multiple if statement in jexl

I have been trying to come up with a custom validation that would check for all three cases below and return error message based on the condition that is met. These validations work separately, can someone plese help on how to make the system move…
Maxrev
  • 11
  • 2
0
votes
1 answer

Does JEXL API work in Scala?

Assuming that foo.method() can be call in a Jexl expression on java, is this possible to happen using the same api in Scala.
Lengoman
  • 904
  • 2
  • 12
  • 22
0
votes
1 answer

How can I create a template for a string?

So basically I have a list of java objects that need to be written into a text file with a specific format. eg. class car { String license; String color; String model; String numOfSeats; } and this has to be written into a text…
Fazil Hussain
  • 425
  • 3
  • 16
0
votes
1 answer

Jexl3 unsolvable property exception when using enum

This code used to work under jexl2 public enum Gender { MALE, FEMALE}; public static void main( String[] args ) throws ClassNotFoundException { JexlEngine jexl = new JexlEngine(); Record r = new Record(); r.setHeader(new…
biliboc
  • 737
  • 1
  • 10
  • 25
0
votes
1 answer

Enabling additional tests in JMeter reduces number of samples

I have a JMeter Test Plan with many copies of almost exactly the same test. In each case there is a variable that is slightly different. Here is the configuration: There are two sets of user variables. There is a top level user variable list,…
snowe
  • 1,312
  • 1
  • 20
  • 41
0
votes
1 answer

org.apache.commons.jexl2.JexlArithmetic: bitwiseXor in JEXL sandbox

I'm working in a native JEXL sandbox, so there is no need of expression e = jexl.createExpression Actually I am able to get this working: foo = new ("org.apache.commons.jexl2.JexlArithmetic", false); tmp = foo.multiply("123","123"); with those…
0
votes
1 answer

JXLS not writing the processed JEXL

Following the example on their site, http://jxls.sourceforge.net/getting_started.html. I came across a problem when trying to write the processed file. Instead of writing data that should be replaced by the JEXL, it simply just writes the template…
Muhatashim
  • 646
  • 8
  • 22
0
votes
1 answer

Android Could not find class 'org.apache.commons.scxml.env.jexl.JexlContext'

I'm using apache commons SCXML to define a state machine my Android app. In my Android Studio project, I've added the following in the dependencies section of my build.gradle file: compile 'commons-scxml:commons-scxml:0.9' compile…
skunkwerk
  • 2,920
  • 2
  • 37
  • 55
0
votes
1 answer

JEXL2.1.1 Script is not throwing exceptions

I'm trying to execute a function dynamically using JEXL 2.1.1 and a Script. The function is defined by me and it throws a custom error. It seems like JEXL catches the exception, but does not propagate it, only shows it. I really need to know when…
Anakin001
  • 1,226
  • 2
  • 14
  • 30
0
votes
1 answer

Jett, poi, jexl. Cannot transform my document

I'm trying to transform my workbook with Jett like this: HashMap tm = new HashMap(); tm.put("mod", "123"); ExcelTransformer t = new ExcelTransformer(); t.transform(wb, tm); In the document there is a cell with such…
Pavel
  • 53
  • 8
0
votes
1 answer

hooks during parsing of an expression

I have a requirement to parse and evaluate user defined expressions. The expressions are of the form "foo > 50 && bar < 60 && !(moo > 50))" During parsing, there is a need to monitor value for foo > 50, bar < 60 and !(moo > 50) and generate events…
kvhdude
  • 1
  • 1
  • 1