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:
1.0
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.
 java.util.Locale getLocale()
          gets the locale to be used for number/date formatting (A hook for later user currently -- revusky)
 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.
 void setLocale(java.util.Locale locale)
          sets the locale to be used for number/date formatting (A hook for later user currently -- revusky)
 
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.

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.

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.

setLocale

public void setLocale(java.util.Locale locale)
Description copied from interface: TemplateModelRoot
sets the locale to be used for number/date formatting (A hook for later user currently -- revusky)
Specified by:
setLocale in interface TemplateModelRoot

getLocale

public java.util.Locale getLocale()
Description copied from interface: TemplateModelRoot
gets the locale to be used for number/date formatting (A hook for later user currently -- revusky)
Specified by:
getLocale in interface TemplateModelRoot