org.szegedi.expose.model
Class ReflectionRootModel

java.lang.Object
  |
  +--org.szegedi.expose.model.ReflectionRootModel
All Implemented Interfaces:
freemarker.template.TemplateHashModel, freemarker.template.TemplateModel, freemarker.template.TemplateModelRoot

public class ReflectionRootModel
extends java.lang.Object
implements freemarker.template.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 ReflectionUtilities.wrap(java.lang.Object).

Version:
1.0
Author:
Attila Szegedi, Scriptum Inc.

Constructor Summary
ReflectionRootModel()
          Creates a new model with its own internal map.
ReflectionRootModel(java.util.Map map)
          Creates a new model that adds TemplateModelRoot behavior to the passed map.
 
Method Summary
 freemarker.template.TemplateModel get(java.lang.String key)
          Returns ReflectionUtilities.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, freemarker.template.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

ReflectionRootModel

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

ReflectionRootModel

public ReflectionRootModel(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 freemarker.template.TemplateModel

get

public freemarker.template.TemplateModel get(java.lang.String key)
Returns ReflectionUtilities.wrap(map.get(key)) where map is the underlying map.
Specified by:
get in interface freemarker.template.TemplateHashModel

put

public void put(java.lang.String key,
                freemarker.template.TemplateModel model)
Puts the specified template model into the map.
Specified by:
put in interface freemarker.template.TemplateModelRoot

remove

public void remove(java.lang.String key)
Removes the template model with the specified key from the map.
Specified by:
remove in interface freemarker.template.TemplateModelRoot