static class DirectiveNode.IfNode extends DirectiveNode
#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
.DirectiveNode.ForEachNode, DirectiveNode.IfNode, DirectiveNode.MacroCallNode, DirectiveNode.SetNode
Modifier and Type | Field and Description |
---|---|
private ExpressionNode |
condition |
private Node |
falsePart |
private Node |
truePart |
lineNumber
Constructor and Description |
---|
IfNode(int lineNumber,
ExpressionNode condition,
Node trueNode,
Node falseNode) |
Modifier and Type | Method and Description |
---|---|
(package private) java.lang.Object |
evaluate(EvaluationContext context)
Returns the result of evaluating this node in the given context.
|
cons, emptyNode, evaluationException, evaluationException
private final ExpressionNode condition
private final Node truePart
private final Node falsePart
IfNode(int lineNumber, ExpressionNode condition, Node trueNode, Node falseNode)
java.lang.Object evaluate(EvaluationContext context)
Node
2 + 3
to 5 in order to set
$x
to 5 in #set ($x = 2 + 3)
. Or it may be used directly as part of the
template output, for example evaluating replacing name
by Fred
in
My name is $name.
.