You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Digby <li...@digby.net> on 2004/11/03 18:46:53 UTC

[JEXL] Ternary expressions?

Was just wondering if there's any chance JEXL will support ternary 
expressions at some point? It would be nice to have some sort of 
conditional support. (I notice this has been discussed on the dev group.)

/digby


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


Re: [JEXL] Ternary expressions?

Posted by Digby <li...@digby.net>.
Good idea - thanks.


peter royal wrote:
> On Nov 3, 2004, at 12:46 PM, Digby wrote:
> 
>> Was just wondering if there's any chance JEXL will support ternary 
>> expressions at some point? It would be nice to have some sort of 
>> conditional support. (I notice this has been discussed on the dev group.)
> 
> 
> since i needed this and didn't feel like hacking jexl, i throw an item 
> named Helper in my context which is an instance of a class with a method 
> like:
> 
> public Object if( boolean state, Object o1, Object o2 )
> {
>     return state ? o1 : o2;
> }
> 
> then its just ${Helper.if( a > b, a, b )}
> 
> -pete


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


Re: [JEXL] Ternary expressions?

Posted by peter royal <pr...@apache.org>.
On Nov 3, 2004, at 12:46 PM, Digby wrote:
> Was just wondering if there's any chance JEXL will support ternary 
> expressions at some point? It would be nice to have some sort of 
> conditional support. (I notice this has been discussed on the dev 
> group.)

since i needed this and didn't feel like hacking jexl, i throw an item 
named Helper in my context which is an instance of a class with a 
method like:

public Object if( boolean state, Object o1, Object o2 )
{
	return state ? o1 : o2;
}

then its just ${Helper.if( a > b, a, b )}

-pete


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