commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geir Magnusson Jr <g...@4quarters.com>
Subject Re: [Jexl] String concatination
Date Wed, 17 Dec 2003 12:50:07 GMT
Intresting.  This is not what the JSP EL does.  Not that we really  
care, but it's an interesting extension.  It follows Java, I suppose :)

Patch in - lets see what people think.

geir

On Dec 15, 2003, at 8:55 PM, Robert wrote:

> Attached is a patch for the ASTAddNode class that will do a string  
> concat if the coercion to a double and long fails.
>
> Thanks!
> Robert McIntosh
> Index: ASTAddNode.java
> ===================================================================
> RCS file:  
> /home/cvspublic/jakarta-commons/jexl/src/java/org/apache/commons/jexl/ 
> parser/ASTAddNode.java,v
> retrieving revision 1.2
> diff -u -r1.2 ASTAddNode.java
> --- ASTAddNode.java	17 May 2002 12:13:22 -0000	1.2
> +++ ASTAddNode.java	16 Dec 2003 01:47:01 -0000
> @@ -119,12 +119,18 @@
>          }
>
>          /*
> -         * otherwise to longs with thee!
> +         * attempt to use Longs
>           */
> -
> -        Long l = Coercion.coerceLong(left);
> -        Long r = Coercion.coerceLong(right);
> -
> -        return new Long(l.longValue() + r.longValue());
> +        try {
> +            Long l = Coercion.coerceLong(left);
> +            Long r = Coercion.coerceLong(right);
> +            return new Long(l.longValue() + r.longValue());
> +        }
> +        catch( java.lang.NumberFormatException nfe ) {
> +            /*
> +             * Well, use strings!
> +             */
> +            return left.toString().concat( right.toString() );
> +        }
>      }
>  }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
-- 
Geir Magnusson Jr                                   203-247-1713(m)
geir@4quarters.com


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