Class SimpleCollection
- All Implemented Interfaces:
TemplateCollectionModel,TemplateModel,Serializable
TemplateCollectionModel.
It's able to wrap java.util.Iterator-s and java.util.Collection-s.
If you wrap an Iterator, the variable can be <#list>-ed only once!
Consider using SimpleSequence instead of this class if you want to wrap Iterators.
SimpleSequence will read all elements of the Iterator, and store them in a List
(this may cause too high resource consumption in some applications), so you can list the variable
for unlimited times. Also, if you want to wrap Collections, and then list the resulting
variable for many times, SimpleSequence may gives better performance, as the
wrapping of non-TemplateModel objects happens only once.
This class is thread-safe. The returned TemplateModelIterator-s
are not thread-safe.
- See Also:
- Serialized Form
-
Field Summary
Fields inherited from interface freemarker.template.TemplateModel
NOTHING -
Constructor Summary
ConstructorsConstructorDescriptionSimpleCollection(Iterable iterable)Deprecated.SimpleCollection(Iterable iterable, ObjectWrapper wrapper)SimpleCollection(Collection collection)Deprecated.UseSimpleCollection(Iterable, ObjectWrapper)instead.SimpleCollection(Collection collection, ObjectWrapper wrapper)Same asSimpleCollection(Iterable, ObjectWrapper); kept for binary compatibility.SimpleCollection(Iterator iterator)Deprecated.SimpleCollection(Iterator iterator, ObjectWrapper wrapper) -
Method Summary
Modifier and TypeMethodDescriptioniterator()Retrieves a template model iterator that is used to iterate over the elements in this collection.Methods inherited from class freemarker.template.WrappingTemplateModel
getDefaultObjectWrapper, getObjectWrapper, setDefaultObjectWrapper, setObjectWrapper, wrap
-
Constructor Details
-
SimpleCollection
Deprecated. -
SimpleCollection
Deprecated.UseSimpleCollection(Iterable, ObjectWrapper)instead. -
SimpleCollection
Deprecated.UseSimpleCollection(Iterable, ObjectWrapper)instead.Same asSimpleCollection(Iterable); kept for binary compatibility. -
SimpleCollection
Same asSimpleCollection(Iterable, ObjectWrapper); kept for binary compatibility. -
SimpleCollection
-
SimpleCollection
- Parameters:
iterable- Note that this was aCollectionbefore 2.3.27, not anIterable
-
-
Method Details
-
iterator
Retrieves a template model iterator that is used to iterate over the elements in this collection.When you wrap an
Iteratorand you getTemplateModelIteratorfor multiple times, only on of the returnedTemplateModelIteratorinstances can be really used. When you have called a method of aTemplateModelIteratorinstance, all other instance will throw aTemplateModelExceptionwhen you try to call their methods, since the wrappedIteratorcan't return the first element anymore.- Specified by:
iteratorin interfaceTemplateCollectionModel
-
SimpleCollection(Iterable, ObjectWrapper)instead.