public class Foreach extends Directive
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
elementKey
The reference name used to access each
of the elements in the list object.
|
private int |
maxNbrLoops
The maximum number of times we're allowed to loop.
|
private boolean |
skipInvalidIterator
Whether or not to throw an Exception if the iterator is null.
|
protected Info |
uberInfo
immutable, so create in init
|
BLOCK, LINE
Constructor and Description |
---|
Foreach() |
Modifier and Type | Method and Description |
---|---|
void |
checkArgs(java.util.ArrayList<java.lang.Integer> argtypes,
Token t,
java.lang.String templateName)
We do not allow a word token in any other arg position except for the 2nd since
we are looking for the pattern #foreach($foo in $bar).
|
protected void |
clean(InternalContextAdapter context,
java.lang.Object o) |
protected java.util.Iterator |
getIterator(java.lang.Object iterable,
Node node)
Retrieve the contextual iterator.
|
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
|
protected void |
put(InternalContextAdapter context,
java.lang.String key,
java.lang.Object value)
Extension hook to allow subclasses to control whether loop vars
are set locally or not.
|
boolean |
render(InternalContextAdapter context,
java.io.Writer writer,
Node node)
renders the #foreach() block
|
protected void |
renderBlock(InternalContextAdapter context,
java.io.Writer writer,
Node block) |
getColumn, getLine, getScopeName, getTemplate, getTemplateName, isScopeProvided, makeScope, postRender, preRender, setLocation, setLocation
private int maxNbrLoops
private boolean skipInvalidIterator
private java.lang.String elementKey
protected Info uberInfo
public java.lang.String getName()
public int getType()
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException
init
in class Directive
rs
- context
- node
- TemplateInitException
protected void put(InternalContextAdapter context, java.lang.String key, java.lang.Object value)
context
- key
- value
- protected java.util.Iterator getIterator(java.lang.Object iterable, Node node)
iterable
- node
- public boolean render(InternalContextAdapter context, java.io.Writer writer, Node node) throws java.io.IOException
protected void renderBlock(InternalContextAdapter context, java.io.Writer writer, Node block) throws java.io.IOException
java.io.IOException
protected void clean(InternalContextAdapter context, java.lang.Object o)
public void checkArgs(java.util.ArrayList<java.lang.Integer> argtypes, Token t, java.lang.String templateName) throws ParseException
checkArgs
in class Directive
argtypes
- type, Array of argument types of each argument to the directive
for example ParserTreeConstants.JJTWORDt
- token of directivetemplateName
- the name of the template this directive is referenced in.ParseException