static class ReferenceNode.PlainReferenceNode extends ReferenceNode
$x
. This node may appear
inside a more complex reference like $x.foo
.ReferenceNode.IndexReferenceNode, ReferenceNode.MemberReferenceNode, ReferenceNode.MethodReferenceNode, ReferenceNode.PlainReferenceNode
ExpressionNode.BinaryExpressionNode, ExpressionNode.NotExpressionNode
Modifier and Type | Field and Description |
---|---|
(package private) java.lang.String |
id |
lineNumber
Constructor and Description |
---|
PlainReferenceNode(int lineNumber,
java.lang.String id) |
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.
|
(package private) boolean |
isDefinedAndTrue(EvaluationContext context)
True if this is a defined value and it evaluates to true.
|
invokeMethod, visibleMethod
intValue, isTrue
cons, emptyNode, evaluationException, evaluationException
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.
.boolean isDefinedAndTrue(EvaluationContext context)
ExpressionNode
ExpressionNode.isTrue(com.google.auto.value.processor.escapevelocity.EvaluationContext)
except that it is allowed for this to be undefined variable, in which it evaluates to false.
The method is overridden for plain references so that undefined is the same as false.
The reason is to support Velocity's idiom #if ($var)
, where it is not an error
if $var
is undefined.isDefinedAndTrue
in class ExpressionNode