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 |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
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
Foreach
public Foreach()
getName
public java.lang.String getName()
- Return name of this directive.
- Overrides:
getName
in class Directive
getType
public int getType()
- Return type of this directive.
- Overrides:
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
render
public boolean render(InternalContextAdapter context,
java.io.Writer writer,
Node node)
throws java.io.IOException,
MethodInvocationException,
ResourceNotFoundException,
ParseErrorException
- renders the #foreach() block
- Overrides:
render
in class Directive
Copyright © 2002 Apache Software Foundation. All Rights Reserved.