freemarker.ext.beans
Class RootMapModel

java.lang.Object
  |
  +--freemarker.ext.beans.RootMapModel
All Implemented Interfaces:
TemplateHashModel, TemplateModel, TemplateModelRoot

public class RootMapModel
extends java.lang.Object
implements TemplateModelRoot

A wrapper for an arbitrary map that will expose it as a TemplateModelRoot. All values returned from the get(java.lang.String) method are automatically passed through BeansWrapper.wrap(java.lang.Object).

Version:
$Id: RootMapModel.java,v 1.3 2002/05/11 10:20:30 run2000 Exp $
Author:
Attila Szegedi, Scriptum Inc.

Constructor Summary
RootMapModel()
          Creates a new model with its own internal map.
RootMapModel(java.util.Map map)
          Creates a new model that adds TemplateModelRoot behavior to the passed map.
 
Method Summary
 TemplateModel get(java.lang.String key)
          Returns BeansWrapper.wrap(map.get(key)) where map is the underlying Map.
 boolean isEmpty()
          Returns map.isEmpty() where map is the underlying map.
 void put(java.lang.String key, TemplateModel model)
          Puts the specified template model into the map.
 void remove(java.lang.String key)
          Removes the template model with the specified key from the map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RootMapModel

public RootMapModel()
Creates a new model with its own internal map.

RootMapModel

public RootMapModel(java.util.Map map)
Creates a new model that adds TemplateModelRoot behavior to the passed map.
Method Detail

isEmpty

public boolean isEmpty()
Returns map.isEmpty() where map is the underlying map.
Specified by:
isEmpty in interface TemplateModel
Following copied from interface: freemarker.template.TemplateModel
Returns:
true if this object is empty, otherwise false

get

public TemplateModel get(java.lang.String key)
Returns BeansWrapper.wrap(map.get(key)) where map is the underlying Map.
Specified by:
get in interface TemplateHashModel
Following copied from interface: freemarker.template.TemplateHashModel
Parameters:
key - the name by which the TemplateModel is identified in the template.
Returns:
the TemplateModel referred to by the key, or null if not found.

put

public void put(java.lang.String key,
                TemplateModel model)
Puts the specified template model into the map.
Specified by:
put in interface TemplateModelRoot
Following copied from interface: freemarker.template.TemplateModelRoot
Parameters:
key - the hash key.
model - the hash value to be added.

remove

public void remove(java.lang.String key)
Removes the template model with the specified key from the map.
Specified by:
remove in interface TemplateModelRoot
Following copied from interface: freemarker.template.TemplateModelRoot
Parameters:
key - the key to be removed.