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
abstract class ExpressionNode extends Node
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 Classes Modifier and Type Class 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
.
-
Field Summary
-
Fields inherited from class com.google.auto.value.processor.escapevelocity.Node
lineNumber, resourceName
-
-
Constructor Summary
Constructors Constructor Description ExpressionNode(java.lang.String resourceName, int lineNumber)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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.-
Methods inherited from class com.google.auto.value.processor.escapevelocity.Node
cons, emptyNode, evaluate, evaluationException, evaluationException
-
-
-
-
Method Detail
-
isTrue
boolean isTrue(EvaluationContext context)
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
boolean isDefinedAndTrue(EvaluationContext context)
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
int intValue(EvaluationContext context)
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
private static java.lang.String show(java.lang.Object value)
Returns a string representing the given value, for use in error messages. The string includes both the value'stoString()
and its type.
-
-