Class DirectiveNode.SetNode

  • Enclosing class:
    DirectiveNode

    static class DirectiveNode.SetNode
    extends DirectiveNode
    A node in the parse tree representing a #set construct. Evaluating #set ($x = 23) will set $x to the value 23. It does not in itself produce any text in the output.

    Velocity supports setting values within arrays or collections, with for example $set ($x[$i] = $y). That is not currently supported here.

    • Field Detail

      • var

        private final java.lang.String var
      • expression

        private final Node expression
    • Constructor Detail

      • SetNode

        SetNode​(java.lang.String var,
                Node expression)
    • Method Detail

      • evaluate

        java.lang.Object evaluate​(EvaluationContext context)
        Description copied from class: Node
        Returns the result of evaluating this node in the given context. This result may be used as part of a further operation, for example evaluating 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..
        Specified by:
        evaluate in class Node