|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object freemarker.ext.beans.BeanModel freemarker.ext.beans.StringModel freemarker.ext.beans.MapModel
public class MapModel
A special case of BeanModel
that adds implementation
for TemplateMethodModelEx
on map objects that is a shortcut for the
Map.get() method. Note that if the passed argument itself is a
reflection-wrapper model, then the map lookup will be performed using the
wrapped object as the key. Note that you can call get() using the
map.key syntax inherited from BeanModel
as well,
however in that case the key is always a string.
The class itself does not implement the TemplateCollectionModel
.
You can, however use map.entrySet(), map.keySet(), or
map.values() to obtain TemplateCollectionModel
instances for
various aspects of the map.
Field Summary |
---|
Fields inherited from class freemarker.ext.beans.BeanModel |
---|
object, wrapper |
Fields inherited from interface freemarker.template.TemplateModel |
---|
NOTHING |
Fields inherited from interface freemarker.template.TemplateScalarModel |
---|
EMPTY_STRING |
Constructor Summary | |
---|---|
MapModel(java.util.Map map,
BeansWrapper wrapper)
Creates a new model that wraps the specified map object. |
Method Summary | |
---|---|
java.lang.Object |
exec(java.util.List arguments)
The first argument is used as a key to call the map's get method. |
protected TemplateModel |
invokeGenericGet(java.util.Map keyMap,
java.lang.Class clazz,
java.lang.String key)
Overridden to invoke the generic get method by casting to Map instead of through reflection - should yield better performance. |
boolean |
isEmpty()
Tells whether the model is empty. |
protected java.util.Set |
keySet()
Helper method to support TemplateHashModelEx. |
int |
size()
|
Methods inherited from class freemarker.ext.beans.StringModel |
---|
getAsString |
Methods inherited from class freemarker.ext.beans.BeanModel |
---|
get, getAdaptedObject, getWrappedObject, hasPlainGetMethod, keys, toString, unwrap, values, wrap |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MapModel(java.util.Map map, BeansWrapper wrapper)
map
- the map 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 Detail |
---|
public java.lang.Object exec(java.util.List arguments) throws TemplateModelException
exec
in interface TemplateMethodModel
exec
in interface TemplateMethodModelEx
arguments
- a List of TemplateModel
objects
containing the values of the arguments passed to the method. If the
implementation wishes to operate on POJOs that might be underlying the
models, it can use the static utility methods in the DeepUnwrap
class to easily obtain them.
TemplateModel
, it will be automatically
wrapped using the environment
object wrapper
.
TemplateModelException
protected TemplateModel invokeGenericGet(java.util.Map keyMap, java.lang.Class clazz, java.lang.String key) throws TemplateModelException
invokeGenericGet
in class BeanModel
TemplateModelException
public boolean isEmpty()
BeanModel
isEmpty
in interface TemplateHashModel
isEmpty
in class BeanModel
public int size()
size
in interface TemplateHashModelEx
size
in class BeanModel
protected java.util.Set keySet()
BeanModel
keySet
in class BeanModel
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |