freemarker.ext.beans
Class IteratorModel

java.lang.Object
  extended by freemarker.ext.beans.ObjectModelBase
      extended by freemarker.ext.beans.ObjectModel
          extended by freemarker.ext.beans.IteratorModel
All Implemented Interfaces:
TemplateHashModel, TemplateListModel2, TemplateModel, TemplateObjectModel, TemplateScalarModel, java.io.Serializable

Deprecated. this class is deprecated in favour of the classes in the freemarker.ext.beans2 package

public final class IteratorModel
extends ObjectModel
implements TemplateListModel2

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

Using the model as a list model is NOT thread-safe, as iterators are inherently not thread-safe.

Version:
$Id: IteratorModel.java 1101 2013-04-01 04:17:32Z run2000 $
Author:
Attila Szegedi, attila@szegedi.org
See Also:
Serialized Form

Field Summary
 
Fields inherited from class freemarker.ext.beans.ObjectModelBase
object
 
Constructor Summary
IteratorModel(java.util.Iterator iterator)
          Deprecated. Creates a new model that wraps the specified iterator object.
 
Method Summary
static IteratorModel getInstance(java.util.Iterator object)
          Deprecated. Returns a model wrapping the specified iterator object.
 freemarker.ext.beans.ObjectModelBase.ModelType getType()
          Deprecated. Returns the type of this object (which is TYPE_ITERATOR)
 boolean isEmpty()
          Deprecated. Returns true if the iterator is null or the iterator has no elements remaining, otherwise false.
 void releaseIterator(TemplateIteratorModel iterator)
          Deprecated. Release the underlying iterator.
 TemplateIteratorModel templateIterator()
          Deprecated. Retrive an iterator for this object.
 
Methods inherited from class freemarker.ext.beans.ObjectModel
get, getInstance
 
Methods inherited from class freemarker.ext.beans.ObjectModelBase
getAsObject, getAsString, getInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IteratorModel

public IteratorModel(java.util.Iterator iterator)
Deprecated. 
Creates a new model that wraps the specified iterator object.

Parameters:
iterator - the iterator object to wrap into a model.
Method Detail

getInstance

public static final IteratorModel getInstance(java.util.Iterator object)
Deprecated. 
Returns a model wrapping the specified iterator object. It always returns a new object, as Iterators are considered short-lived and caching them would have little sense.

Returns:
the model for the iterator

getType

public freemarker.ext.beans.ObjectModelBase.ModelType getType()
Deprecated. 
Returns the type of this object (which is TYPE_ITERATOR)

Overrides:
getType in class ObjectModel

isEmpty

public boolean isEmpty()
Deprecated. 
Returns true if the iterator is null or the iterator has no elements remaining, otherwise false.

Specified by:
isEmpty in interface TemplateModel
Overrides:
isEmpty in class ObjectModelBase
Returns:
true if this object is empty, otherwise false

templateIterator

public TemplateIteratorModel templateIterator()
                                       throws TemplateModelException
Deprecated. 
Retrive an iterator for this object.

Specified by:
templateIterator in interface TemplateListModel2
Returns:
a TemplateIteratorModel wrapping the underlying java.util.Iterator implementation
Throws:
TemplateModelException - the next item in the list can't be retrieved, or no next item exists.

releaseIterator

public void releaseIterator(TemplateIteratorModel iterator)
Deprecated. 
Release the underlying iterator. The iterator can only be called once.

Specified by:
releaseIterator in interface TemplateListModel2
Parameters:
iterator - the wrapper for the iterator to be released