freemarker.ext.beans
Class MapModel
- AdapterTemplateModel, TemplateHashModel, TemplateHashModelEx, TemplateMethodModel, TemplateMethodModelEx, TemplateModel, TemplateScalarModel, WrapperTemplateModel
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.
$Id: MapModel.java,v 1.26.2.3 2006/02/26 18:26:37 revusky Exp $
Object | exec(List arguments) - The first argument is used as a key to call the map's get method.
|
protected TemplateModel | invokeGenericGet(Map keyMap, Class clazz, 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 Set | keySet() - Helper method to support TemplateHashModelEx.
|
int | size()
|
get , getAdaptedObject , getWrappedObject , hasPlainGetMethod , invokeGenericGet , isEmpty , keySet , keys , size , toString , unwrap , values , wrap |
MapModel
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.
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.
- isEmpty in interface TemplateHashModel
- isEmpty in interface BeanModel
keySet
protected Set keySet()
Helper method to support TemplateHashModelEx. Returns the Set of
Strings which are available via the TemplateHashModel
interface. Subclasses that override invokeGenericGet to
provide additional hash keys should also override this method.
- keySet in interface BeanModel