Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EL - What is 'empty'  RSS feed

 
Garrett Smith
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brain dead, recursive definition.
http://www.oracle.com/technology/sample_code/tutorials/jsp20/simpleel.html

" The empty operator is a prefix operation that can be used to determine if a value is null or empty."


Doesn't say whether or no "" is empty, does it?
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Garrett Smith wrote:Brain dead, recursive definition.
http://www.oracle.com/technology/sample_code/tutorials/jsp20/simpleel.html

" The empty operator is a prefix operation that can be used to determine if a value is null or empty."


Doesn't say whether or no "" is empty, does it?


Well, since I've always used the term "empty string" for "", it never gave me any problems.

Of course, there's "empty" strings and then there's blank strings....
 
Kris Schneider
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Garrett Smith wrote:Brain dead, recursive definition.
http://www.oracle.com/technology/sample_code/tutorials/jsp20/simpleel.html

" The empty operator is a prefix operation that can be used to determine if a value is null or empty."


Doesn't say whether or no "" is empty, does it?


For better or worse, that's actually a quote from the JSP 2.0 Spec. (section JSP.2.3.7). However, the spec. also provides some detail to give the definition of "empty" some context:

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 Collection, return true,
• Otherwise return false.

Even with the additional detail, it's still fair to take issue with the "recursive" use of "empty" instead of something like:

To evaluate empty A
• If A is null, return true,
• Otherwise, if A is a String, then return A.length() == 0.
• Otherwise, if A is an array, then return A.length == 0.
• Otherwise, if A is a Map, return A.isEmpty(),
• Otherwise, if A is a Collection, return A.isEmpty(),
• Otherwise return false.
 
Garrett Smith
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kris Schneider wrote:For better or worse, that's actually a quote from the JSP 2.0 Spec. (section JSP.2.3.7). However, the spec. also provides some detail to give the definition of "empty" some context:



Google search results yeilded this thread, a PDF from oracle that crashed Firefox, and a links on jcp.org that resulted in no server response.

Search 1: JSP.2.3.7
Search 2: jsp 2.0 specification

Where can I get the official specification?
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe I'm being dense here, but it seems like people are confusing the definition of the EL "empty" operator (the eponymous operator) and the various criteria for "emptiness", such as being an empty string (no characters), an empty array (no elements), an empty collection (no members).

Question. If the EL operator had been named, say "missing" instead of "empty", given the same rules, would you still consider the definition recursive?
 
Kris Schneider
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Garrett Smith wrote:Google search results yeilded this thread, a PDF from oracle that crashed Firefox, and a links on jcp.org that resulted in no server response.
...
Where can I get the official specification?


There were definitely some problems with jcp.org, but they seem to have been resolved:

JSP 2.0: http://jcp.org/aboutJava/communityprocess/final/jsr152/
 
Garrett Smith
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kris Schneider wrote:
There were definitely some problems with jcp.org, but they seem to have been resolved:

JSP 2.0: http://jcp.org/aboutJava/communityprocess/final/jsr152/


Thanks - that's what I was looking for.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!