Foreach (Velocity 1.4 API)
Keywords: org.apache.velocity.runtime.directive.Foreach class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.velocity.runtime.directive
Class Foreach

    java.lang.Object
      org.apache.velocity.runtime.directive.Directive
          org.apache.velocity.runtime.directive.Foreach

All Implemented Interfaces:
  java.lang.Cloneable, DirectiveConstants

public class Foreach
extends Directive

Foreach directive used for moving through arrays, or objects that provide an Iterator.

Version:
  $Id: Foreach.java,v 1.42.4.1 2004/03/03 23:22:55 geirm Exp $
Author:
  Jason van Zyl, Geir Magnusson Jr.

Field Summary
`private int` | `counterInitialValue` What value to start the loop counter at.
`private java.lang.String` | `counterName` The name of the variable to use when placing the counter value into the context.
`private java.lang.String` | `elementKey` The reference name used to access each of the elements in the list object.
`protected Info` | `uberInfo` immutable, so create in init

Fields inherited from class org.apache.velocity.runtime.directive.Directive
`rsvc`

Fields inherited from interface org.apache.velocity.runtime.directive.DirectiveConstants
`BLOCK, LINE`

Constructor Summary
`Foreach()`

Method Summary
`java.lang.String` | `getName()` Return name of this directive.
`int` | `getType()` Return type of this directive.
`void` | `init(RuntimeServices rs, InternalContextAdapter context, Node node)` simple init - init the tree and get the elementKey from the AST
`boolean` | `render(InternalContextAdapter context, java.io.Writer writer, Node node)` renders the #foreach() block

Methods inherited from class org.apache.velocity.runtime.directive.Directive
`getColumn, getLine, setLocation`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### counterName

    private java.lang.String counterName

  The name of the variable to use when placing the counter value into the context. Right now the default is $velocityCount.

### counterInitialValue

    private int counterInitialValue

  What value to start the loop counter at.

### elementKey

    private java.lang.String elementKey

  The reference name used to access each of the elements in the list object. It is the $item in the following: #foreach ($item in $list) This can be used class wide because it is immutable.

### uberInfo

    protected Info uberInfo

  immutable, so create in init

Constructor Detail

### Foreach

    public Foreach()

Method Detail

### getName

    public java.lang.String getName()

  Return name of this directive.

  Specified by:
    `getName` in class `Directive`

### getType

    public int getType()

  Return type of this directive.

  Specified by:
    `getType` in class `Directive`

### init

    public void init(RuntimeServices rs,
                     InternalContextAdapter context,
                     Node node)
              throws java.lang.Exception

  simple init - init the tree and get the elementKey from the AST

  Overrides:
    `init` in class `Directive`
  Throws:
    `java.lang.Exception`

### render

    public boolean render(InternalContextAdapter context,
                          java.io.Writer writer,
                          Node node)
                   throws java.io.IOException,
                          MethodInvocationException,
                          ResourceNotFoundException,
                          ParseErrorException

  renders the #foreach() block

  Specified by:
    `render` in class `Directive`
  Throws:
    `java.io.IOException`
    `MethodInvocationException`
    `ResourceNotFoundException`
    `ParseErrorException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002 Apache Software Foundation. All Rights Reserved.