|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfreemarker.ext.jython.JythonModel
Generic model for arbitrary Jython objects.
Field Summary | |
protected org.python.core.PyObject |
object
|
protected JythonWrapper |
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 | |
JythonModel(org.python.core.PyObject object,
JythonWrapper wrapper)
|
Method Summary | |
java.lang.Object |
exec(java.util.List arguments)
Executes a method call. |
TemplateModel |
get(java.lang.String key)
Calls PyObject.__findattr__(java.lang.String) , then if it
returns null calls PyObject.__finditem__(java.lang.String) .
|
boolean |
getAsBoolean()
Returns the value of PyObject.__nonzero__() . |
java.lang.String |
getAsString()
Returns the value of Object.toString() . |
java.lang.Object |
getWrappedObject()
Retrieves the object wrapped by this model. |
boolean |
isEmpty()
Returns PyObject.__len__() == 0 . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected final org.python.core.PyObject object
protected final JythonWrapper wrapper
Constructor Detail |
public JythonModel(org.python.core.PyObject object, JythonWrapper wrapper)
Method Detail |
public boolean getAsBoolean() throws TemplateModelException
PyObject.__nonzero__()
.
getAsBoolean
in interface TemplateBooleanModel
TemplateModelException
public java.lang.String getAsString() throws TemplateModelException
Object.toString()
.
getAsString
in interface TemplateScalarModel
TemplateModelException
public TemplateModel get(java.lang.String key) throws TemplateModelException
PyObject.__findattr__(java.lang.String)
, then if it
returns null calls PyObject.__finditem__(java.lang.String)
.
If JythonWrapper.setAttributesShadowItems(boolean)
was called
with false
, the order of calls is reversed (that is, item
lookup takes precedence over attribute lookup).
get
in interface TemplateHashModel
key
- the name by which the TemplateModel
is identified in the template.
TemplateModelException
public boolean isEmpty() throws TemplateModelException
PyObject.__len__()
== 0
.
isEmpty
in interface TemplateHashModel
TemplateModelException
public java.lang.Object exec(java.util.List arguments) throws TemplateModelException
TemplateMethodModel
TemplateScalarModel
s, and evaluated to Strings
before being passed. If some of the passed arguments is not a scalar,
an exception will occur and the method will not be called.
If your method would like to act on actual data model objects instead
of on their String representations, implement the
TemplateMethodModelEx
instead.
exec
in interface TemplateMethodModel
arguments
- a List of String objects
containing the values of the arguments passed to the method.
TemplateModelException
TemplateMethodModel.exec(List)
public java.lang.Object getWrappedObject()
WrapperTemplateModel
getWrappedObject
in interface WrapperTemplateModel
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |