public class SimpleCollection extends WrappingTemplateModel implements TemplateCollectionModel, java.io.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.
NOTHING
Constructor and Description |
---|
SimpleCollection(java.util.Collection collection)
Deprecated.
Use
SimpleCollection(Iterable, ObjectWrapper) instead. |
SimpleCollection(java.util.Collection collection,
ObjectWrapper wrapper)
Same as
SimpleCollection(Iterable, ObjectWrapper) ; kept for binary compatibility. |
SimpleCollection(java.lang.Iterable iterable)
Deprecated.
Use
SimpleCollection(Iterable, ObjectWrapper) instead. |
SimpleCollection(java.lang.Iterable iterable,
ObjectWrapper wrapper) |
SimpleCollection(java.util.Iterator iterator)
Deprecated.
|
SimpleCollection(java.util.Iterator iterator,
ObjectWrapper wrapper) |
Modifier and Type | Method and Description |
---|---|
TemplateModelIterator |
iterator()
Retrieves a template model iterator that is used to iterate over the elements in this collection.
|
getDefaultObjectWrapper, getObjectWrapper, setDefaultObjectWrapper, setObjectWrapper, wrap
@Deprecated public SimpleCollection(java.util.Iterator iterator)
SimpleCollection(Iterator, ObjectWrapper)
@Deprecated public SimpleCollection(java.lang.Iterable iterable)
SimpleCollection(Iterable, ObjectWrapper)
instead.@Deprecated public SimpleCollection(java.util.Collection collection)
SimpleCollection(Iterable, ObjectWrapper)
instead.SimpleCollection(Iterable)
; kept for binary compatibility.public SimpleCollection(java.util.Collection collection, ObjectWrapper wrapper)
SimpleCollection(Iterable, ObjectWrapper)
; kept for binary compatibility.public SimpleCollection(java.util.Iterator iterator, ObjectWrapper wrapper)
public SimpleCollection(java.lang.Iterable iterable, ObjectWrapper wrapper)
iterable
- Note that this was a Collection
before 2.3.27, not an Iterable
public TemplateModelIterator iterator()
When you wrap an Iterator and you get TemplateModelIterator for multiple times, only on of the returned TemplateModelIterator instances can be really used. When you have called a method of a TemplateModelIterator instance, all other instance will throw a TemplateModelException when you try to call their methods, since the wrapped Iterator can't return the first element anymore.
iterator
in interface TemplateCollectionModel