You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Brent Johnson <bl...@gmail.com> on 2004/08/05 23:55:14 UTC

Exception with HashSet.size() in JXTemplate

I'm getting the following exception when I try to get the size of a HashSet.

org.apache.cocoon.ProcessingException: Failed to execute pipeline.:
file:/home/www/wedge/webapps/client/private/blocks/actions/examine.jx:48:59:java.lang.Exception:
size() : unknown type : class java.util.HashSet

I can run a <jx:forEach> on the HashSet and it works fine, but when I
try and get the size I get an error.  Here's what I'm doing to get the
error:  ${item.getAttributes().size()}

item.getAttributes() returns a HashSet with 2 items in it.

Thanks,

- Brent

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Exception with HashSet.size() in JXTemplate

Posted by Brent Johnson <bl...@gmail.com>.
No problem - I was using size() to test if it was zero anyways.  I
just switched to using the isEmpty() method and it works fine.

Thanks,

- Brent

On Tue, 10 Aug 2004 17:40:42 +0200, Leszek Gawron <lg...@mobilebox.pl> wrote:
> 
> 
> Brent Johnson wrote:
> > I'm getting the following exception when I try to get the size of a HashSet.
> >
> > org.apache.cocoon.ProcessingException: Failed to execute pipeline.:
> > file:/home/www/wedge/webapps/client/private/blocks/actions/examine.jx:48:59:java.lang.Exception:
> > size() : unknown type : class java.util.HashSet
> >
> > I can run a <jx:forEach> on the HashSet and it works fine, but when I
> > try and get the size I get an error.  Here's what I'm doing to get the
> > error:  ${item.getAttributes().size()}
> >
> > item.getAttributes() returns a HashSet with 2 items in it.
> This is due to how Jexl treats size function. size is a keyword in jexl
> that can be applied only to types known to jexl itself. Among these:
> - ArrayList
> - List
> and some other. the problem is that there is no java.util.Set there. The
> patch is a 2-liner. Had no time to send a patch though.
> 
> --
> Leszek Gawron                                      lgawron@mobilebox.pl
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Exception with HashSet.size() in JXTemplate

Posted by Leszek Gawron <lg...@mobilebox.pl>.
Brent Johnson wrote:
> I'm getting the following exception when I try to get the size of a HashSet.
> 
> org.apache.cocoon.ProcessingException: Failed to execute pipeline.:
> file:/home/www/wedge/webapps/client/private/blocks/actions/examine.jx:48:59:java.lang.Exception:
> size() : unknown type : class java.util.HashSet
> 
> I can run a <jx:forEach> on the HashSet and it works fine, but when I
> try and get the size I get an error.  Here's what I'm doing to get the
> error:  ${item.getAttributes().size()}
> 
> item.getAttributes() returns a HashSet with 2 items in it.
This is due to how Jexl treats size function. size is a keyword in jexl 
that can be applied only to types known to jexl itself. Among these:
- ArrayList
- List
and some other. the problem is that there is no java.util.Set there. The 
patch is a 2-liner. Had no time to send a patch though.

-- 
Leszek Gawron                                      lgawron@mobilebox.pl

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Exception with HashSet.size() in JXTemplate

Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Aug 5, 2004, at 4:23 PM, Brent Johnson wrote:

> Well - this is in the JXTemplate page not really the flowscript.

sorry, my bad... shoulda read more carefully :-/
~ml


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Exception with HashSet.size() in JXTemplate

Posted by Brent Johnson <bl...@gmail.com>.
Well - this is in the JXTemplate page not really the flowscript.  But
I can access the HashSet using a jx:forEach.  I can also access some
of the other methods like HashSet.isEmpty().  This works fine (returns
false).  But if I try and use the HashSet.size() method I get the
exception.

- Brent

On Thu, 5 Aug 2004 15:33:03 -0700, Mark Lundquist <ml...@wrinkledog.com> wrote:
> 
> On Aug 5, 2004, at 2:55 PM, Brent Johnson wrote:
> 
> > I'm getting the following exception when I try to get the size of a
> > HashSet.
> >
> > org.apache.cocoon.ProcessingException: Failed to execute pipeline.:
> > file:/home/www/wedge/webapps/client/private/blocks/actions/examine.jx:
> > 48:59:java.lang.Exception:
> > size() : unknown type : class java.util.HashSet
> >
> > I can run a <jx:forEach> on the HashSet and it works fine, but when I
> > try and get the size I get an error.  Here's what I'm doing to get the
> > error:  ${item.getAttributes().size()}
> 
> I'm not the flowscript expert, but did you try adding
> 
>         importClass (Packages.java.util.HashSet);
> 
> ???
> ~ml
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Exception with HashSet.size() in JXTemplate

Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Aug 5, 2004, at 2:55 PM, Brent Johnson wrote:

> I'm getting the following exception when I try to get the size of a  
> HashSet.
>
> org.apache.cocoon.ProcessingException: Failed to execute pipeline.:
> file:/home/www/wedge/webapps/client/private/blocks/actions/examine.jx: 
> 48:59:java.lang.Exception:
> size() : unknown type : class java.util.HashSet
>
> I can run a <jx:forEach> on the HashSet and it works fine, but when I
> try and get the size I get an error.  Here's what I'm doing to get the
> error:  ${item.getAttributes().size()}

I'm not the flowscript expert, but did you try adding

	importClass (Packages.java.util.HashSet);

???
~ml


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org