You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by ge...@apache.org on 2002/03/25 01:47:30 UTC

cvs commit: jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node ASTEQNode.java ASTGENode.java ASTGTNode.java ASTLENode.java ASTLTNode.java

geirm       02/03/24 16:47:30

  Modified:    src/java/org/apache/velocity/runtime/parser/node
                        ASTEQNode.java ASTGENode.java ASTGTNode.java
                        ASTLENode.java ASTLTNode.java
  Log:
  Fixes for 7396 - there is no reason why we shouldn't be able to do
  
    #set($foo = ( 3 == 3 ))
  
  there is now real downside - we allow any other kind of expression...
  
  Revision  Changes    Path
  1.9       +10 -1     jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTEQNode.java
  
  Index: ASTEQNode.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTEQNode.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ASTEQNode.java	7 Aug 2001 21:56:30 -0000	1.8
  +++ ASTEQNode.java	25 Mar 2002 00:47:30 -0000	1.9
  @@ -67,7 +67,7 @@
    *  This operator requires that the LHS and RHS are both of the
    *  same Class.
    *
  - *  @version $Id: ASTEQNode.java,v 1.8 2001/08/07 21:56:30 geirm Exp $
  + *  @version $Id: ASTEQNode.java,v 1.9 2002/03/25 00:47:30 geirm Exp $
    */
   public class ASTEQNode extends SimpleNode
   {
  @@ -149,4 +149,13 @@
   
           return false;    
       }
  +
  +    public Object value(InternalContextAdapter context)
  +        throws MethodInvocationException
  +    {
  +        boolean val = evaluate(context);
  +
  +        return val ? Boolean.TRUE : Boolean.FALSE;
  +    }
  +
   }
  
  
  
  1.9       +9 -0      jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTGENode.java
  
  Index: ASTGENode.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTGENode.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ASTGENode.java	7 Aug 2001 21:56:30 -0000	1.8
  +++ ASTGENode.java	25 Mar 2002 00:47:30 -0000	1.9
  @@ -122,4 +122,13 @@
           return ( (Integer) left).intValue() >=  ((Integer) right).intValue(); 
        
       }
  +
  +    public Object value(InternalContextAdapter context)
  +        throws MethodInvocationException
  +    {
  +        boolean val = evaluate(context);
  +
  +        return val ? Boolean.TRUE : Boolean.FALSE;
  +    }
  +
   }
  
  
  
  1.8       +9 -0      jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTGTNode.java
  
  Index: ASTGTNode.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTGTNode.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ASTGTNode.java	7 Aug 2001 21:56:30 -0000	1.7
  +++ ASTGTNode.java	25 Mar 2002 00:47:30 -0000	1.8
  @@ -122,4 +122,13 @@
   
           return ((Integer) left).intValue() > ((Integer) right).intValue();
       }
  +
  +    public Object value(InternalContextAdapter context)
  +        throws MethodInvocationException
  +    {
  +        boolean val = evaluate(context);
  +
  +        return val ? Boolean.TRUE : Boolean.FALSE;
  +    }
  +
   }
  
  
  
  1.8       +9 -0      jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTLENode.java
  
  Index: ASTLENode.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTLENode.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ASTLENode.java	7 Aug 2001 21:56:30 -0000	1.7
  +++ ASTLENode.java	25 Mar 2002 00:47:30 -0000	1.8
  @@ -122,4 +122,13 @@
   
           return ((Integer) left).intValue() <=  ((Integer) right).intValue();
       }
  +
  +    public Object value(InternalContextAdapter context)
  +        throws MethodInvocationException
  +    {
  +        boolean val = evaluate(context);
  +
  +        return val ? Boolean.TRUE : Boolean.FALSE;
  +    }
  +
   }
  
  
  
  1.8       +9 -0      jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTLTNode.java
  
  Index: ASTLTNode.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTLTNode.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ASTLTNode.java	7 Aug 2001 21:56:30 -0000	1.7
  +++ ASTLTNode.java	25 Mar 2002 00:47:30 -0000	1.8
  @@ -122,4 +122,13 @@
   
           return ((Integer) left).intValue() < ((Integer) right).intValue();
       }
  +
  +    public Object value(InternalContextAdapter context)
  +        throws MethodInvocationException
  +    {
  +        boolean val = evaluate(context);
  +
  +        return val ? Boolean.TRUE : Boolean.FALSE;
  +    }
  +
   }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node ASTEQNode.java ASTGENode.java ASTGTNode.java ASTLENode.java ASTLTNode.java

