• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

EL - What is 'empty'

 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Saloon Keeper
Posts: 24315
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Saloon Keeper
Posts: 24315
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic