freemarker.ext.misc
Class ExtendedHash
java.lang.Object
freemarker.template.SimpleHash
freemarker.ext.misc.ExtendedHash
- All Implemented Interfaces:
- TemplateHashModel, TemplateModel, TemplateModelRoot, TemplateObjectModel, TemplateWriteableHashModel, java.io.Serializable
public class ExtendedHash
- extends SimpleHash
- implements java.io.Serializable
Simple extension to the SimpleHash implementation.
This class implements a number of convenience facilities in the form of template
hash keys. The hash keys are:
_size - retrieves the number of elements in the hash
_keys - returns an ExtendedList model containing all
keys in the hash
_values - returns an ExtendedList model containing all
values in the hash
- Since:
- 1.7
- Version:
- $Id: ExtendedHash.java 1101 2013-04-01 04:17:32Z run2000 $
- See Also:
ExtendedList,
Serialized Form
| Methods inherited from class freemarker.template.SimpleHash |
equals, getAsObject, hashCode, isEmpty, put, put, put, put, put, remove, toString |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
ExtendedHash
public ExtendedHash()
- Creates new
ExtendedHash.
ExtendedHash
public ExtendedHash(java.util.Map<java.lang.String,? extends TemplateModel> hash)
- Creates new
ExtendedHash given a Map of
values. A defensive copy of the map is made.
- Parameters:
hash - The Map of values to be copied into this
ExtendedHash.
- Throws:
java.lang.NullPointerException - the map value is null
get
public TemplateModel get(java.lang.String key)
throws TemplateModelException
- Gets a
TemplateModel from the hash. If the
key matches one of the special values used in this implementation,
return the special value, otherwise return the value from the underlying
Map.
- Specified by:
get in interface TemplateHashModel- Overrides:
get in class SimpleHash
- 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.
- Throws:
TemplateModelException - there was a problem getting the value
for the given key