freemarker.template
Class FastListIterator

java.lang.Object
  extended by freemarker.template.FastListIterator
All Implemented Interfaces:
TemplateIteratorModel, TemplateModel, TemplateWriteableIteratorModel

public class FastListIterator
extends java.lang.Object
implements TemplateWriteableIteratorModel

Iterator class for FastList where the underlying Collection is a List. Note that this model is not serializable, to match the semantics of the underlying java.util.ListIterator.

Since:
1.8
See Also:
FastList

Field Summary
protected  java.util.ListIterator iterator
          The iterator being wrapped by this model.
 
Constructor Summary
FastListIterator(java.util.List list)
          Constructor that takes a java.util.Collection implementation to iterator over.
 
Method Summary
 boolean hasNext()
          Do we have another item in the list?
 boolean isEmpty()
          Is the object empty?
 TemplateModel next()
          Retrieve the next item in the list.
 void set(TemplateModel model)
          Inserts the specified element into the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

iterator

protected final java.util.ListIterator iterator
The iterator being wrapped by this model.

Constructor Detail

FastListIterator

public FastListIterator(java.util.List list)
Constructor that takes a java.util.Collection implementation to iterator over.

Throws:
java.lang.NullPointerException - the collection is null
Method Detail

hasNext

public boolean hasNext()
                throws TemplateModelException
Do we have another item in the list?

Specified by:
hasNext in interface TemplateIteratorModel
Returns:
true if there are more items to be iterated over, otherwise false
Throws:
TemplateModelException - there was a problem determining the next item in the list

next

public TemplateModel next()
                   throws TemplateModelException
Retrieve the next item in the list. The item will be a TemplateModel containing the underlying value.

Specified by:
next in interface TemplateIteratorModel
Returns:
the next item in the list
Throws:
TemplateModelException - the next item couldn't be retrieved, or we're at the end of the list

set

public void set(TemplateModel model)
         throws TemplateModelException
Inserts the specified element into the list. The element is inserted immediately before the next element that would be returned by next, if any.

Specified by:
set in interface TemplateWriteableIteratorModel
Parameters:
model - the model to insert into the list
Throws:
TemplateModelException - the model could not be assigned to the list

isEmpty

public boolean isEmpty()
                throws TemplateModelException
Is the object empty?

Specified by:
isEmpty in interface TemplateModel
Returns:
true if this object is empty, otherwise false
Throws:
TemplateModelException