You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by js...@apache.org on 2002/06/04 20:34:34 UTC

cvs commit: jakarta-commons-sandbox/jelly build.xml

jstrachan    2002/06/04 11:34:33

  Modified:    jelly/src/java/org/apache/commons/jelly/tags/core
                        ForEachTag.java
               jelly    build.xml
  Log:
  Patched the <forEach> tag to properly handle the being and step attributes to miss out items in the collection.
  
  Revision  Changes    Path
  1.11      +20 -6     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ForEachTag.java
  
  Index: ForEachTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ForEachTag.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ForEachTag.java	21 May 2002 07:59:33 -0000	1.10
  +++ ForEachTag.java	4 Jun 2002 18:34:33 -0000	1.11
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ForEachTag.java,v 1.10 2002/05/21 07:59:33 jstrachan Exp $
  - * $Revision: 1.10 $
  - * $Date: 2002/05/21 07:59:33 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ForEachTag.java,v 1.11 2002/06/04 18:34:33 jstrachan Exp $
  + * $Revision: 1.11 $
  + * $Date: 2002/06/04 18:34:33 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: ForEachTag.java,v 1.10 2002/05/21 07:59:33 jstrachan Exp $
  + * $Id: ForEachTag.java,v 1.11 2002/06/04 18:34:33 jstrachan Exp $
    */
   
   package org.apache.commons.jelly.tags.core;
  @@ -80,7 +80,7 @@
   /** A tag which performs an iteration over the results of an XPath expression
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.10 $
  +  * @version $Revision: 1.11 $
     */
   public class ForEachTag extends TagSupport {
   
  @@ -132,7 +132,12 @@
                   log.debug("Iterating through: " + iter);
               }
   
  -            for (index = begin; iter.hasNext() && index < end; index += step) {
  +            // ignore the first items of the iterator
  +            for (index = 0; index < begin && iter.hasNext(); index++ ) {
  +                iter.next();
  +            }
  +            
  +            while (iter.hasNext() && index < end) {
                   Object value = iter.next();
                   if (var != null) {
                       context.setVariable(var, value);
  @@ -141,6 +146,15 @@
                       context.setVariable(indexVar, new Integer(index));
                   }
                   getBody().run(context, output);
  +                
  +                // now we need to move to next index
  +                index++;
  +                for ( int i = 1; i < step; i++, index++ ) {
  +                    if ( ! iter.hasNext() ) {
  +                       return;
  +                    }
  +                    iter.next();
  +                }
               }
           }
           else {
  
  
  
  1.35      +2 -0      jakarta-commons-sandbox/jelly/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/build.xml,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- build.xml	2 Jun 2002 18:00:38 -0000	1.34
  +++ build.xml	4 Jun 2002 18:34:33 -0000	1.35
  @@ -185,6 +185,8 @@
   	  <path id="test.classpath">
   	    <pathelement path="${maven.build.dest}"/>
           <path refid="maven.dependency.classpath"/>
  +        <pathelement location="${lib.repo}/xmlParserAPIs-2.0.0.jar"/>
  +        <pathelement location="${lib.repo}/xercesImpl-2.0.0.jar"/>
   	  </path>
   	  
         <taskdef
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>