Package org.python.core.adapter
Class ClassicPyObjectAdapter
java.lang.Object
org.python.core.adapter.ExtensiblePyObjectAdapter
org.python.core.adapter.ClassicPyObjectAdapter
- All Implemented Interfaces:
PyObjectAdapter
Implements the algorithm originally used in
Py.java2py(java.lang.Object)
to adapt objects.
Pre-class adapters are added to handle instances of PyObject, PyProxy and null values. Class
adapters are added to handle builtin Java classes: String, Integer, Float, Double, Byte, Long,
Short, Character, Class and Boolean. An adapter is added to the post-class adapters to handle
wrapping arrays properly. Finally, if all of the added adapters can handle an object, it's
wrapped in a PyJavaInstance.-
Constructor Summary
-
Method Summary
Methods inherited from class org.python.core.adapter.ExtensiblePyObjectAdapter
add, addPostClass, addPreClass
-
Constructor Details
-
ClassicPyObjectAdapter
public ClassicPyObjectAdapter()
-
-
Method Details
-
canAdapt
Always returns true as we just return new PyJavaInstance(o) if the adapters added to the superclass can't handle o.- Specified by:
canAdapt
in interfacePyObjectAdapter
- Overrides:
canAdapt
in classExtensiblePyObjectAdapter
- Returns:
- true if a preClass, postClass or class adapter can handle this
-
adapt
Description copied from class:ExtensiblePyObjectAdapter
Attempts to adapt o using the preClass, class and postClass adapters. First each of the preClass adapters is asked in the order of addition if they can adapt o. If so, they adapt it. Otherwise, if o.getClass() is equal to one of the classes from the added ClassAdapters, that class adapter is used. Finally, each of the post class adapters are asked in turn if they can adapt o. If so, that adapter handles it. If none can, null is returned.- Specified by:
adapt
in interfacePyObjectAdapter
- Overrides:
adapt
in classExtensiblePyObjectAdapter
-