Class ExpressionNode
java.lang.Object
com.google.auto.value.processor.escapevelocity.Node
com.google.auto.value.processor.escapevelocity.ExpressionNode
- Direct Known Subclasses:
ConstantExpressionNode
,ExpressionNode.BinaryExpressionNode
,ExpressionNode.NotExpressionNode
,ReferenceNode
A node in the parse tree representing an expression. Expressions appear inside directives,
specifically
#set
, #if
, #foreach
, and macro calls. Expressions can
also appear inside indices in references, like $x[$i]
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
Represents all binary expressions.(package private) static class
A node in the parse tree representing an expression like!$a
. -
Field Summary
Fields inherited from class com.google.auto.value.processor.escapevelocity.Node
lineNumber, resourceName
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(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 String
Returns a string representing the given value, for use in error messages.Methods inherited from class com.google.auto.value.processor.escapevelocity.Node
cons, emptyNode, evaluate, evaluationException, evaluationException
-
Constructor Details
-
ExpressionNode
ExpressionNode(String resourceName, int lineNumber)
-
-
Method Details
-
isTrue
True if evaluating this expression yields a value that is considered true by Velocity's rules. A value is false if it is null or equal to Boolean.FALSE. Every other value is true.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.
-
isDefinedAndTrue
True if this is a defined value and it evaluates to true. This is the same asisTrue(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. -
intValue
The integer result of evaluating this expression.- Throws:
EvaluationException
- if evaluating the expression produces an exception, or if it yields a value that is not an integer.
-
show
Returns a string representing the given value, for use in error messages. The string includes both the value'stoString()
and its type.
-