commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wer...@apache.org
Subject cvs commit: jakarta-commons/jexl/src/java/org/apache/commons/jexl/parser ASTGTNode.java ASTLTNode.java
Date Thu, 06 Mar 2003 21:34:33 GMT
werken      2003/03/06 13:34:33

  Modified:    jexl/src/java/org/apache/commons/jexl/parser ASTGTNode.java
                        ASTLTNode.java
  Log:
  jexl seems to enjoy producing java.lang.Long from multiplicative
  expressions, but integral constants are java.lang.Integer.
  
  jexl would only compare an Integer to an Integer for the GT/LT
  operators and would throw an exception if one of the operands
  was an Integer and one was a Long.  This seemed to be an uneeded
  restriction.  So, if either are Long or Integer, the comparison
  is made from the resulting longValue() from either to avoid
  trimming and to allow comparision between different bitsized
  integral values.
  
  Revision  Changes    Path
  1.2       +8 -4      jakarta-commons/jexl/src/java/org/apache/commons/jexl/parser/ASTGTNode.java
  
  Index: ASTGTNode.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jexl/src/java/org/apache/commons/jexl/parser/ASTGTNode.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ASTGTNode.java	26 Apr 2002 04:23:14 -0000	1.1
  +++ ASTGTNode.java	6 Mar 2003 21:34:32 -0000	1.2
  @@ -94,11 +94,15 @@
               throw new Exception("Null comparison : GT ");
           }
   
  -        if (left instanceof Integer && right instanceof Integer)
  +        if ( (left instanceof Integer || left instanceof Long)
  +             && (right instanceof Integer || right instanceof Long) )
           {
  -            int val = ((Integer) left).compareTo((Integer)right);
  +            long leftLong = ((Number)left).longValue();
  +            long rightLong = ((Number)right).longValue();
   
  -            return new Boolean(val > 0);
  +            return ( ( leftLong > rightLong  )
  +                     ? Boolean.TRUE
  +                     : Boolean.FALSE );
           }
   
           throw new Exception("Invalid comparison : GT ");
  
  
  
  1.2       +8 -4      jakarta-commons/jexl/src/java/org/apache/commons/jexl/parser/ASTLTNode.java
  
  Index: ASTLTNode.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jexl/src/java/org/apache/commons/jexl/parser/ASTLTNode.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ASTLTNode.java	26 Apr 2002 04:23:14 -0000	1.1
  +++ ASTLTNode.java	6 Mar 2003 21:34:32 -0000	1.2
  @@ -95,11 +95,15 @@
               throw new Exception("Null comparison : LT ");
           }
   
  -        if (left instanceof Integer && right instanceof Integer)
  +        if ( (left instanceof Integer || left instanceof Long) 
  +             && ( right instanceof Integer || right instanceof Long) )
           {
  -            int val = ((Integer) left).compareTo((Integer)right);
  +            long leftLong = ((Number)left).longValue();
  +            long rightLong = ((Number)right).longValue();
   
  -            return new Boolean(val < 0);
  +            return ( ( leftLong < rightLong )
  +                     ? Boolean.TRUE
  +                     : Boolean.FALSE );
           }
   
           throw new Exception("Invalid comparison : LT ");
  
  
  

---------------------------------------------------------------------
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