freemarker.template
Interface TemplateListModel2

All Superinterfaces:
TemplateModel
All Known Implementing Classes:
ArrayModel, ArrayWrapper, CollectionModel, CollectionWrapper, ContentList, EnumerationMethodWrapper, EnumerationModel, EnumWrapper, ExtendedList, FastList, FastListRange, IndexedPropertyWrapper, IterableWrapper, IteratorMethodWrapper, IteratorModel, ListModel, ListWrapper, MapWrapper, NodeListModel, PropertiesWrapper, SimpleList, StaticEnumWrapper

public interface TemplateListModel2
extends TemplateModel

List values in a template data model must implement either this interface or the deprecated TemplateListModel interface. This interface acts effectively as a factory for TemplateIteratorModel objects. TemplateIteratorModel objects are the objects that actually iterate over the underlying list represented by this interface. The relationship is almost identical to that between java.util.List implementations and the java.util.Iterator interface.

This interface also supports the notion of recycling iterators. This is not required, but may improve efficiency in cases where creating a new iterator is expensive.

This interface replaces the now deprecated TemplateListModel interface.

The detail messages of any TemplateModelExceptions thrown will be included as HTML comments in the output.

Since:
1.8
Version:
$Id: TemplateListModel2.java 1101 2013-04-01 04:17:32Z run2000 $
See Also:
TemplateListModel, TemplateIteratorModel

Method Summary
 void releaseIterator(TemplateIteratorModel iterator)
          Returns the used iterator to the list model.
 TemplateIteratorModel templateIterator()
          Retrieves an iterator to iterate over this list.
 
Methods inherited from interface freemarker.template.TemplateModel
isEmpty
 

Method Detail

templateIterator

TemplateIteratorModel templateIterator()
                                       throws TemplateModelException
Retrieves an iterator to iterate over this list. Can choose to return null if there are no elements in the list.

Returns:
an iterator to iterate over the current list.
Throws:
TemplateModelException - the next item in the list can't be retrieved, or no next item exists.

releaseIterator

void releaseIterator(TemplateIteratorModel iterator)

Returns the used iterator to the list model. Implement this method when you want to use an object pool of TemplateIterator objects. Otherwise, leave the implementation of this method blank.

Note that if the iterator returned in templateIterator() is null, this method will not be called for the null iterator.

Parameters:
iterator - the iterator to be returned to the object pool, if any