commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject cvs commit: jakarta-commons/jexl/src/java/org/apache/commons/jexl/parser ASTSubtractNode.java
Date Wed, 25 Jun 2003 10:49:48 GMT
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


Mime
View raw message