cz.cuni.pogamut.introspection.python
Class PyObjectWrapper

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

public abstract class PyObjectWrapper
extends java.lang.Object


Field Summary
private  java.lang.Class javaClass
           
 
Constructor Summary
PyObjectWrapper(java.lang.Class javaClass)
           
 
Method Summary
abstract  java.util.ArrayList<PyObjectAdapter> getChildren(java.lang.Object pyObject)
          If the PyObject contains children (e.g.
 java.lang.Class getJavaClass()
          Returns class which PyObject represents and whose instance is expected in the set() method as parameter
abstract  java.lang.Object getJavaObject(java.lang.Object pyObject)
          Returns java representation of the object.
abstract  PyObject getNewValue(java.lang.Object newValue)
          Creates instance of correct descendant of the PyObject according to the type of wrapper from newValue.
abstract  boolean hasChildren(java.lang.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
 

Field Detail

javaClass

private java.lang.Class javaClass
Constructor Detail

PyObjectWrapper

public PyObjectWrapper(java.lang.Class javaClass)
Method Detail

getJavaClass

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

Returns:
JavaClass

getChildren

public abstract java.util.ArrayList<PyObjectAdapter> getChildren(java.lang.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(java.lang.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 java.lang.Object getJavaObject(java.lang.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 PyObject getNewValue(java.lang.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 -