freemarker.ext.beans
Class MapModel

java.lang.Object
  extended by freemarker.ext.beans.ObjectModelBase
      extended by freemarker.ext.beans.ObjectModel
          extended by freemarker.ext.beans.MapModel
All Implemented Interfaces:
TemplateHashModel, TemplateMethodModel2, TemplateModel, TemplateObjectModel, TemplateScalarModel, java.io.Serializable

Deprecated. this class is deprecated in favour of the classes in the freemarker.ext.beans2 package

public class MapModel
extends ObjectModel
implements TemplateMethodModel2

A special case of ObjectModel that adds implementation for TemplateMethodModel2 on map objects that is a shortcut for the Map.get() method.

You can use map.entrySet, map.keySet, or map.values to obtain TemplateListModel2 instances for various aspects of the map.

Version:
$Id: MapModel.java 1101 2013-04-01 04:17:32Z run2000 $
Author:
Attila Szegedi, attila@szegedi.org
See Also:
Serialized Form

Field Summary
 
Fields inherited from class freemarker.ext.beans.ObjectModelBase
object
 
Constructor Summary
MapModel(java.util.Map map)
          Deprecated. Creates a new model that wraps the specified map object.
 
Method Summary
 TemplateModel exec(java.util.List<TemplateModel> arguments)
          Deprecated. The first argument is used as a key to call the map's get method.
static MapModel getInstance(java.util.Map object)
          Deprecated. Returns a model wrapping the specified map object.
 freemarker.ext.beans.ObjectModelBase.ModelType getType()
          Deprecated. Returns the type of this object (which is TYPE_MAP)
 boolean isEmpty()
          Deprecated. Returns true if the underlying map is empty.
 
Methods inherited from class freemarker.ext.beans.ObjectModel
get, getInstance
 
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

MapModel

public MapModel(java.util.Map map)
Deprecated. 
Creates a new model that wraps the specified map object.

Parameters:
map - the map object to wrap into a model.
Method Detail

getInstance

public static final MapModel getInstance(java.util.Map object)
Deprecated. 
Returns a model wrapping the specified map object. If there is already a cached model instance for this map, returns the cached model instance. Models are cached using 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.

Parameters:
object - the map to wrap into a model.
Returns:
the model for the map

getType

public freemarker.ext.beans.ObjectModelBase.ModelType getType()
Deprecated. 
Returns the type of this object (which is TYPE_MAP)

Overrides:
getType in class ObjectModel

exec

public TemplateModel exec(java.util.List<TemplateModel> arguments)
                   throws TemplateModelException
Deprecated. 
The first argument is used as a key to call the map's get method.

Specified by:
exec in interface TemplateMethodModel2
Parameters:
arguments - a List of TemplateModel objects containing the values of the arguments passed to the method.
Returns:
the TemplateModel produced by the method, or null.
Throws:
TemplateModelException

isEmpty

public boolean isEmpty()
Deprecated. 
Returns true if the underlying map is empty.

Specified by:
isEmpty in interface TemplateModel
Overrides:
isEmpty in class ObjectModelBase
Returns:
true if this object is empty, otherwise false