jeff wrote:
>
> Rather than going overboard trying to second guess the userbase, have
> interfaces like these ever been considered?
No! :)
> public interface VelocityMap
> {
> void set(Object key, Object value);
> Object get(Object key);
> VelocityIterator keys();
> }
>
> public interface VelocityIterator extends Iterator
> {
> void reset();
> }
Actually, we talked about the VelIterator thing about 4 messages back in
this thread, mostly as exploration.
> These cover the two basic kinds of access used by Velocity. VelocityMap is
> simpler to implement than java.util.Map and VelocityIterator contains the
> one piece of functionality lacking in the real Iterator.
I think supporting Map is easy in Vel, because we can just dig out an
Iterator. If that's a pain to work with in ones own classes, a simple
Object[] is also supported, so there always is an easy way out.
> Of course, this still won't be as convenient for debugging as being able to
> toss Iterator and Enumeration directly into a #foreach, but it is simple,
> consistent and easy to understand.
Iterator is currently in there with a warning generated in the log and a
warning and discussion in th docs. We can do the same with
Enumeration. I wonder if that will be enough of a compromise : the
warning helps people figure out what went 'wrong' w/o <gasp> having to
read the documentation, and supporting Iterator and Enumeration *does*
make Velocity more useful for people who don't really have a choice.
geir
--
Geir Magnusson Jr. [EMAIL PROTECTED]
Velocity : it's not just a good idea. It should be the law.
http://jakarta.apache.org/velocity