I've noticed the same.

- mike

> -----Original Message-----
> From: Mark R. Diggory [mailto:[EMAIL PROTECTED]
> Sent: Friday, February 28, 2003 1:51 PM
> To: Jakarta Commons Developers List
> Subject: Re: [JAXL & JELLY] size() behavior question
> 
> On a related size() note: I've been noticing the following problem.
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <jelly xmlns="jelly:core">
>      <new var="test" className="java.util.ArrayList"/>
>      <new var="foo" className="java.lang.String"/>
>      ${test.add(foo)}
> 
>      <!-- this works -->
>      ${size(test)}
> 
>      <!-- this doesn't work -->
>      <!-- ${test.size()} -->
> </jelly>
> 
> Seems that ${test.size()} is a legitimate method call on a ListArray
> object like ${test.add(foo)} but doesn't work because size() is being
> reserved for the ${size(test)} function. Couldn't there be a "check"
to
> see if the size() method is actually supported by the object before
> rejecting it?
> 
> I get the problem:
> 
> Feb 28, 2003 1:34:56 PM org.apache.commons.logging.impl.Jdk14Logger
error
> SEVERE: Caught exception: org.apache.commons.jelly.JellyException:
> null:-1:-1: <
> null> Encountered ". size" at line 1, column 5.
> Was expecting one of:
>      "||" ...
>      "or" ...
>      "&&" ...
>      "and" ...
>      "|" ...
>      "^" ...
>      "&" ...
>      "==" ...
>      "eq" ...
> 
> -Mark Diggory
> 
> Stanley,Michael P. wrote:
> > Hi all,
> >
> > I have question about the current behavior of the size() test (and a
> > related question to Jelly).
> >
> > I was attempting to verify if a property was set.  There are a
number of
> > ways to do this, but I'm more concerned with the concept than the
> > problem.
> >
> > Usually when checking to see if something is set (like a String or a
> > List) you do the following -
> >
> >          (var == null || var.length() == 0)
> >
> > This would prevent null pointers, and would also check against the
empty
> > case.  From my understanding size() was introduced in JEXL to
provide a
> > common way to detect if it is empty, whether a String or Collection.
> >
> >          (size(var))
> >
> > Ok, consider the same null pointer check now ->
> >
> >          (var == null || size(var))
> >
> > In this case if var is null this test will through an exception.  I
> > think that it should either be consistent with the var == null ||
> > var.length() pattern or there should a nullSafeSize() test.
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]



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

Reply via email to