Posted by Jon Scott Stevens <jo...@latchkey.com>.
on 3/24/02 4:47 PM, "geirm@apache.org" <ge...@apache.org> wrote:

> Fixes for 7396 - there is no reason why we shouldn't be able to do
> 
>   #set($foo = ( 3 == 3 ))
> 
> there is now real downside - we allow any other kind of expression...
> 

I'm not sure I like the ability to do the above.

Heading into Perl land now...

-jon


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node ASTEQNode.java ASTGENode.java ASTGTNode.java ASTLENode.java ASTLTNode.java

Posted by Daniel Rall <dl...@finemaltcoding.com>.
"Geir Magnusson Jr." <ge...@earthlink.net> writes:

> On 3/24/02 7:59 PM, "Jon Scott Stevens" <jo...@latchkey.com> wrote:
>
>> on 3/24/02 4:47 PM, "geirm@apache.org" <ge...@apache.org> wrote:
>> 
>>>   #set($foo = ( 3 == 3 ))
>>> 
>> 
>> What happens with something convoluted like:
>> 
>> #set($foo = ($bar.A == true))
>> 
>> ?
>> Or
>> 
>> #set ($foo = ("#macr("joe")" == $bar.B))
>> 
>> Yucky.
>> 
>
> Yep - you can make yucky things with this.
>
> However, what you would have to do otherwise is
>
> #set($foo = false)
>
> #if("#macr('joe')" == $bar.B)
>   #set($foo = true)
> #end
>
> Which I think in some ways is yecchier - the one line set makes it clear
> what you are doing, I think, in a lot faster, more readablt way.

I much prefer one line sets when evaluating a boolean expression.
It's lean and mean.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node ASTEQNode.java ASTGENode.java ASTGTNode.java ASTLENode.java ASTLTNode.java

Posted by "Geir Magnusson Jr." <ge...@earthlink.net>.
On 3/24/02 7:59 PM, "Jon Scott Stevens" <jo...@latchkey.com> wrote:

> on 3/24/02 4:47 PM, "geirm@apache.org" <ge...@apache.org> wrote:
> 
>>   #set($foo = ( 3 == 3 ))
>> 
> 
> What happens with something convoluted like:
> 
> #set($foo = ($bar.A == true))
> 
> ?
> Or
> 
> #set ($foo = ("#macr("joe")" == $bar.B))
> 
> Yucky.
> 

Yep - you can make yucky things with this.

However, what you would have to do otherwise is

#set($foo = false)

#if("#macr('joe')" == $bar.B)
  #set($foo = true)
#end

Which I think in some ways is yecchier - the one line set makes it clear
what you are doing, I think, in a lot faster, more readablt way.

geir
-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety." - Benjamin Franklin



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node ASTEQNode.java ASTGENode.java ASTGTNode.java ASTLENode.java ASTLTNode.java

Posted by Jon Scott Stevens <jo...@latchkey.com>.
on 3/24/02 5:09 PM, "Geir Magnusson Jr." <ge...@earthlink.net>
wrote:

> Can I please get some *#Q#( bandwidth here in SF???
> 
> :)

Stop by studioz... :-)

The wireless has been installed...

-jon


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node ASTEQNode.java ASTGENode.java ASTGTNode.java ASTLENode.java ASTLTNode.java

Posted by "Geir Magnusson Jr." <ge...@earthlink.net>.
On 3/24/02 7:59 PM, "Jon Scott Stevens" <jo...@latchkey.com> wrote:

> on 3/24/02 4:47 PM, "geirm@apache.org" <ge...@apache.org> wrote:
> 
>>   #set($foo = ( 3 == 3 ))
>> 
> 
> What happens with something convoluted like:
> 
> #set($foo = ($bar.A == true))
> 
> ?
> Or
> 
> #set ($foo = ("#macr("joe")" == $bar.B))
> 
> Yucky.
> 
> -jon

Can I please get some *#Q#( bandwidth here in SF???

:)

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety." - Benjamin Franklin



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node ASTEQNode.java ASTGENode.java ASTGTNode.java ASTLENode.java ASTLTNode.java

Posted by Jon Scott Stevens <jo...@latchkey.com>.
on 3/24/02 4:47 PM, "geirm@apache.org" <ge...@apache.org> wrote:

>   #set($foo = ( 3 == 3 ))
> 

What happens with something convoluted like:

#set($foo = ($bar.A == true))

?
Or

#set ($foo = ("#macr("joe")" == $bar.B))

Yucky.

-jon


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>