freemarker.ext.beans2
Class ListWrapper<T extends java.util.List>
java.lang.Object
freemarker.ext.beans2.BeanWrapper<T>
freemarker.ext.beans2.IterableWrapper<T>
freemarker.ext.beans2.CollectionWrapper<T>
freemarker.ext.beans2.ListWrapper<T>
- All Implemented Interfaces:
- ObjectWrapper, TemplateHashModel, TemplateIndexedModel, TemplateListModel2, TemplateMethodModel2, TemplateModel, TemplateObjectModel, TemplateScalarModel, TemplateWriteableHashModel, TemplateWriteableIndexedModel, java.io.Serializable, java.lang.Cloneable
public class ListWrapper<T extends java.util.List>
- extends CollectionWrapper<T>
- implements TemplateIndexedModel, TemplateWriteableIndexedModel, java.io.Serializable
Wraps a List object by extending the Collection wrapper to provide an indexed
model.
- Since:
- 1.9
- Version:
- $Id: ListWrapper.java 1067 2011-06-06 10:55:28Z run2000 $
- Author:
- Nicholas Cull
- See Also:
- Serialized Form
Constructor Summary |
ListWrapper()
Default constructor where an object is not provided initially. |
ListWrapper(T object)
Constructor that takes a List object to be wrapped. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ListWrapper
public ListWrapper()
- Default constructor where an object is not provided initially. This allows
the wrapper to be used as a prototype.
ListWrapper
public ListWrapper(T object)
- Constructor that takes a List object to be wrapped.
- Parameters:
object
- the list object to be wrapped
templateIterator
public TemplateIteratorModel templateIterator()
throws TemplateModelException
- Retrieves an iterator to iterate over this collection.
- Specified by:
templateIterator
in interface TemplateListModel2
- Overrides:
templateIterator
in class IterableWrapper<T extends java.util.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.
getAtIndex
public TemplateModel getAtIndex(long index)
throws TemplateModelException
- Get the value corresponding to the given index. This corresponds
correspond to an index into an List such as a
java.util.Vector
.
- Specified by:
getAtIndex
in interface TemplateIndexedModel
- Parameters:
index
- the index of the underlying value we're interested in
- Returns:
- a
TemplateModel
representing the value for the given index
- Throws:
TemplateModelException
- the value could not be determined, possibly
due to an index out-of-bounds, or an otherwise undefined value
putAtIndex
public void putAtIndex(long index,
TemplateModel model)
throws TemplateModelException
- Set the value corresponding to the given index. Traditionally this would
correspond to an index into an array, or similar structure, such as a
java.util.Vector
.
- Specified by:
putAtIndex
in interface TemplateWriteableIndexedModel
- Parameters:
index
- the index of the underlying value we're interested inmodel
- the model to be added to the list
- Throws:
TemplateModelException
- the value could not be determined, possibly
due to an index out-of-bounds, or an otherwise undefined value