freemarker.ext.beans

Class ArrayModel

Implemented Interfaces:
AdapterTemplateModel, TemplateCollectionModel, TemplateHashModel, TemplateHashModelEx, TemplateModel, TemplateSequenceModel, WrapperTemplateModel

public class ArrayModel
extends BeanModel
implements TemplateCollectionModel, TemplateSequenceModel

A class that will wrap an arbitrary array into TemplateCollectionModel and TemplateSequenceModel interfaces. It supports element retrieval through the array[index] syntax and can be iterated as a list.
Version:
$Id: ArrayModel.java,v 1.26 2003/06/03 13:21:32 szegedia Exp $
Author:
Attila Szegedi

Field Summary

Fields inherited from class freemarker.ext.beans.BeanModel

object, wrapper

Fields inherited from interface freemarker.template.TemplateModel

NOTHING

Constructor Summary

ArrayModel(Object array, BeansWrapper wrapper)
Creates a new model that wraps the specified array object.

Method Summary

TemplateModel
get(int index)
boolean
isEmpty()
Tells whether the model is empty.
TemplateModelIterator
iterator()
int
size()

Methods inherited from class freemarker.ext.beans.BeanModel

get, getAdaptedObject, getWrappedObject, hasPlainGetMethod, invokeGenericGet, isEmpty, keySet, keys, size, toString, unwrap, values, wrap

Constructor Details

ArrayModel

public ArrayModel(Object array,
                  BeansWrapper wrapper)
Creates a new model that wraps the specified array object.
Parameters:
array - the array object to wrap into a model.
wrapper - the BeansWrapper associated with this model. Every model has to have an associated BeansWrapper instance. The model gains many attributes from its wrapper, including the caching behavior, method exposure level, method-over-item shadowing policy etc.

Method Details

get

public TemplateModel get(int index)
            throws TemplateModelException
Specified by:
get in interface TemplateSequenceModel

isEmpty

public boolean isEmpty()
Tells whether the model is empty. It is empty if either the wrapped object is null, or it is a Boolean with false value.
Specified by:
isEmpty in interface TemplateHashModel
Overrides:
isEmpty in interface BeanModel

iterator

public TemplateModelIterator iterator()
Specified by:
iterator in interface TemplateCollectionModel

size

public int size()
Specified by:
size in interface TemplateSequenceModel
size in interface TemplateHashModelEx
Overrides:
size in interface BeanModel