Use different quotation mark when evaluating a string using JEXL

402 views Asked by At

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 JEXL documentation, I can use simple quote ' or double quote ", but not my french guillemet : https://commons.apache.org/proper/commons-jexl/reference/syntax.html#Literals

One way to do this will be to clean first my file, replacing all different quotation marks and use always the same.

Is there any other possible way to change this behavior?

1

There are 1 answers

0
henrib On BEST ANSWER

You definitely should replace the french guillemets with one of the supported syntax (quote/double-quote). If you absolutely must stick to this (odd) convention and are able/willing to fork/build you own local version of JEXL, you have to change the Javacc grammar to accept this new 'string' syntax. Somewhere around http://svn.apache.org/viewvc/commons/proper/jexl/tags/COMMONS_JEXL_3_1/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt?view=markup#l244