You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ge...@apache.org on 2003/06/25 12:49:48 UTC

cvs commit: jakarta-commons/jexl/src/java/org/apache/commons/jexl/parser ASTSubtractNode.java

geirm       2003/06/25 03:49:48

  Modified:    jexl/src/java/org/apache/commons/jexl/parser
                        ASTSubtractNode.java
  Log:
  Mark Wilkinson's patch (hack!) to the sub node - we really need to fix
  this another way - prollie in the introspector
  
  Revision  Changes    Path
  1.3       +21 -3     jakarta-commons/jexl/src/java/org/apache/commons/jexl/parser/ASTSubtractNode.java
  
  Index: ASTSubtractNode.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jexl/src/java/org/apache/commons/jexl/parser/ASTSubtractNode.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ASTSubtractNode.java	17 May 2002 12:13:22 -0000	1.2
  +++ ASTSubtractNode.java	25 Jun 2003 10:49:48 -0000	1.3
  @@ -61,6 +61,7 @@
    *  Subtraction
    *
    *  @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
  + *  @author <a href="mailto:mhw@kremvax.net">Mark H. Wilkinson</a>
    *  @version $Id$
    */
   public class ASTSubtractNode extends SimpleNode
  @@ -118,9 +119,26 @@
           Long l = Coercion.coerceLong(left);
           Long r = Coercion.coerceLong(right);
   
  -        return new Long(l.longValue() - r.longValue());
  +        /*
  +         *  TODO - this is actually wrong - JSTL says to return a Long
  +         *  but we have problems where you have something like 
  +         * 
  +         *     foo.bar( a - b )
  +         * 
  +         *  where bar wants an int... 
  +         * 
  +         */
  +        long v = l.longValue() - r.longValue();
   
  -    }
  +        if ( left instanceof Integer && right instanceof Integer )
  +        {
  +            return new Integer((int) v);
  +        }
  +        else
  +        {
  +            return new Long(v);
  +        }
  +     }
       /** Accept the visitor. **/
       public Object jjtAccept(ParserVisitor visitor, Object data)
       {
  
  
  

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


Re: cvs commit: jakarta-commons/jexl/src/java/org/apache/commons/jexl/parser ASTSubtractNode.java

Posted by Peter Royal <pr...@apache.org>.
On Wednesday, June 25, 2003, at 06:49  AM, geirm@apache.org wrote:
> geirm       2003/06/25 03:49:48
>
>   Modified:    jexl/src/java/org/apache/commons/jexl/parser
>                         ASTSubtractNode.java
>   Log:
>   Mark Wilkinson's patch (hack!) to the sub node - we really need to 
> fix
>   this another way - prollie in the introspector
>
>   +        /*
>   +         *  TODO - this is actually wrong - JSTL says to return a 
> Long
>   +         *  but we have problems where you have something like
>   +         *
>   +         *     foo.bar( a - b )
>   +         *
>   +         *  where bar wants an int...
>   +         *
>   +         */

A "proper" way to fix this would be to do coercion when passing 
arguments to method calls, right?
-pete


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