freemarker.ext.jython

Class JythonHashModel

Implemented Interfaces:
AdapterTemplateModel, TemplateBooleanModel, TemplateHashModel, TemplateHashModelEx, TemplateMethodModel, TemplateMethodModelEx, TemplateModel, TemplateScalarModel, WrapperTemplateModel

public class JythonHashModel
extends JythonModel
implements TemplateHashModelEx

Model for Jython dictionaries (org.python.core.PyDictionary and org.python.core.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.
Version:
$Id: JythonHashModel.java,v 1.14 2003/11/12 21:53:40 ddekany Exp $
Author:
Attila Szegedi

Field Summary

Fields inherited from class freemarker.ext.jython.JythonModel

object, wrapper

Fields inherited from interface freemarker.template.TemplateBooleanModel

FALSE, TRUE

Fields inherited from interface freemarker.template.TemplateModel

NOTHING

Fields inherited from interface freemarker.template.TemplateScalarModel

EMPTY_STRING

Constructor Summary

JythonHashModel(PyObject object, JythonWrapper wrapper)

Method Summary

TemplateCollectionModel
keys()
Returns either object.__findattr__("keys").__call__() or object.__findattr__("keySet").__call__().
int
size()
Returns PyObject.__len__().
TemplateCollectionModel
values()
Returns object.__findattr__("values").__call__().

Methods inherited from class freemarker.ext.jython.JythonModel

exec, get, getAdaptedObject, getAsBoolean, getAsString, getWrappedObject, isEmpty

Constructor Details

JythonHashModel

public JythonHashModel(PyObject object,
                       JythonWrapper wrapper)

Method Details

keys

public TemplateCollectionModel keys()
            throws TemplateModelException
Returns either object.__findattr__("keys").__call__() or object.__findattr__("keySet").__call__().
Specified by:
keys in interface TemplateHashModelEx

size

public int size()
            throws TemplateModelException
Returns PyObject.__len__().
Specified by:
size in interface TemplateHashModelEx

values

public TemplateCollectionModel values()
            throws TemplateModelException
Returns object.__findattr__("values").__call__().
Specified by:
values in interface TemplateHashModelEx