Return-Path: Delivered-To: apmail-commons-commits-archive@locus.apache.org Received: (qmail 98431 invoked from network); 28 Oct 2007 10:31:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Oct 2007 10:31:02 -0000 Received: (qmail 91260 invoked by uid 500); 28 Oct 2007 10:30:48 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 91163 invoked by uid 500); 28 Oct 2007 10:30:48 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 91154 invoked by uid 99); 28 Oct 2007 10:30:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Oct 2007 03:30:48 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Oct 2007 10:31:04 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D09201A9832; Sun, 28 Oct 2007 03:30:36 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r589324 - in /commons/proper/jexl/branches/2.0/src: java/org/apache/commons/jexl/Interpreter.java test/org/apache/commons/jexl/JexlTest.java Date: Sun, 28 Oct 2007 10:30:32 -0000 To: commits@commons.apache.org From: dion@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071028103036.D09201A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dion Date: Sun Oct 28 03:30:28 2007 New Revision: 589324 URL: http://svn.apache.org/viewvc?rev=589324&view=rev Log: add relation equality operators for big dec and big int JEXL-30 Modified: commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/Interpreter.java commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/JexlTest.java Modified: commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/Interpreter.java URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/Interpreter.java?rev=589324&r1=589323&r2=589324&view=diff ============================================================================== --- commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/Interpreter.java (original) +++ commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/Interpreter.java Sun Oct 28 03:30:28 2007 @@ -1025,6 +1025,8 @@ return false; } else if (left.getClass().equals(right.getClass())) { return left.equals(right); + } else if (left instanceof BigDecimal || right instanceof BigDecimal) { + return Coercion.coerceBigDecimal(left).compareTo(Coercion.coerceBigDecimal(right)) == 0; } else if (isFloatingPointType(left, right)) { Double l = Coercion.coerceDouble(left); Double r = Coercion.coerceDouble(right); @@ -1067,6 +1069,10 @@ double rightDouble = Coercion.coerceDouble(right).doubleValue(); return leftDouble < rightDouble; + } else if (left instanceof BigDecimal || right instanceof BigDecimal) { + BigDecimal l = Coercion.coerceBigDecimal(left); + BigDecimal r = Coercion.coerceBigDecimal(right); + return l.compareTo(r) < 0; } else if (Coercion.isNumberable(left) || Coercion.isNumberable(right)) { long leftLong = Coercion.coerceLong(left).longValue(); long rightLong = Coercion.coerceLong(right).longValue(); Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/JexlTest.java URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/JexlTest.java?rev=589324&r1=589323&r2=589324&view=diff ============================================================================== --- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/JexlTest.java (original) +++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/JexlTest.java Sun Oct 28 03:30:28 2007 @@ -17,6 +17,8 @@ package org.apache.commons.jexl; import java.io.StringReader; +import java.math.BigDecimal; +import java.math.BigInteger; import java.util.ArrayList; import java.util.BitSet; import java.util.Calendar; @@ -115,6 +117,8 @@ jc.getVars().put("now", Calendar.getInstance().getTime()); GregorianCalendar gc = new GregorianCalendar(5000, 11, 20); jc.getVars().put("now2", gc.getTime()); + jc.getVars().put("bdec", new BigDecimal(7)); + jc.getVars().put("bint", new BigInteger("7")); assertExpression(jc, "a == b", Boolean.FALSE); assertExpression(jc, "a==true", Boolean.TRUE); @@ -152,6 +156,15 @@ assertExpression(jc, "\"foo\" + \"bar\" == \"foobar\"", Boolean.TRUE); + assertExpression(jc, "bdec > num", Boolean.TRUE); + assertExpression(jc, "bdec >= num", Boolean.TRUE); + assertExpression(jc, "num <= bdec", Boolean.TRUE); + assertExpression(jc, "num < bdec", Boolean.TRUE); + assertExpression(jc, "bint > num", Boolean.TRUE); + assertExpression(jc, "bint == bdec", Boolean.TRUE); + assertExpression(jc, "bint >= num", Boolean.TRUE); + assertExpression(jc, "num <= bint", Boolean.TRUE); + assertExpression(jc, "num < bint", Boolean.TRUE); } public void testEmpty()