freemarker.ext.beans2
Class IterableWrapper<T extends java.lang.Iterable>

java.lang.Object
  extended by freemarker.ext.beans2.BeanWrapper<T>
      extended by freemarker.ext.beans2.IterableWrapper<T>
All Implemented Interfaces:
ObjectWrapper, TemplateHashModel, TemplateListModel2, TemplateModel, TemplateObjectModel, TemplateScalarModel, TemplateWriteableHashModel, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
CollectionWrapper

public class IterableWrapper<T extends java.lang.Iterable>
extends BeanWrapper<T>
implements TemplateListModel2, java.io.Serializable

Wraps Iterable objects by providing a template iterator model. Also a base class for CollectionWrapper.

Since:
1.9
Version:
$Id: IterableWrapper.java 1067 2011-06-06 10:55:28Z run2000 $
Author:
Nicholas Cull
See Also:
Serialized Form

Field Summary
 
Fields inherited from class freemarker.ext.beans2.BeanWrapper
emptyParams, object
 
Constructor Summary
IterableWrapper()
          Default constructor where an object is not provided initially.
IterableWrapper(T object)
          Constructor that takes an Iterable object to be wrapped.
 
Method Summary
 void releaseIterator(TemplateIteratorModel iterator)
          Returns the used iterator to the list model.
 TemplateIteratorModel templateIterator()
          Retrieves an iterator to iterate over this collection.
 
Methods inherited from class freemarker.ext.beans2.BeanWrapper
clone, get, getAsObject, getAsString, isEmpty, put, setObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface freemarker.template.TemplateModel
isEmpty
 

Constructor Detail

IterableWrapper

public IterableWrapper()
Default constructor where an object is not provided initially. This allows the wrapper to be used as a prototype.


IterableWrapper

public IterableWrapper(T object)
Constructor that takes an Iterable object to be wrapped.

Parameters:
object - the iterable object to be wrapped
Method Detail

templateIterator

public TemplateIteratorModel templateIterator()
                                       throws TemplateModelException
Retrieves an iterator to iterate over this collection.

Specified by:
templateIterator in interface TemplateListModel2
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

public void releaseIterator(TemplateIteratorModel iterator)
Returns the used iterator to the list model.

Specified by:
releaseIterator in interface TemplateListModel2
Parameters:
iterator - the iterator to be returned