freemarker.ext.beans
Class ListModel

java.lang.Object
  |
  +--freemarker.ext.beans.ObjectModelBase
        |
        +--freemarker.ext.beans.ObjectModel
              |
              +--freemarker.ext.beans.CollectionModel
                    |
                    +--freemarker.ext.beans.ListModel
All Implemented Interfaces:
TemplateHashModel, TemplateIndexedModel, TemplateListModel2, TemplateModel, TemplateObjectModel, TemplateScalarModel

public final class ListModel
extends CollectionModel
implements TemplateIndexedModel

A special case of CollectionModel that implements TemplateIndexedModel to allow gets using numbered indexes.

Version:
$Id: ListModel.java,v 1.2 2003/11/03 03:33:31 run2000 Exp $
Author:
Nicholas Cull

Fields inherited from class freemarker.ext.beans.ObjectModelBase
TYPE_ARRAY, TYPE_COLLECTION, TYPE_ENUMERATION, TYPE_ITERATOR, TYPE_LIST, TYPE_MAP, TYPE_OBJECT, TYPE_OBJECT_BASE, TYPE_RESOURCE_BUNDLE
 
Constructor Summary
ListModel(java.util.List list)
          Creates a new model that wraps the specified collection object.
 
Method Summary
 TemplateModel getAtIndex(long index)
          Get the object at the specified index.
static CollectionModel getInstance(java.util.List object)
          Returns a model wrapping the specified list object.
 int getType()
          Returns the type of this object (which is TYPE_COLLECTION)
 
Methods inherited from class freemarker.ext.beans.CollectionModel
get, getInstance, isEmpty, releaseIterator, templateIterator
 
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
 
Methods inherited from interface freemarker.template.TemplateModel
isEmpty
 

Constructor Detail

ListModel

public ListModel(java.util.List list)
Creates a new model that wraps the specified collection object.
Parameters:
list - the list object to wrap into a model.
Method Detail

getInstance

public static final CollectionModel getInstance(java.util.List object)
Returns a model wrapping the specified list object. If there is already a cached model instance for this list, returns the cached model instance. Models are cached using 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.
Parameters:
object - the list to wrap into a model.
Returns:
the model for the list

getType

public int getType()
Returns the type of this object (which is TYPE_COLLECTION)
Overrides:
getType in class CollectionModel

getAtIndex

public TemplateModel getAtIndex(long index)
                         throws TemplateModelException
Get the object at the specified index. Returns a suitable TemplateModel for the underlying value.
Specified by:
getAtIndex in interface TemplateIndexedModel
Parameters:
index - the index of object within the list
Returns:
the object at the specified index
Throws:
TemplateModelException - there was a problem with the