You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Purshotam Shah <pu...@yahoo-inc.com.INVALID> on 2015/06/16 01:12:00 UTC

[jexl]Apache JEXL conditional execution path

I am using Apache JEXL for condition expression execution.

My expression can be like

(functionA(string[]) || functionB(string[])) &&  (functionC(string[]) ||  functionD(string[]) )
Each function will return some string. If the function returns empty string, then it consider as false.

At the end I need to have concatenated string and also which path has created the concatenated string.

(functionA(string[]) && functionB(string[])) ||  (functionC(string[]) &&  functionD(string[]) )
If functionA = true, functionB = false, functionC = true, functionD = true Final output should be of concatenated string from functionC and functionD. It should not contain functionA output.

Any suggestion on how to do it?



  

Re: [jexl]Apache JEXL conditional execution path

Posted by henrib <he...@apache.org>.
Hi;
Using version 3.0 trunk and a small syntactic accommodation, it seems you
can code the expected behavior.
The syntax needs to use the '&' and '|' operators rather than '&&' and '||';
the latter are reserved for logical constructs and can not be overridden.
So, define a derived JexlArithmetic to encode or override the
bitwiseAnd/bitwiseOr;  in the example, we consume String parameters.
And define a JexlContext implementation with your methods (aka functionA,
...) in it; the JelxContext is used as the 'unnamed' namespace for
functions.
Overall, the following runs against the 3.0 trunk.
If you are using version 2.0, I dont see a solution.


Hope this fits the bill.
Cheers



--
View this message in context: http://apache-commons.680414.n4.nabble.com/jexl-Apache-JEXL-conditional-execution-path-tp4676367p4676411.html
Sent from the Commons - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org