freemarker.template.expression
Class ListLiteral

java.lang.Object
  |
  +--freemarker.template.expression.ListLiteral
All Implemented Interfaces:
Expression, ExpressionElement, java.io.Serializable

public final class ListLiteral
extends java.lang.Object
implements Expression, java.io.Serializable

Represents a literal List model in a FM-Classic template. The list model is not evaluated until run time, since the model may contain variables or other more complex expressions that can't be determined at compile time.

Version:
$Id: ListLiteral.java,v 1.25 2003/11/27 07:07:12 run2000 Exp $
See Also:
Serialized Form

Constructor Summary
ListLiteral(java.util.List values)
          Constructor that takes a list of Expression elements to be evaluated as a list model at run time.
 
Method Summary
 boolean equals(java.lang.Object o)
          Determines whether this object is equal to the given object.
 TemplateModel getAsTemplateModel(TemplateModelRoot modelRoot)
          The TemplateModel value of this Expression.
 java.util.List getModelList(TemplateModelRoot modelRoot)
          For the benefit of method calls, return the list of arguments as a list of TemplateModel values.
 int getType()
          Determine the type of result that can be calculated by this expression.
 java.util.List getValueList(TemplateModelRoot modelRoot)
          For the benefit of method calls, return the list of arguments as a list of String values.
 int hashCode()
          Returns the hash code for this operator.
 boolean isComplete()
          Has the ListLiteral been populated?
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ListLiteral

public ListLiteral(java.util.List values)
Constructor that takes a list of Expression elements to be evaluated as a list model at run time.
Parameters:
values - the values to be added to the ListLiteral
Throws:
NullPointerException - the value list is null
Method Detail

getAsTemplateModel

public TemplateModel getAsTemplateModel(TemplateModelRoot modelRoot)
                                 throws TemplateException
The TemplateModel value of this Expression.
Specified by:
getAsTemplateModel in interface Expression
Parameters:
modelRoot - the template model that will be evaluated by the expression
Returns:
a FastList containing the values in the list model
Throws:
TemplateException - the expression could not be evaluated for some reason

getModelList

public java.util.List getModelList(TemplateModelRoot modelRoot)
                            throws TemplateException
For the benefit of method calls, return the list of arguments as a list of TemplateModel values.
Parameters:
modelRoot - the template model that will be evaluated by the expression
Returns:
a List of TemplateModels contained in the ListLiteral
Throws:
TemplateException - the literal list could not be returned

getValueList

public java.util.List getValueList(TemplateModelRoot modelRoot)
                            throws TemplateException
For the benefit of method calls, return the list of arguments as a list of String values.
Parameters:
modelRoot - the template model that will be evaluated by the expression
Returns:
a List of TemplateModels contained in the ListLiteral
Throws:
TemplateException - the literal list could not be returned

isComplete

public boolean isComplete()
Has the ListLiteral been populated?
Specified by:
isComplete in interface Expression
Returns:
true if the ListLiteral is populated, 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.
Specified by:
getType in interface Expression

toString

public java.lang.String toString()
Returns a string representation of the object.
Overrides:
toString in class java.lang.Object
Returns:
a String representation of this expression

equals

public boolean equals(java.lang.Object o)
Determines whether this object is equal to the given object.
Overrides:
equals in class java.lang.Object
Parameters:
o - the object to be compared with
Returns:
true if the objects are equal, otherwise false

hashCode

public int hashCode()
Returns the hash code for this operator.
Overrides:
hashCode in class java.lang.Object
Returns:
the hash code of this object