Top Description Fields Constructors Methods
com.google.escapevelocity

pack-priv Class ConstantExpressionNode

extends ExpressionNode
Class Inheritance
Imports
com.google.common.base.CharMatcher

A node in the parse tree representing a constant value. Evaluating the node yields the constant value. Instances of this class are used both in expressions, like the 23 in #set ($x = 23), and for literal text in templates. In the template...
abc#{if}($x == 5)def#{end}xyz
...each of the strings abc, def, xyz is represented by an instance of this class that evaluates to that string, and the value 5 is represented by an instance of this class that evaluates to the integer 5.
Author
[email protected] (Éamonn McManus)

Field Summary

Modifier and TypeField and Description
private static final CharMatcher
private final Object

Constructor Summary

AccessConstructor and Description
pack-priv
ConstantExpressionNode(String resourceName, int lineNumber, Object value)

Method Summary

Modifier and TypeMethod and Description
pack-priv Object
evaluate(EvaluationContext
the context of the evaluation, for example the $variables that are in scope
context
,
boolean
whether an undefined plain reference like $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.
undefinedIsFalse
)

Implements abstract com.google.escapevelocity.ExpressionNode.evaluate.

Returns the result of evaluating this node in the given context.
pack-priv boolean
isHorizontalWhitespace()

Overrides com.google.escapevelocity.Node.isHorizontalWhitespace.

True if this node is just a span of horizontal whitespace in the text.
public String
toString()

Implements abstract com.google.escapevelocity.ExpressionNode.toString.

Returns the source form of this node.
Inherited from com.google.escapevelocity.ExpressionNode:
evaluateintValueisSilentisTruerender

Field Detail

HORIZONTAL_SPACEback to summary
private static final CharMatcher HORIZONTAL_SPACE
valueback to summary
private final Object value

Constructor Detail

ConstantExpressionNodeback to summary
pack-priv ConstantExpressionNode(String resourceName, int lineNumber, Object value)

Method Detail

evaluateback to summary
pack-priv Object evaluate(EvaluationContext context, boolean undefinedIsFalse)

Implements abstract com.google.escapevelocity.ExpressionNode.evaluate.

Doc from com.google.escapevelocity.ExpressionNode.evaluate.

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..

This has to be an Object rather than a String (or rather than appending to a StringBuilder) because it can potentially participate in other operations. In the preceding example, the nodes representing 2 and 3 and the node representing 2 + 3 all return Integer. As another example, in #if ($foo.bar < 3) the value $foo is itself an ExpressionNode which evaluates to the object referenced by the foo variable, and $foo.bar is another ExpressionNode that takes the value from foo and looks for the property bar in it.

Parameters
context:EvaluationContext

the context of the evaluation, for example the $variables that are in scope

undefinedIsFalse:boolean

whether an undefined plain reference like $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.

Annotations
@Override
isHorizontalWhitespaceback to summary
pack-priv boolean isHorizontalWhitespace()

Overrides com.google.escapevelocity.Node.isHorizontalWhitespace.

Doc from com.google.escapevelocity.Node.isHorizontalWhitespace.

True if this node is just a span of horizontal whitespace in the text.

Annotations
@Override
toStringback to summary
public String toString()

Implements abstract com.google.escapevelocity.ExpressionNode.toString.

Doc from com.google.escapevelocity.ExpressionNode.toString.

Returns the source form of this node. This may not be exactly how it appears in the template. For example both $x and ${x} end up being the same kind of node, and its toString() is "$x".

This method is used in error messages. It is not invoked in normal template evaluation.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

Annotations
@Override