freemarker.template

Interface TemplateSequenceModel

All Superinterfaces:
TemplateModel
Known Implementing Classes:
ArrayModel, CollectionAndSequence, CollectionModel, JythonSequenceModel, NodeListModel, NodeListModel, NodeModel, RhinoFunctionModel, RhinoScriptableModel, SimpleList, SimpleSequence, StringArraySequence, TemplateModelListSequence

public interface TemplateSequenceModel
extends TemplateModel

List values in a template data model whose elements are accessed by the index operator should implement this interface. In addition to accessing elements by index and querying size using the ?size built-in, objects that implement this interface can be iterated in <#foreach ...> and <#list ...> directives. The iteration is implemented by calling the get(int) method repeatedly starting from zero and going to size() - 1.
Version:
$Id: TemplateSequenceModel.java,v 1.10 2004/11/27 14:49:57 ddekany Exp $
Author:
Attila Szegedi, szegedia at users dot sourceforge dot net

Fields inherited from interface freemarker.template.TemplateModel

NOTHING

Method Summary

TemplateModel
get(int index)
Retrieves the i-th template model in this sequence.
int
size()

Method Details

get

public TemplateModel get(int index)
            throws TemplateModelException
Retrieves the i-th template model in this sequence.
Returns:
the item at the specified index, or null if the index is out of bounds. Note that a null value is interpreted by FreeMarker as "variable does not exist", and accessing a missing variables is usually considered as an error in the FreeMarker Template Language, so the usage of a bad index will not remain hidden.

size

public int size()
            throws TemplateModelException
Returns:
the number of items in the list.