TemplateCollectionModel (FreeMarker 2.3.23 API)
Date: 2015-07-05

freemarker.template

## Interface TemplateCollectionModel

- All Superinterfaces:
    TemplateModel
  All Known Subinterfaces:
    TemplateCollectionModelEx
  All Known Implementing Classes:
    ArrayModel, CollectionModel, 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. As such, 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 implement `TemplateCollectionModelEx`, 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 and 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`