#set ($x = $y)
or #if ($x) y #end.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | DirectiveNode.BreakNode
A node in the parse tree representing a |
| pack-priv static class | DirectiveNode.DefineNode
A node in the parse tree representing a |
| pack-priv static class | DirectiveNode.ForEachNode
A node in the parse tree representing a |
| pack-priv static class | DirectiveNode.IfNode
A node in the parse tree representing an |
| pack-priv static class | DirectiveNode.MacroCallNode
A node in the parse tree representing a macro call. |
| pack-priv static class | DirectiveNode.SetNode
A node in the parse tree representing a |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| DirectiveNode | back to summary |
|---|---|
| pack-priv DirectiveNode(String resourceName, int lineNumber) | |
#break directive. The directive has an optional
scope argument, so you can write #break($foreach) to break from the nearest
#foreach loop. That is in fact the only scope we support, so we just have a boolean
that indicates if it is present. Otherwise we break from the nearest #foreach or
#parse or from the whole template.
| Modifier and Type | Field and Description |
|---|---|
| private final ExpressionNode |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | render(EvaluationContext context, StringBuilder output)
Implements abstract com. output.
|
| scope | back to summary |
|---|---|
| private final ExpressionNode scope | |
| BreakNode | back to summary |
|---|---|
| pack-priv BreakNode(String resourceName, int lineNumber, ExpressionNode scope) | |
| render | back to summary |
|---|---|
| pack-priv void render(EvaluationContext context, StringBuilder output) Implements abstract com. Doc from com. Adds this node's contribution to the
| |
#define construct. Evaluating
#define ($x) foo $bar #end will set $x to the given sequence of nodes. It does
not produce any text in the output.
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | render(EvaluationContext context, StringBuilder output)
Implements abstract com. output.
|
| body | back to summary |
|---|---|
| private final Node body | |
| var | back to summary |
|---|---|
| private final String var | |
| DefineNode | back to summary |
|---|---|
| pack-priv DefineNode(String var, Node body) | |
| render | back to summary |
|---|---|
| pack-priv void render(EvaluationContext context, StringBuilder output) Implements abstract com. Doc from com. Adds this node's contribution to the
| |
#foreach construct. While evaluating
#foreach ($x in $things), {$code $x} will be set to each element of $things in
turn. Once the loop completes, $x will go back to whatever value it had before, which
might be undefined. During loop execution, the variable $foreach is also defined.
Velocity defines a number of properties in this variable, but here we only support
$foreach.hasNext and $foreach.index.
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private static class | DirectiveNode.ForEachNode.ForEachVar
This class is the type of the variable |
| Modifier and Type | Field and Description |
|---|---|
| private final Node | |
| private final ExpressionNode | |
| private final String |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | render(EvaluationContext context, StringBuilder output)
Implements abstract com. output.
|
| body | back to summary |
|---|---|
| private final Node body | |
| collection | back to summary |
|---|---|
| private final ExpressionNode collection | |
| var | back to summary |
|---|---|
| private final String var | |
| ForEachNode | back to summary |
|---|---|
| pack-priv ForEachNode(String resourceName, int lineNumber, String var, ExpressionNode in, Node body) | |
| render | back to summary |
|---|---|
| pack-priv void render(EvaluationContext context, StringBuilder output) Implements abstract com. Doc from com. Adds this node's contribution to the
| |
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private final Iterator |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| pack-priv int | |
| public Object |
| index | back to summary |
|---|---|
| private int index | |
| iterator | back to summary |
|---|---|
| private final Iterator<?> iterator | |
| CountingIterator | back to summary |
|---|---|
| pack-priv CountingIterator(Iterator<?> iterator) | |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| index | back to summary |
|---|---|
| pack-priv int index() | |
| next | back to summary |
|---|---|
| public Object next() Implements java. Doc from java. Returns the next element in the iteration. | |
$foreach that is defined within
#foreach loops. Its getHasNext() method means that we can write
#if ($foreach.hasNext) and likewise for getIndex() etc.
| Modifier and Type | Field and Description |
|---|---|
| private final DirectiveNode. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public int | |
| public boolean | |
| public boolean | |
| public int | |
| public boolean | |
| public String |
| iterator | back to summary |
|---|---|
| private final DirectiveNode. | |
| ForEachVar | back to summary |
|---|---|
| pack-priv ForEachVar(DirectiveNode. | |
| getCount | back to summary |
|---|---|
| public int getCount() | |
| getFirst | back to summary |
|---|---|
| public boolean getFirst() | |
| getHasNext | back to summary |
|---|---|
| public boolean getHasNext() | |
| getIndex | back to summary |
|---|---|
| public int getIndex() | |
| getLast | back to summary |
|---|---|
| public boolean getLast() | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
#if construct. All instances of this class
have a true subtree and a false subtree. For a plain #if (cond) body
#end, the false subtree will be empty. For #if (cond1) body1 #elseif (cond2) body2
#else body3 #end, the false subtree will contain a nested IfNode, as if #else
#if had been used instead of #elseif.
| Modifier and Type | Field and Description |
|---|---|
| private final ExpressionNode | |
| private final Node | |
| private final Node |
| Access | Constructor and Description |
|---|---|
| pack-priv | IfNode(String resourceName, int lineNumber, ExpressionNode condition, Node trueNode, Node falseNode)
|
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | render(EvaluationContext context, StringBuilder output)
Implements abstract com. output.
|
| condition | back to summary |
|---|---|
| private final ExpressionNode condition | |
| falsePart | back to summary |
|---|---|
| private final Node falsePart | |
| truePart | back to summary |
|---|---|
| private final Node truePart | |
| IfNode | back to summary |
|---|---|
| pack-priv IfNode(String resourceName, int lineNumber, ExpressionNode condition, Node trueNode, Node falseNode) | |
| render | back to summary |
|---|---|
| pack-priv void render(EvaluationContext context, StringBuilder output) Implements abstract com. Doc from com. Adds this node's contribution to the
| |
#macro (mymacro $x $y) ... #end, then a call of that macro looks like
#mymacro (xvalue yvalue). The call is represented by an instance of this class. The
definition itself does not appear in the parse tree.
Evaluating a macro involves temporarily setting the parameter variables ($x $y in
the example) to thunks representing the argument expressions, evaluating the macro body, and
restoring any previous values that the parameter variables had.
| Modifier and Type | Field and Description |
|---|---|
| private final Node | |
| private final String | |
| private final ImmutableList |
| Access | Constructor and Description |
|---|---|
| pack-priv | MacroCallNode(String resourceName, int lineNumber, String name, ImmutableList<ExpressionNode> argumentNodes, Node bodyContent)
|
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | render(EvaluationContext context, StringBuilder output)
Implements abstract com. output.
|
| bodyContent | back to summary |
|---|---|
| private final Node bodyContent | |
| name | back to summary |
|---|---|
| private final String name | |
| thunks | back to summary |
|---|---|
| private final ImmutableList<ExpressionNode> thunks | |
| MacroCallNode | back to summary |
|---|---|
| pack-priv MacroCallNode(String resourceName, int lineNumber, String name, ImmutableList<ExpressionNode> argumentNodes, Node bodyContent) | |
| render | back to summary |
|---|---|
| pack-priv void render(EvaluationContext context, StringBuilder output) Implements abstract com. Doc from com. Adds this node's contribution to the
| |
#set construct. Evaluating
#set ($x = 23) will set $x to the value 23. It does not in itself produce
any text in the output.
Velocity supports setting values within arrays or collections, with for example
$set ($x[$i] = $y). That is not currently supported here.
| Modifier and Type | Field and Description |
|---|---|
| private final ExpressionNode | |
| private final String |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | render(EvaluationContext context, StringBuilder output)
Implements abstract com. output.
|
| expression | back to summary |
|---|---|
| private final ExpressionNode expression | |
| var | back to summary |
|---|---|
| private final String var | |
| SetNode | back to summary |
|---|---|
| pack-priv SetNode(String var, ExpressionNode expression) | |
| render | back to summary |
|---|---|
| pack-priv void render(EvaluationContext context, StringBuilder output) Implements abstract com. Doc from com. Adds this node's contribution to the
| |