[prev in list] [next in list] [prev in thread] [next in thread]
List: velocity-user
Subject: Re: Following up on key / value loops and Map.Entry
From: "Geir Magnusson Jr." <geirm () optonline ! net>
Date: 2001-05-25 12:50:08
[Download RAW message or body]
"Henning P. Schmiedehausen" wrote:
>
> Hi,
>
> some weeks ago, someone asked about loops over Hashtables in
> Templates:
>
> foreach( $entry in $table )
> My $entry is $table.get($entry)
> #end
>
> with $table being a Hashtable or a HashMap. But "$entry" loops over
> the values, not over the keys. And there is no "value -> key" lookup
> method.
>
First, to just solve the problem, why not iterate over the keyset?
#foreach($key in $hashtable.keySet() )
key = $key value = $hashtable.get($key)
#end
:)
> One of the proposed ways to do this was a posting which suggested
> using the Map.Entry interface which should make the following thing
> possible:
>
> [SNIP]
> I was wondering, whether it is possible to recognize such situations.
> [SNIP]
> I was also asking myself, whether this could be a bug in the JDK. What
> sense makes the current behaviour?
>
> Regards
> Henning
>
No, you are right on - the problem is due to the fact that we are
'method-centric' in our introspection, and we need to address the public
interfaces on default, protected or private-scope classes.
I was working on a general solution, not just localized to the
PropertyExecutor, for this problem. I even had it in the HEAD CVS until
I realized how wrong it was :) and decided to put it off until after
the 1.1 release. Look for it then.
geir
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
Developing for the web? See http://jakarta.apache.org/velocity/
"still climbing up to the shoulders..."
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic