| 
 | |||||||||
| 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.ArrayModel
freemarker.ext.beans2 package
public final class ArrayModel
A class that will wrap an arbitrary array into TemplateHashModel,
 TemplateMethodModel2, TemplateIndexedModel and
 TemplateListModel2 interfaces.
The models are cached (meaning requesting a model for same object twice will return the same model instance) unless the system property expose.reflection.nocache is set to true.
Apart from supporting retrieval through array[index] syntax
 and array("index") syntax, it also supports the array.length
 syntax for retrieving the length of the array. A template can iterate over
 the array directly using the <list> or
 <foreach> syntax.
The array.iterator syntax for retrieving a
 TemplateListModel2 interface backed by this array
 is supported for backward compatibility with earlier releases.
Using the model as a list model is thread-safe, as it maintains the
 list position on a per-iterator basis using the new TemplateListModel2
 interface.
| Field Summary | 
|---|
| Fields inherited from class freemarker.ext.beans.ObjectModelBase | 
|---|
| object | 
| Constructor Summary | |
|---|---|
| ArrayModel(java.lang.Object array)Deprecated. Creates a new model that wraps the specified array object. | |
| Method Summary | |
|---|---|
|  TemplateModel | exec(java.util.List<TemplateModel> arguments)Deprecated. The first argument of the list is interpreted as an array index (it can be either a Number, or a String containing parseable integer). | 
|  TemplateModel | get(java.lang.String key)Deprecated. If the key can be parsed by the java.lang.Integer#parseInt(java.lang.String)method into an
 array index, the array element at the parsed index is returned. | 
|  TemplateModel | getAtIndex(long index)Deprecated. Retrive the object at the specified index. | 
| static ArrayModel | getInstance(java.lang.Object object)Deprecated. Returns a model wrapping the specified array object. | 
|  freemarker.ext.beans.ObjectModelBase.ModelType | getType()Deprecated. Returns the type of this object (which is TYPE_ARRAY) | 
|  boolean | isEmpty()Deprecated. Returns true if the wrapped array is null, or its length is 0. | 
|  void | releaseIterator(TemplateIteratorModel iterator)Deprecated. Return the iterator to the object pool, if any. | 
|  TemplateIteratorModel | templateIterator()Deprecated. Retrieve an iterator over this array. | 
| 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 ArrayModel(java.lang.Object array)
array - the array object to wrap into a model.
java.lang.IllegalArgumentException - if the passed object is not a Java array.| Method Detail | 
|---|
public static final ArrayModel getInstance(java.lang.Object 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 array to wrap into a model.
java.lang.IllegalArgumentException - if the passed object is not a Java array.public freemarker.ext.beans.ObjectModelBase.ModelType getType()
getType in class ObjectModelBase
public TemplateModel get(java.lang.String key)
                  throws TemplateModelException
java.lang.Integer#parseInt(java.lang.String) method into an
 array index, the array element at the parsed index is returned. If the
 key is named "length", the length of the array is returned.
get in interface TemplateHashModelkey - the name by which the TemplateModel
 is identified in the template.
TemplateModel referred to by the key,
 or null if not found.
TemplateModelException - there was a problem getting the value
 for the given key
public TemplateModel exec(java.util.List<TemplateModel> arguments)
                   throws TemplateModelException
exec in interface TemplateMethodModel2arguments - a List of TemplateModel objects
 containing the values of the arguments passed to the method.
TemplateModel produced by the method, or null.
TemplateModelException
public TemplateModel getAtIndex(long index)
                         throws TemplateModelException
getAtIndex in interface TemplateIndexedModelindex - the index of the object to be retrieved
TemplateModelException - the value could not be determined, possibly
 due to an index out-of-bounds, or an otherwise undefined value
public TemplateIteratorModel templateIterator()
                                       throws TemplateModelException
templateIterator in interface TemplateListModel2null if the array
 is empty
TemplateModelExceptionpublic void releaseIterator(TemplateIteratorModel iterator)
releaseIterator in interface TemplateListModel2iterator - the iterator to be returnedpublic boolean isEmpty()
isEmpty in interface TemplateModelisEmpty in class ObjectModelBasetrue if this object is empty, otherwise false| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||