Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 9763 invoked from network); 4 Jan 2004 04:36:37 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 4 Jan 2004 04:36:37 -0000 Received: (qmail 28015 invoked by uid 500); 4 Jan 2004 04:36:16 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 27965 invoked by uid 500); 4 Jan 2004 04:36:16 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 27954 invoked by uid 500); 4 Jan 2004 04:36:16 -0000 Delivered-To: apmail-cocoon-2.1-cvs@apache.org Received: (qmail 27951 invoked from network); 4 Jan 2004 04:36:16 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 4 Jan 2004 04:36:16 -0000 Received: (qmail 9736 invoked by uid 1342); 4 Jan 2004 04:36:35 -0000 Date: 4 Jan 2004 04:36:35 -0000 Message-ID: <20040104043635.9735.qmail@minotaur.apache.org> From: vgritsenko@apache.org To: cocoon-2.1-cvs@apache.org Subject: cvs commit: cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/validationruleimpl RangeValidationRule.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N vgritsenko 2004/01/03 20:36:35 Modified: src/blocks/woody/java/org/apache/cocoon/woody/datatype/validationruleimpl RangeValidationRule.java Log: Add support for Double and Float to this profane hack :-) Revision Changes Path 1.6 +8 -1 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/validationruleimpl/RangeValidationRule.java Index: RangeValidationRule.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/validationruleimpl/RangeValidationRule.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- RangeValidationRule.java 30 Dec 2003 20:22:08 -0000 1.5 +++ RangeValidationRule.java 4 Jan 2004 04:36:35 -0000 1.6 @@ -60,7 +60,9 @@ import org.outerj.expression.ExpressionContext; /** - * Checks numeric ranges. Works for Integer, Long and BigDecimal values. + * Checks numeric ranges. + * Works for Integer, Long, BigDecimal, Float, Double, and Date values. + * Numbers are converted to the BigDecimal before comparing. * *

This validation rule can perform 3 different checks: *

    @@ -87,11 +89,16 @@ } public ValidationError validate(Object value, ExpressionContext expressionContext) { + // HACK: JDK's Comparable can't even compare Decimal to Integer Comparable decimal; if (value instanceof Integer) { decimal = new BigDecimal(((Integer) value).intValue()); } else if (value instanceof Long) { decimal = new BigDecimal(((Long) value).longValue()); + } else if (value instanceof Float) { + decimal = new BigDecimal(((Float) value).floatValue()); + } else if (value instanceof Double) { + decimal = new BigDecimal(((Double) value).doubleValue()); } else { decimal = (Comparable) value; }