public class JythonHashModel extends JythonModel implements TemplateHashModelEx
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.object, wrapper
NOTHING
FALSE, TRUE
EMPTY_STRING
Constructor and Description |
---|
JythonHashModel(org.python.core.PyObject object,
JythonWrapper wrapper) |
Modifier and Type | Method and Description |
---|---|
TemplateCollectionModel |
keys()
Returns either
object. |
int |
size()
Returns
PyObject.__len__() . |
TemplateCollectionModel |
values()
Returns
object. |
exec, get, getAdaptedObject, getAsBoolean, getAsString, getWrappedObject, isEmpty
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
get, isEmpty
public JythonHashModel(org.python.core.PyObject object, JythonWrapper wrapper)
public int size() throws TemplateModelException
PyObject.__len__()
.size
in interface TemplateHashModelEx
TemplateModelException
public TemplateCollectionModel keys() throws TemplateModelException
object.__findattr__("keys").__call__()
or object.__findattr__("keySet").__call__()
.keys
in interface TemplateHashModelEx
TemplateScalarModel
(as the keys of hashes are always strings).TemplateModelException
public TemplateCollectionModel values() throws TemplateModelException
object.__findattr__("values").__call__()
.values
in interface TemplateHashModelEx
TemplateModel
-s.TemplateModelException