|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfreemarker.ext.beans.BeanModel
freemarker.ext.beans.StringModel
freemarker.ext.beans.CollectionModel
public class CollectionModel
A special case of 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 class freemarker.ext.beans.BeanModel |
|---|
object, wrapper |
| Fields inherited from interface freemarker.template.TemplateModel |
|---|
NOTHING |
| Fields inherited from interface freemarker.template.TemplateScalarModel |
|---|
EMPTY_STRING |
| Constructor Summary | |
|---|---|
CollectionModel(java.util.Collection collection,
BeansWrapper wrapper)
Creates a new model that wraps the specified collection object. |
|
| Method Summary | |
|---|---|
TemplateModel |
get(int index)
Retrieves the i-th object from the collection, wrapped as a TemplateModel. |
TemplateModelIterator |
iterator()
Retrieves a template model iterator that is used to iterate over the elements in this collection. |
int |
size()
|
| Methods inherited from class freemarker.ext.beans.StringModel |
|---|
getAsString |
| Methods inherited from class freemarker.ext.beans.BeanModel |
|---|
get, getAdaptedObject, getWrappedObject, hasPlainGetMethod, invokeGenericGet, isEmpty, keys, keySet, toString, unwrap, values, wrap |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public CollectionModel(java.util.Collection collection,
BeansWrapper wrapper)
collection - the collection object to wrap into a model.wrapper - the BeansWrapper associated with this model.
Every model has to have an associated BeansWrapper instance. The
model gains many attributes from its wrapper, including the caching
behavior, method exposure level, method-over-item shadowing policy etc.| Method Detail |
|---|
public TemplateModel get(int index)
throws TemplateModelException
get in interface TemplateSequenceModelnull if
the index is out of bounds. Note that a null value is
interpreted by FreeMarker as "variable does not exist", and accessing
a missing variables is usually considered as an error in the FreeMarker
Template Language, so the usage of a bad index will not remain hidden.
TemplateModelException - if the index is out of bounds, or the
underlying collection is not a List.public TemplateModelIterator iterator()
TemplateCollectionModel
iterator in interface TemplateCollectionModelpublic int size()
size in interface TemplateHashModelExsize in interface TemplateSequenceModelsize in class BeanModel
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||