Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
freemarker.ext.beans.BeanModel
freemarker.ext.beans.StringModel
freemarker.ext.beans.CollectionModel
public class CollectionModel
extends StringModel
implements TemplateCollectionModel, TemplateSequenceModel
BeanModel
that can wrap Java collections
and that implements the TemplateCollectionModel
in order to be usable
in a <foreach> block.
Field Summary |
Fields inherited from interface freemarker.template.TemplateModel | |
NOTHING |
Fields inherited from interface freemarker.template.TemplateScalarModel | |
EMPTY_STRING |
Constructor Summary | |
|
Method Summary | |
TemplateModel |
|
TemplateModelIterator |
|
int |
|
Methods inherited from class freemarker.ext.beans.StringModel | |
getAsString |
Methods inherited from class freemarker.ext.beans.BeanModel | |
get , getAdaptedObject , getWrappedObject , hasPlainGetMethod , invokeGenericGet , isEmpty , keySet , keys , size , toString , unwrap , values , wrap |
public CollectionModel(Collection collection, BeansWrapper wrapper)
Creates a new model that wraps the specified collection object.
- Parameters:
collection
- the collection object to wrap into a model.wrapper
- theBeansWrapper
associated with this model. Every model has to have an associatedBeansWrapper
instance. The model gains many attributes from its wrapper, including the caching behavior, method exposure level, method-over-item shadowing policy etc.
public TemplateModel get(int index) throws TemplateModelException
Retrieves the i-th object from the collection, wrapped as a TemplateModel.
- Specified by:
- get in interface TemplateSequenceModel
- Throws:
TemplateModelException
- if the index is out of bounds, or the underlying collection is not a List.
public TemplateModelIterator iterator()
Retrieves a template model iterator that is used to iterate over the elements in this collection.
- Specified by:
- iterator in interface TemplateCollectionModel
public int size()
- Specified by:
- size in interface TemplateSequenceModel
- size in interface TemplateHashModelEx
- Returns:
- the number of items in the list.