#set, #if, #foreach, and macro calls. Expressions can
also appear inside indices in references, like $x[$i].
Nontrivial expressions are represented by a tree of ExpressionNode objects. For
example, in #if ($foo.bar < 3), the expression $foo.bar < 3 is parsed into
a tree that we might describe as
BinaryExpressionNode(ReferenceNode.(MemberReferenceNode ReferenceNode.("foo"), "bar"),PlainReferenceNode Operator#LESS,ConstantExpressionNode(3))
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | ExpressionNode.BinaryExpressionNode
Represents all binary expressions. |
| pack-priv static class | ExpressionNode.NotExpressionNode
A node in the parse tree representing an expression like |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv abstract Object | evaluate(EvaluationContext
the context of the evaluation, for example the context, boolean $variables that are in
scopewhether an undefined plain reference like undefinedIsFalse)$foo is considered
to be false. This is the case when evaluating the condition in an #if. Everywhere
else, an undefined reference causes an exception.Returns the result of evaluating this node in the given context. |
| pack-priv final Object | |
| pack-priv Integer | intValue(EvaluationContext context)
The integer result of evaluating this expression, or null if the expression evaluates to null. |
| pack-priv boolean | isSilent()
True if a null value for this expression is silently translated to an empty string when substituted into template text. |
| pack-priv boolean | isTrue(EvaluationContext context, boolean undefinedIsFalse)
True if evaluating this expression yields a value that is considered true by Velocity's rules. |
| pack-priv final void | render(EvaluationContext context, StringBuilder output)
Implements abstract com. output.
|
| private static String | |
| public abstract String |
| ExpressionNode | back to summary |
|---|---|
| pack-priv ExpressionNode(String resourceName, int lineNumber) | |
| evaluate | back to summary |
|---|---|
| pack-priv abstract Object evaluate(EvaluationContext context, boolean undefinedIsFalse) 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 This has to be an
| |
| evaluate | back to summary |
|---|---|
| pack-priv final Object evaluate(EvaluationContext context) | |
| intValue | back to summary |
|---|---|
| pack-priv Integer intValue(EvaluationContext context) The integer result of evaluating this expression, or null if the expression evaluates to null.
| |
| isSilent | back to summary |
|---|---|
| pack-priv boolean isSilent() True if a null value for this expression is silently translated to an empty string when substituted into template text. Otherwise it results in an exception. | |
| isTrue | back to summary |
|---|---|
| pack-priv boolean isTrue(EvaluationContext context, boolean undefinedIsFalse) 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 what Velocity actually implements. | |
| render | back to summary |
|---|---|
| pack-priv final void render(EvaluationContext context, StringBuilder output) Implements abstract com. Doc from com. Adds this node's contribution to the
| |
| show | back to summary |
|---|---|
| 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 | back to summary |
|---|---|
| public abstract String toString() Overrides java. Returns the source form of this node. This may not be exactly how it appears in the template.
For example both This method is used in error messages. It is not invoked in normal template evaluation.
| |
#set ($a = $b + $c), this will be the type
of the node representing $b + $c.
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final ExpressionNode | |
| pack-priv final Parser. | |
| pack-priv final ExpressionNode |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private boolean | |
| pack-priv Object | evaluate(EvaluationContext
the context of the evaluation, for example the context, boolean $variables that are in
scopewhether an undefined plain reference like undefinedIsFalse)$foo is considered
to be false. This is the case when evaluating the condition in an #if. Everywhere
else, an undefined reference causes an exception.Implements abstract com. |
| private Void | |
| private String | |
| private Object | |
| public String | toString()
Implements abstract com. |
| lhs | back to summary |
|---|---|
| pack-priv final ExpressionNode lhs | |
| op | back to summary |
|---|---|
| pack-priv final Parser. | |
| rhs | back to summary |
|---|---|
| pack-priv final ExpressionNode rhs | |
| BinaryExpressionNode | back to summary |
|---|---|
| pack-priv BinaryExpressionNode(ExpressionNode lhs, Parser. | |
| equal | back to summary |
|---|---|
| private boolean equal(EvaluationContext context) Returns true if Velocity's definition
of equality differs depending on whether the objects being compared are of the same
class. If so, equality comes from | |
| evaluate | back to summary |
|---|---|
| pack-priv Object evaluate(EvaluationContext context, boolean undefinedIsFalse) Implements abstract com. Doc from com. 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 This has to be an
| |
| nullOperand | back to summary |
|---|---|
| private Void nullOperand(boolean leftIsNull) | |
| operandString | back to summary |
|---|---|
| private String operandString(ExpressionNode operand) | |
| plus | back to summary |
|---|---|
| private Object plus(EvaluationContext context) | |
| toString | back to summary |
|---|---|
| public String toString() Implements abstract com. Doc from com. Returns the source form of this node. This may not be exactly how it appears in the template.
For example both This method is used in error messages. It is not invoked in normal template evaluation.
| |
!$a.
| Modifier and Type | Field and Description |
|---|---|
| private final ExpressionNode |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv Object | evaluate(EvaluationContext
the context of the evaluation, for example the context, boolean $variables that are in
scopewhether an undefined plain reference like undefinedIsFalse)$foo is considered
to be false. This is the case when evaluating the condition in an #if. Everywhere
else, an undefined reference causes an exception.Implements abstract com. |
| public String | toString()
Implements abstract com. |
| expr | back to summary |
|---|---|
| private final ExpressionNode expr | |
| NotExpressionNode | back to summary |
|---|---|
| pack-priv NotExpressionNode(ExpressionNode expr) | |
| evaluate | back to summary |
|---|---|
| pack-priv Object evaluate(EvaluationContext context, boolean undefinedIsFalse) Implements abstract com. Doc from com. 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 This has to be an
| |
| toString | back to summary |
|---|---|
| public String toString() Implements abstract com. Doc from com. Returns the source form of this node. This may not be exactly how it appears in the template.
For example both This method is used in error messages. It is not invoked in normal template evaluation.
| |