Home » freemarker-2.3.13 » freemarker.ext.beans » [javadoc | source]
public class: MapModel [javadoc | source]

All Implemented Interfaces:
    TemplateMethodModelEx, TemplateScalarModel, AdapterTemplateModel, WrapperTemplateModel, TemplateHashModelEx

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 freemarker.template.TemplateCollectionModel . You can, however use map.entrySet(), map.keySet(), or map.values() to obtain freemarker.template.TemplateCollectionModel instances for various aspects of the map.

Field Summary
static final  ModelFactory FACTORY     
Fields inherited from freemarker.ext.beans.StringModel:
Fields inherited from freemarker.ext.beans.BeanModel:
object,  wrapper,  FACTORY
 public MapModel(Map map,
    BeansWrapper wrapper) 
    Creates a new model that wraps the specified map object.
    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 from freemarker.ext.beans.MapModel Summary:
exec,   invokeGenericGet,   isEmpty,   keySet,   size
Methods from freemarker.ext.beans.StringModel:
Methods from freemarker.ext.beans.BeanModel:
get,   getAdaptedObject,   getWrappedObject,   hasPlainGetMethod,   invokeGenericGet,   isEmpty,   keySet,   keys,   size,   toString,   unwrap,   values,   wrap
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from freemarker.ext.beans.MapModel Detail:
 public Object exec(List arguments) throws TemplateModelException 
    The first argument is used as a key to call the map's get method.
 protected TemplateModel invokeGenericGet(Map keyMap,
    Class clazz,
    String key) throws TemplateModelException 
    Overridden to invoke the generic get method by casting to Map instead of through reflection - should yield better performance.
 public boolean isEmpty() 
 protected Set keySet() 
 public int size()