Interface TemplateCollectionModel
-
- All Superinterfaces:
TemplateModel
- All Known Subinterfaces:
TemplateCollectionModelEx
- All Known Implementing Classes:
ArrayModel
,CollectionModel
,DefaultEnumerationAdapter
,DefaultIterableAdapter
,DefaultIteratorAdapter
,DefaultNonListCollectionAdapter
,EnumerationModel
,IteratorModel
,JythonSequenceModel
,NodeListModel
,SimpleCollection
public interface TemplateCollectionModel extends TemplateModel
"collection" template language data type: a collection of values that can be enumerated, but can't be or not meant to be accessed by index or key, nor the number of elements in it is known. As such, this is very similar to Java'sIterable
interface (but it predates that interface, hence the unfortunate class name).Note that this is not a super-interface of
TemplateSequenceModel
, and implementations of that interface needn't also implement this interface just because they can. They should though, if enumeration with this interface is significantly faster than enumeration by index. The#list
directive will enumerate using this interface if it's available.The enumeration should be repeatable if that's possible with reasonable effort, otherwise a second enumeration attempt is allowed to throw an
TemplateModelException
. Generally, the interface user Java code need not handle that kind of exception, as in practice only the template author can handle it, by not listing such collections twice.Note that to wrap Java's
Collection
, you should implementTemplateCollectionModelEx
, not just this interface.
-
-
Field Summary
-
Fields inherited from interface freemarker.template.TemplateModel
NOTHING
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description TemplateModelIterator
iterator()
Retrieves a template model iterator that is used to iterate over the elements in this collection.
-
-
-
Method Detail
-
iterator
TemplateModelIterator iterator() throws TemplateModelException
Retrieves a template model iterator that is used to iterate over the elements in this collection.- Throws:
TemplateModelException
-
-