Package freemarker.ext.jython
Class JythonHashModel
java.lang.Object
freemarker.ext.jython.JythonModel
freemarker.ext.jython.JythonHashModel
- All Implemented Interfaces:
WrapperTemplateModel,AdapterTemplateModel,TemplateBooleanModel,TemplateHashModel,TemplateHashModelEx,TemplateMethodModel,TemplateMethodModelEx,TemplateModel,TemplateScalarModel
Model for Jython dictionaries (
PyDictionary
and PyStringMap).
Note that the basic JythonModel already provides access to the
PyObject.__finditem__(String) method. This class only adds
TemplateHashModelEx functionality in a somewhat skewed way. One
could say it even violates TemplateHashModelEx semantics, as both the
returned keys and values are only those from the item mapping, while the
get() method works for attributes as well. However, in practice
when you ask for dict?keys inside a template, you'll really
want to retrieve only items, not attributes so this is considered OK.-
Field Summary
Fields inherited from class freemarker.ext.jython.JythonModel
object, wrapperFields inherited from interface freemarker.template.TemplateBooleanModel
FALSE, TRUEFields inherited from interface freemarker.template.TemplateModel
NOTHINGFields inherited from interface freemarker.template.TemplateScalarModel
EMPTY_STRING -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class freemarker.ext.jython.JythonModel
exec, get, getAdaptedObject, getAsBoolean, getAsString, getWrappedObject, isEmptyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface freemarker.template.TemplateHashModel
get, isEmpty
-
Constructor Details
-
JythonHashModel
-
-
Method Details
-
size
ReturnsPyObject.__len__().- Specified by:
sizein interfaceTemplateHashModelEx- Returns:
- the number of key/value mappings in the hash.
- Throws:
TemplateModelException
-
keys
Returns eitherobject.__findattr__("keys").__call__()orobject.__findattr__("keySet").__call__().- Specified by:
keysin interfaceTemplateHashModelEx- Returns:
- a collection containing the keys in the hash. Every element of
the returned collection must implement the
TemplateScalarModel(as the keys of hashes are always strings). - Throws:
TemplateModelException
-
values
Returnsobject.__findattr__("values").__call__().- Specified by:
valuesin interfaceTemplateHashModelEx- Returns:
- a collection containing the values in the hash. The elements of the
returned collection can be any kind of
TemplateModel-s. - Throws:
TemplateModelException
-