public class Foreach extends Directive
Modifier and Type | Field and Description |
---|---|
protected Info |
uberInfo
immutable, so create in init
|
BLOCK, LINE
Constructor and Description |
---|
Foreach() |
Modifier and Type | Method and Description |
---|---|
void |
checkArgs(ArrayList<Integer> argtypes,
Token t,
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,
Object o) |
protected Iterator |
getIterator(Object iterable,
Node node)
Retrieve the contextual iterator.
|
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,
String key,
Object value)
Extension hook to allow subclasses to control whether loop vars
are set locally or not.
|
boolean |
render(InternalContextAdapter context,
Writer writer,
Node node)
renders the #foreach() block
|
protected void |
renderBlock(InternalContextAdapter context,
Writer writer,
Node block) |
getColumn, getLine, getScopeName, getTemplate, getTemplateName, isScopeProvided, makeScope, postRender, preRender, setLocation, setLocation
protected Info uberInfo
public 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, String key, Object value)
protected Iterator getIterator(Object iterable, Node node)
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException
render
in class Directive
context
- writer
- node
- IOException
protected void renderBlock(InternalContextAdapter context, Writer writer, Node block) throws IOException
IOException
protected void clean(InternalContextAdapter context, Object o)
public void checkArgs(ArrayList<Integer> argtypes, Token t, 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
Copyright © 2000–2017 The Apache Software Foundation. All rights reserved.