Geir,
> > I would like to be able to #foreach through an Enumeration. Is anyone
> > receptive to this being added to Velocity?
>
> Yep. Should be straightforward. :)
please find attached a new class
org.apache.velocity.util.EnumerationIterator
also, here is a diff for Foreach.java:
diff Foreach.java Foreach.java.old
71d70
< import org.apache.velocity.util.EnumerationIterator;
133,138d131
<
< /**
< * Flag to indicate that the list object being used
< * is an Enumeration.
< */
< private final static int INFO_ENUMERATION = 5;
240,241d232
< else if ( listObject instanceof Enumeration )
< type = INFO_ENUMERATION;
265c256
< case INFO_ITERATOR :
---
> case INFO_ITERATOR :
273d263
< return ( (Iterator) listObject);
275,283c265
< case INFO_ENUMERATION :
< Runtime.warn ("Warning! The reference "
< + node.jjtGetChild(2).getFirstToken().image
< + " is an Enumeration in the #foreach() loop at
["
< + getLine() + "," + getColumn() + "]"
< + " in template " +
context.getCurrentTemplateName()
< + ". If used in more than once, this may lead to
"
< + "unexpected results.");
< return ( new EnumerationIterator( (Enumeration) listObject));
---
> return ( (Iterator) listObject);
EnumerationIterator.java