freemarker.template
Class SimpleSequence
- Serializable, TemplateModel, TemplateSequenceModel
public class SimpleSequence
A convenient implementation of a list. This
object implements
TemplateSequenceModel
, using an underlying
java.util.List implementation.
A
SimpleSequence can act as a cache for a
TemplateCollectionModel, e.g. one that gets data from a
database. When passed a
TemplateCollectionModel as an
argument to its constructor, the
SimpleSequence immediately
copies all the elements and discards the
TemplateCollectionModel.
This class is thread-safe if you don't call the
add method after you
have made the object available for multiple threads.
Note:
As of 2.0, this class is unsynchronized by default.
To obtain a synchronized wrapper, call the
synchronizedWrapper()
method.
$Id: SimpleSequence.java,v 1.53 2005/06/21 18:17:54 ddekany Exp $
list
protected final List list
SimpleSequence
public SimpleSequence()
SimpleSequence
public SimpleSequence(Collection collection)
collection
- the collection containing initial values. Note that a
copy of the collection is made for internal use.
SimpleSequence
public SimpleSequence(Collection collection,
ObjectWrapper wrapper)
Constructs a simple sequence that will contain the elements
from the specified Collection
and will use the specified object
wrapper.
SimpleSequence
public SimpleSequence(ObjectWrapper wrapper)
Constructs an empty simple sequence using the specified object wrapper.
SimpleSequence
public SimpleSequence(int capacity)
add
public void add(Object obj)
Adds an arbitrary object to the end of this
SimpleSequence.
If the object itself does not implement the
TemplateModel
interface, it will be wrapped into an appropriate adapter on the first
call to
get(int)
.
obj
- the boolean to be added.
add
public void add(boolean b)
b
- the boolean to be added.
synchronizedWrapper
public SimpleSequence synchronizedWrapper()
- a synchronized wrapper for list.
toList
public List toList()
throws TemplateModelException
Note that this method creates and returns a deep-copy of the underlying list used
internally. This could be a gotcha for some people
at some point who want to alter something in the data model,
but we should maintain our immutability semantics (at least using default SimpleXXX wrappers)
for the data model. It will recursively unwrap the stuff in the underlying container.
toString
public String toString()