Bug 18816

Summary: org.apache.taglibs.standard.lang.jstl.EmptyOperator.apply(...) bug
Product: Taglibs Reporter: Mike Lissick <mlissick>
Component: Standard TaglibAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: 1.0.2   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: treats Collections instead of Lists or Maps

Description Mike Lissick 2003-04-08 14:58:56 UTC
The EmptyOperator doesn't work for all objects implementing Collection as the 
specification requires.  The apply(...) method only checks null, empty String, 
zero-length array, empty List or empty Map.  Therefore, it doesn't work on a 
Set.  Looking at the code, it appears that the Map and List specific logic 
could be replaced with Collection-specific logic, which would then support Set.

This is also true of v 1.0.3 according to the source code I downloaded minutes 
ago (today is 4/8/2003).

If you have any questions regardinging this, don't hesitate to contact me at 
mlissick@yahoo.com

Best Regards,
Mike Lissick
Comment 1 gregory_lardiere 2003-07-01 07:47:14 UTC
Created attachment 7035 [details]
treats Collections instead of Lists or Maps
Comment 2 Pierre Delisle 2003-08-02 02:03:15 UTC
JSTL 1.0 specifies the following:

A.3.8 Empty Operator - empty A
The empty operator is a prefix operator that can be used to determine if a value is
null or empty.
To evaluate empty A
- If A is null, return true,
- Otherwise, if A is the empty string, then return true.
- Otherwise, if A is an empty array, then return true.
- Otherwise, if A is an empty Map, return true
- Otherwise, if A is an empty List, return true,
- Otherwise return false.

Unfortunately, the case where A is a Collection was left out in 1.0.

However, this has been fixed in the JSP 2.0 spec (which now owns the EL),
and is therefore available with JSTL 1.1.

PROPOSED FINAL DRAFT 3
JSP.2.3.7 Empty Operator - empty A
The empty operator is a prefix operator that can be used to determine if a value
is null or empty.
To evaluate empty A
EXPRESSION LANGUAGE 1-72
- If A is null, return true,
- Otherwise, if A is the empty string, then return true.
- Otherwise, if A is an empty array, then return true.
- Otherwise, if A is an empty Map, return true,
- Otherwise, if A is an empty Collection, return true,
- Otherwise return false.