cz.cuni.amis.introspection.python
Class PyObjectWrapper

Package class diagram package PyObjectWrapper
java.lang.Object
  extended by cz.cuni.amis.introspection.python.PyObjectWrapper
Direct Known Subclasses:
PyDictionaryWrapper, PyFloatWrapper, PyInstanceWrapper, PyIntegerWrapper, PyListWrapper, PyLongWrapper, PyStringWrapper, PyTupleWrapper, PyUnsupportedWrapper

public abstract class PyObjectWrapper
extends Object


Constructor Summary
PyObjectWrapper(Class javaClass)
           
 
Method Summary
abstract  ArrayList<PyObjectAdapter> getChildren(Object pyObject)
          If the PyObject contains children (e.g.
 Class getJavaClass()
          Returns class which PyObject represents and whose instance is expected in the set() method as parameter
abstract  Object getJavaObject(Object pyObject)
          Returns java representation of the object.
abstract  org.python.core.PyObject getNewValue(Object newValue)
          Creates instance of correct descendant of the PyObject according to the type of wrapper from newValue.
abstract  boolean hasChildren(Object pyObject)
          Whether the wrapper may have children (e.g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PyObjectWrapper

public PyObjectWrapper(Class javaClass)
Method Detail

getJavaClass

public Class getJavaClass()
Returns class which PyObject represents and whose instance is expected in the set() method as parameter

Returns:
JavaClass

getChildren

public abstract ArrayList<PyObjectAdapter> getChildren(Object pyObject)
If the PyObject contains children (e.g. List, Instance, Dictionary), they are returned as list of PyObjectAdapter.

Returns:
list of PyObjectAdapter if the pyObject contains children (List, Instance, etc.)

hasChildren

public abstract boolean hasChildren(Object pyObject)
Whether the wrapper may have children (e.g. List, Instance, Dictionary). Warning - it does not tells anything about the number of children. For instance - if it's list which doesn't have any items, it will still return true.

Returns:
true if wrapper can have a child (or more children)

getJavaObject

public abstract Object getJavaObject(Object pyObject)
Returns java representation of the object. This works well for BASIC_TYPEs, others are returned as String representations. Note that basic type wrappers (PyInteger, PyLong, PyFloat, PyString) handles also the java type of objects because the ScriptEngine sometimes return those types in their java representations.

Returns:
Object Java representation of the object

getNewValue

public abstract org.python.core.PyObject getNewValue(Object newValue)
Creates instance of correct descendant of the PyObject according to the type of wrapper from newValue. New value must be instance of the class which returns getJavaClass().

Parameters:
newValue -


Copyright © 2014 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.