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].
  • Constructor Details

    • ExpressionNode

      ExpressionNode(String resourceName, int lineNumber)
  • Method Details

    • 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 as 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.
    • 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 String show(Object value)
      Returns a string representing the given value, for use in error messages. The string includes both the value's toString() and its type.