abstract class ExpressionNode extends Node
#set
, #if
, #foreach
, and macro calls. Expressions can
also appear inside indices in references, like $x[$i]
.Modifier and Type | Class and Description |
---|---|
(package private) static class |
ExpressionNode.BinaryExpressionNode
Represents all binary expressions.
|
(package private) static class |
ExpressionNode.NotExpressionNode
A node in the parse tree representing an expression like
!$a . |
lineNumber
Constructor and Description |
---|
ExpressionNode(int lineNumber) |
Modifier and Type | Method and Description |
---|---|
(package private) int |
intValue(EvaluationContext context)
The integer result of evaluating this expression.
|
(package private) boolean |
isDefinedAndTrue(EvaluationContext context)
True if this is a defined value and it evaluates to true.
|
(package private) boolean |
isTrue(EvaluationContext context)
True if evaluating this expression yields a value that is considered true by Velocity's
rules.
|
private static java.lang.String |
show(java.lang.Object value)
Returns a string representing the given value, for use in error messages.
|
cons, emptyNode, evaluate, evaluationException, evaluationException
boolean isTrue(EvaluationContext context)
Note that the text at the similar link here states that empty collections and empty strings are also considered false, but that is not true.
boolean isDefinedAndTrue(EvaluationContext context)
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.int intValue(EvaluationContext context)
EvaluationException
- if evaluating the expression produces an exception, or if it
yields a value that is not an integer.private static java.lang.String show(java.lang.Object value)
toString()
and its type.