There was some talk on taglibs-user about EL "empty" only working with
java.util.Map and java.util.List.  

here's a (simple) patch for jexl that makes ASTEmptyOperator work for all
Collections. 

--------
Tim O'Brien 
Index: src/java/org/apache/commons/jexl/parser/ASTEmptyFunction.java
===================================================================
RCS file: 
/home/cvs/jakarta-commons/jexl/src/java/org/apache/commons/jexl/parser/ASTEmptyFunction.java,v
retrieving revision 1.1
diff -u -r1.1 ASTEmptyFunction.java
--- src/java/org/apache/commons/jexl/parser/ASTEmptyFunction.java       26 Apr 2002 
04:23:14 -0000      1.1
+++ src/java/org/apache/commons/jexl/parser/ASTEmptyFunction.java       13 Feb 2003 
+18:18:22 -0000
@@ -56,13 +56,13 @@
 
 import org.apache.commons.jexl.JexlContext;
 
-import java.util.List;
-import java.util.Map;
+import java.util.Collection;
 
 /**
  *  function to see if reference doesn't exist in context
  *
  *  @author <a href="mailto:[EMAIL PROTECTED]";>Geir Magnusson Jr.</a>
+ *  @author <a href="mailto:[EMAIL PROTECTED]";>Tim O'Brien</a>
  *  @version $Id: ASTEmptyFunction.java,v 1.1 2002/04/26 04:23:14 geirm Exp $
  */
 public class ASTEmptyFunction extends SimpleNode
@@ -107,10 +107,7 @@
             if (o.getClass().isArray() && ((Object[])o).length == 0)
                 return Boolean.TRUE;
 
-            if (o instanceof Map && ((Map)o).isEmpty())
-                return Boolean.TRUE;
-
-            if (o instanceof List && ((List)o).isEmpty())
+            if (o instanceof Collection && ((Collection)o).isEmpty())
                 return Boolean.TRUE;
 
             return Boolean.FALSE;

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to