Class IteratorModel

java.lang.Object
freemarker.ext.beans.BeanModel
freemarker.ext.beans.IteratorModel
All Implemented Interfaces:
WrapperTemplateModel, AdapterTemplateModel, TemplateCollectionModel, TemplateHashModel, TemplateHashModelEx, TemplateModel, TemplateModelIterator, TemplateModelWithAPISupport

public class IteratorModel extends BeanModel implements TemplateModelIterator, TemplateCollectionModel

A class that adds TemplateModelIterator functionality to the Iterator interface implementers.

It differs from the SimpleCollection in that it inherits from BeanModel, and therefore you can call methods on it directly, even to the effect of calling iterator.remove() in the template.

Using the model as a collection model is NOT thread-safe, as iterators are inherently not thread-safe. Further, you can iterate over it only once. Attempts to call the iterator() method after it was already driven to the end once will throw an exception.