freemarker.core
Class CollectionAndSequence
java.lang.Object
freemarker.core.CollectionAndSequence
- All Implemented Interfaces:
- TemplateCollectionModel, TemplateModel, TemplateSequenceModel, java.io.Serializable
public final class CollectionAndSequence
- extends java.lang.Object
- implements TemplateCollectionModel, TemplateSequenceModel, java.io.Serializable
Add sequence capabilities to an existing collection, or
vice versa. Used by ?keys and ?values built-ins.
- See Also:
- Serialized Form
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CollectionAndSequence
public CollectionAndSequence(TemplateCollectionModel collection)
CollectionAndSequence
public CollectionAndSequence(TemplateSequenceModel sequence)
iterator
public TemplateModelIterator iterator()
throws TemplateModelException
- Description copied from interface:
TemplateCollectionModel
- Retrieves a template model iterator that is used to iterate over
the elements in this collection.
- Specified by:
iterator
in interface TemplateCollectionModel
- Throws:
TemplateModelException
get
public TemplateModel get(int i)
throws TemplateModelException
- Description copied from interface:
TemplateSequenceModel
- Retrieves the i-th template model in this sequence.
- Specified by:
get
in interface TemplateSequenceModel
- Returns:
- the item at the specified index, or
null
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.
- Throws:
TemplateModelException
size
public int size()
throws TemplateModelException
- Specified by:
size
in interface TemplateSequenceModel
- Returns:
- the number of items in the list.
- Throws:
TemplateModelException