freemarker.template
Class SimpleHash

java.lang.Object
  |
  +--freemarker.template.SimpleHash

public class SimpleHash
extends java.lang.Object
implements TemplateModelRoot, java.io.Serializable

A simple implementation of the TemplateHashModel and TemplateModelRoot interfaces, using a HashMap.

All the public methods in this implementation are synchronized.

See Also:
Serialized Form

Field Summary
protected  java.util.HashMap hash
           
 
Constructor Summary
SimpleHash()
          Constructs an empty SimpleHash.
 
Method Summary
 TemplateModel get(java.lang.String key)
           
 boolean isEmpty()
           
 void put(java.lang.String key, boolean b)
          Puts a boolean in the hash, by first wrapping the boolean in a SimpleScalar.
 void put(java.lang.String key, java.lang.String s)
          Puts a string in the hash, by first wrapping the string in a SimpleScalar.
 void put(java.lang.String key, TemplateModel model)
          Puts a TemplateModel in the hash.
 void remove(java.lang.String key)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hash

protected java.util.HashMap hash
Constructor Detail

SimpleHash

public SimpleHash()
Constructs an empty SimpleHash.
Method Detail

isEmpty

public boolean isEmpty()
                throws TemplateModelException

put

public void put(java.lang.String key,
                TemplateModel model)
Puts a TemplateModel in the hash.
Specified by:
put in interface TemplateModelRoot
Parameters:
key - the name by which the TemplateModel is identified in the template.
model - the TemplateModel to store.

put

public void put(java.lang.String key,
                java.lang.String s)
Puts a string in the hash, by first wrapping the string in a SimpleScalar.
Parameters:
key - the name by which the resulting TemplateModel is identified in the template.
s - the string to store.

put

public void put(java.lang.String key,
                boolean b)
Puts a boolean in the hash, by first wrapping the boolean in a SimpleScalar.
Parameters:
key - the name by which the resulting TemplateModel is identified in the template.
b - the boolean to store.

get

public TemplateModel get(java.lang.String key)
                  throws TemplateModelException

remove

public void remove(java.lang.String key)
Specified by:
remove in interface TemplateModelRoot