freemarker.template.expression
Class ListRange

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

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

An expression that represents a indexModel of list values. The from and to expressions are held until evaluation time, then a FastListRange is created. A simple FastIndexedIterator is used to iterate over the values.

Since:
1.8
Version:
$Id: ListRange.java,v 1.14 2003/11/27 07:07:12 run2000 Exp $
See Also:
Serialized Form

Constructor Summary
ListRange(Expression fromRange, Expression toRange)
          Constructor that takes from and to values in the form of expressions.
 
Method Summary
 boolean equals(java.lang.Object o)
          Determines whether this object is equal to the given object.
 TemplateModel getAsTemplateModel(TemplateModelRoot modelRoot)
          Retrieve the list range as a template model.
 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()
          Do we have from and to values?
 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

ListRange

public ListRange(Expression fromRange,
                 Expression toRange)
Constructor that takes from and to values in the form of expressions. The expressions are evaluated at template run time and converted into values usable by the FastListRange.
Parameters:
fromRange - the start of the range, as an expression
toRange - the end of the range, as an expression
Throws:
NullPointerException - fromRange or toRange are null
java.lang.IllegalArgumentException - the expressions cannot be evaluated as numbers
Method Detail

getAsTemplateModel

public TemplateModel getAsTemplateModel(TemplateModelRoot modelRoot)
                                 throws TemplateException
Retrieve the list range as a template model.
Specified by:
getAsTemplateModel in interface Expression
Parameters:
modelRoot - the model from which to evaluate the range of the list
Returns:
a new FastListRange representing the range list
Throws:
TemplateException - the new range could not be created

isComplete

public boolean isComplete()
Do we have from and to values?
Specified by:
isComplete in interface Expression
Returns:
true if both from and to values are specified, 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