freemarker.template.expression
Interface Expression

All Superinterfaces:
ExpressionElement
All Known Subinterfaces:
Binary, Operator, Unary, Variable
All Known Implementing Classes:
BooleanLiteral, Constant, HashLiteral, ListLiteral, NumberLiteral, StringLiteral, ListRange

public interface Expression
extends ExpressionElement

An Expression can return a TemplateModel value. An expression is used whenever we want to interact with the template models. An expression can be simple, such as an identifier, or more complex, such as a dynamic key name or a concatenation operator.

Expressions can be (in fact, usually are) nested. For instance, a comparison of two concatenation operations may be represented as follows:

                         Equals
                           |
          +----------------+---------------+
          |                                |
          |Plus                            | Plus
     +----+----+                     +-----+-----+
     |         |                     |           |
     |         |                     |           |
 identifier identifier           identifier      + dynamic-key-name
                                                 |
                                                 |
                                                 + identifier
 

Each node on the tree represents a different expression object.

Once complete (i.e. parsed), expressions should be considered immutable.

Version:
$Id: Expression.java,v 1.9 2003/11/10 03:55:38 run2000 Exp $

Method Summary
 TemplateModel getAsTemplateModel(TemplateModelRoot modelRoot)
          The TemplateModel value of this Expression.
 int getType()
          Determine the type of result that can be calculated by this expression.
 boolean isComplete()
          Is the Expression complete?
 

Method Detail

getAsTemplateModel

public TemplateModel getAsTemplateModel(TemplateModelRoot modelRoot)
                                 throws TemplateException
The TemplateModel value of this Expression.
Parameters:
modelRoot - the template model that will be evaluated by the expression
Throws:
TemplateException - the expression could not be evaluated for some reason

isComplete

public boolean isComplete()
Is the Expression complete?
Returns:
true if this Expression is complete, otherwise false

getType

public int getType()
Determine the type of result that can be calculated by this expression. This is in the form of an integer constant ored together from values in the ExpressionUtils class.