org.python.core.adapter
Class ClassicPyObjectAdapter

java.lang.Object
  extended by org.python.core.adapter.ExtensiblePyObjectAdapter
      extended by org.python.core.adapter.ClassicPyObjectAdapter
All Implemented Interfaces:
PyObjectAdapter

public class ClassicPyObjectAdapter
extends ExtensiblePyObjectAdapter

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
ClassicPyObjectAdapter()
           
 
Method Summary
 PyObject adapt(Object o)
          Attempts to adapt o using the preClass, class and postClass adapters.
 boolean canAdapt(Object o)
          Always returns true as we just return new PyJavaInstance(o) if the adapters added to the superclass can't handle o.
 
Methods inherited from class org.python.core.adapter.ExtensiblePyObjectAdapter
add, addPostClass, addPreClass
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassicPyObjectAdapter

public ClassicPyObjectAdapter()
Method Detail

canAdapt

public boolean canAdapt(Object o)
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 interface PyObjectAdapter
Overrides:
canAdapt in class ExtensiblePyObjectAdapter
Returns:
true if a preClass, postClass or class adapter can handle this

adapt

public PyObject adapt(Object o)
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 interface PyObjectAdapter
Overrides:
adapt in class ExtensiblePyObjectAdapter


Jython homepage