freemarker.template.expression
Class HashLiteral

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

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

Represents a literal Hash model in a FM-Classic template. The hash 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: HashLiteral.java,v 1.20 2003/11/27 07:07:12 run2000 Exp $
See Also:
Serialized Form

Constructor Summary
HashLiteral(java.util.List values)
          Constructor that takes a list of Expression elements to be evaluated as a hash 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.
 int getType()
          Determine the type of result that can be calculated by this expression.
 int hashCode()
          Returns the hash code for this operator.
 boolean isComplete()
          Has the HashLiteral 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

HashLiteral

public HashLiteral(java.util.List values)
Constructor that takes a list of Expression elements to be evaluated as a hash model at run time.
Parameters:
values - the values to be added to the HashLiteral
Throws:
NullPointerException - the value list is null
java.lang.IllegalArgumentException - there are an odd number of arguments in the value list
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 FastHash containing the values in the hash model
Throws:
TemplateException - the expression could not be evaluated for some reason

isComplete

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