com.basilv.envgen
Class TemplateMapModel

java.lang.Object
  extended by com.basilv.envgen.TemplateMapModel
All Implemented Interfaces:
TemplateHashModel, TemplateModel, TemplateScalarModel

public class TemplateMapModel
extends Object
implements TemplateHashModel, TemplateScalarModel

Adapts a Map of property names and values to Freemarker's TemplateModel interface. Properties of the form "foo.bar" need special handling, as FreeMarker considers a period to be a dereference operator, and thus first looks up property "foo", and then in the result looks up property "bar". So we store these properties in the same fashion. This class can represent both a simple string value for a given property, or a map of properties. This allows it to store the properties "foo.bar=one" and "foo.bar.baz=two" as follows. The property "foo" is mapped to instance #2 of this class. Instance #2 has property "bar", which maps to instance #3 that holds the string value "one" and holds the property "baz" which maps to instance #4 that just holds the string value "two".


Field Summary
 
Fields inherited from interface freemarker.template.TemplateModel
NOTHING
 
Fields inherited from interface freemarker.template.TemplateScalarModel
EMPTY_STRING
 
Fields inherited from interface freemarker.template.TemplateModel
NOTHING
 
Constructor Summary
TemplateMapModel(Map properties)
           
 
Method Summary
 TemplateModel get(String key)
           
 String getAsString()
           
 TemplateMapModel getAsTemplateMapModel(String key)
           
 boolean isEmpty()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateMapModel

public TemplateMapModel(Map properties)
Method Detail

getAsTemplateMapModel

public TemplateMapModel getAsTemplateMapModel(String key)

get

public TemplateModel get(String key)
Specified by:
get in interface TemplateHashModel

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface TemplateHashModel

getAsString

public String getAsString()
Specified by:
getAsString in interface TemplateScalarModel


EnvGen available from www.basilv.com/psd/software Copyright © 2007 Basil Vandegriend. All Rights Reserved.