|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfreemarker.ext.beans.ObjectModelBase
freemarker.ext.beans.ObjectModel
freemarker.ext.beans.CollectionModel
freemarker.ext.beans2
package
public class CollectionModel
A special case of ObjectModel
that supports the
collection.iterator
syntax to obtain a TemplateListModel2
instance backed by this collection.
The class itself also implements TemplateListModel2
directly, since this model preserves thread safety.
Field Summary |
---|
Fields inherited from class freemarker.ext.beans.ObjectModelBase |
---|
object |
Constructor Summary | |
---|---|
CollectionModel(java.util.Collection collection)
Deprecated. Creates a new model that wraps the specified collection object. |
Method Summary | |
---|---|
TemplateModel |
get(java.lang.String key)
Deprecated. Uses Beans introspection to locate a property or method with name matching the key name. |
static CollectionModel |
getInstance(java.util.Collection object)
Deprecated. Returns a model wrapping the specified collection object. |
freemarker.ext.beans.ObjectModelBase.ModelType |
getType()
Deprecated. Returns the type of this object (which is TYPE_COLLECTION) |
boolean |
isEmpty()
Deprecated. Returns true if the underlying collection contains no elements. |
void |
releaseIterator(TemplateIteratorModel iterator)
Deprecated. Release the iterator once we've finished with it |
TemplateIteratorModel |
templateIterator()
Deprecated. Retrive an iterator for this Collection . |
Methods inherited from class freemarker.ext.beans.ObjectModel |
---|
getInstance |
Methods inherited from class freemarker.ext.beans.ObjectModelBase |
---|
getAsObject, getAsString, getInstance |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CollectionModel(java.util.Collection collection)
collection
- the collection object to wrap into a model.Method Detail |
---|
public static final CollectionModel getInstance(java.util.Collection object)
WeakReference
objects. The caching can be turned
off by setting the expose.reflection.nocache system property to
true. In this case calling this method is equivalent to constructing a new model.
object
- the collection to wrap into a model.
public TemplateModel get(java.lang.String key) throws TemplateModelException
ObjectModel
MethodModel
or ScalarModel
instance and
returned. Models for various properties and methods are cached on a per-class
basis, so the costly introspection is performed only once per property or method
of a class. (Sidenote: this also implies that any class whose method has been
called will be strongly referred to by the framework and will not become
unloadable until this class has been unloaded first. Normally this is not an
issue, but can be in a rare scenario where you create many classes on the fly.
Also, as the cache grows with new classes and methods introduced to the
framework, it may appear as if it were leaking memory.)
If no method or propery matching the key is found, the framework
will try to invoke methods with signature get(java.lang.String)
,
then get(java.lang.Object)
.
get
in interface TemplateHashModel
get
in class ObjectModel
key
- the name by which the TemplateModel
is identified in the template.
TemplateModel
referred to by the key,
or null
if not found.
TemplateModelException
- if there was no property nor method nor
a generic get
method to invoke.public freemarker.ext.beans.ObjectModelBase.ModelType getType()
getType
in class ObjectModel
public boolean isEmpty()
isEmpty
in interface TemplateModel
isEmpty
in class ObjectModelBase
true
if this object is empty, otherwise false
public TemplateIteratorModel templateIterator() throws TemplateModelException
Collection
.
templateIterator
in interface TemplateListModel2
TemplateIteratorModel
wrapping the underlying
java.util.Iterator
implementation
TemplateModelException
- the next item in the list can't be
retrieved, or no next item exists.public void releaseIterator(TemplateIteratorModel iterator)
releaseIterator
in interface TemplateListModel2
iterator
- the iterator model to be released
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |