Package freemarker.template
Interface TemplateSequenceModel
-
- All Superinterfaces:
TemplateModel
- All Known Implementing Classes:
SimpleList,SimpleSequence,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?sizebuilt-in, objects that implement this interface can be iterated in<#foreach ...>and<#list ...>directives. The iteration is implemented by calling theget(int)method repeatedly starting from zero and going tosize()- 1.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface freemarker.template.TemplateModel
TemplateModel.InvalidExpressionModel, TemplateModel.JavaNull
-
-
Field Summary
-
Fields inherited from interface freemarker.template.TemplateModel
INVALID_EXPRESSION, JAVA_NULL, NOTHING
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description TemplateModelget(int index)Retrieves the i-th template model in this sequence.intsize()
-
-
-
Method Detail
-
get
TemplateModel get(int index) throws TemplateModelException
Retrieves the i-th template model in this sequence.- Returns:
- the item at the specified index, or
nullif the index is out of bounds. Note that anullvalue 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. - Throws:
TemplateModelException
-
size
int size() throws TemplateModelException
- Returns:
- the number of items in the list.
- Throws:
TemplateModelException
-
-