|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--org.szegedi.expose.model.ReflectionObjectModelBase
|
+--org.szegedi.expose.model.ReflectionArrayModel
A class that will wrap an arbitrary array into
TemplateHashModel, TemplateMethodModel, and TemplateListModel
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. Except supporting retrieval through array.index syntax
and array("index") syntax, it also supports the array.length
syntax for retrieving the length of the array.
Using the model as a list model is thread-safe, as it maintains the list position
on a per-thread basis.
| Fields inherited from class org.szegedi.expose.model.ReflectionObjectModelBase |
TYPE_ARRAY, TYPE_COLLECTION, TYPE_ENUMERATION, TYPE_ITERATOR, TYPE_MAP, TYPE_OBJECT, TYPE_OBJECT_BASE, TYPE_RESOURCE_BUNDLE |
| Constructor Summary | |
ReflectionArrayModel(java.lang.Object array)
Creates a new model that wraps the specified array object. |
|
| Method Summary | |
freemarker.template.TemplateModel |
exec(java.util.List arguments)
The first argument of the list is interpreted as an array index (it can be either a Number, or a String containing parseable integer). |
freemarker.template.TemplateModel |
get(int index)
Retrieves an array element by its index, wrapped into an appropriate template model. |
freemarker.template.TemplateModel |
get(java.lang.String key)
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. |
static ReflectionArrayModel |
getInstance(java.lang.Object object)
Returns a model wrapping the specified array object. |
int |
getType()
Returns the type of this object (which is TYPE_ARRAY) |
boolean |
hasNext()
True if the list pointer is not past the last element of the array |
boolean |
isEmpty()
Returns true if the wrapped array is null, or its length is 0. |
boolean |
isRewound()
True if the list pointer points to the first element of the array |
freemarker.template.TemplateModel |
listSize()
Returns a Simple scalar with a string containing the decimal representation of the array size. |
freemarker.template.TemplateModel |
next()
Returns the array element at the list pointer, advances list pointer by one |
void |
rewind()
Rewinds the list pointer to the first element of the array |
| Methods inherited from class org.szegedi.expose.model.ReflectionObjectModelBase |
getAsString, getInstance, getObject |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ReflectionArrayModel(java.lang.Object array)
object - 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 ReflectionArrayModel 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 int getType()
getType in class ReflectionObjectModelBasepublic freemarker.template.TemplateModel get(java.lang.String key)
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 freemarker.template.TemplateHashModel
public freemarker.template.TemplateModel exec(java.util.List arguments)
throws freemarker.template.TemplateModelException
exec in interface freemarker.template.TemplateMethodModelpublic freemarker.template.TemplateModel get(int index)
public boolean isEmpty()
isEmpty in interface freemarker.template.TemplateModelisEmpty in class ReflectionObjectModelBasepublic boolean hasNext()
hasNext in interface freemarker.template.TemplateListModelpublic boolean isRewound()
isRewound in interface freemarker.template.TemplateListModelpublic freemarker.template.TemplateModel next()
next in interface freemarker.template.TemplateListModelpublic void rewind()
rewind in interface freemarker.template.TemplateListModelpublic freemarker.template.TemplateModel listSize()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||