Home » freemarker-2.3.13 » freemarker.template » [javadoc | source]
freemarker.template
public class: SimpleHash [javadoc | source]
java.lang.Object
   freemarker.template.WrappingTemplateModel
      freemarker.template.SimpleHash

All Implemented Interfaces:
    Serializable, TemplateHashModelEx

Direct Known Subclasses:
    AllHttpScopesHashModel, Namespace, SynchronizedHash

A simple implementation of the TemplateHashModelEx interface, using an underlying Map or SortedMap .

This class is thread-safe if you don't call the put or remove methods after you have made the object available for multiple threads.

Note:
As of 2.0, this class is unsynchronized by default. To obtain a synchronized wrapper, call the #synchronizedWrapper method.

Constructor:
 public SimpleHash() 
 public SimpleHash(Map map) 
    Parameters:
    map - The Map to use for the key/value pairs. It makes a copy for internal use. If the map implements the SortedMap interface, the internal copy will be a TreeMap , otherwise it will be a HashMap .
 public SimpleHash(ObjectWrapper wrapper) 
    Creates an empty simple hash using the specified object wrapper.
 public SimpleHash(Map map,
    ObjectWrapper wrapper) 
Method from freemarker.template.SimpleHash Summary:
copyMap,   get,   isEmpty,   keys,   put,   put,   putAll,   remove,   size,   synchronizedWrapper,   toMap,   toString,   values
Methods from freemarker.template.WrappingTemplateModel:
getDefaultObjectWrapper,   getObjectWrapper,   setDefaultObjectWrapper,   setObjectWrapper,   wrap
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from freemarker.template.SimpleHash Detail:
 protected Map copyMap(Map map) 
 public TemplateModel get(String key) throws TemplateModelException 
 public boolean isEmpty() 
 public TemplateCollectionModel keys() 
 public  void put(String key,
    Object obj) 
    Adds a key-value entry to the map.
 public  void put(String key,
    boolean b) 
    Puts a boolean in the map
 public  void putAll(Map m) 
    Adds all the key/value entries in the map
 public  void remove(String key) 
    Removes the given key from the underlying map.
 public int size() 
 public SimpleHash synchronizedWrapper() 
 public Map toMap() throws TemplateModelException 
    Note that this method creates and returns a deep-copy of the underlying hash used internally. This could be a gotcha for some people at some point who want to alter something in the data model, but we should maintain our immutability semantics (at least using default SimpleXXX wrappers) for the data model. It will recursively unwrap the stuff in the underlying container.
 public String toString() 
    Convenience method for returning the String value of the underlying map.
 public TemplateCollectionModel values()