Py#java2py 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.
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private static class |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public PyObject | adapt(Object o)
Overrides org. Implements org. Attempts to adapt o using the preClass, class and postClass adapters. |
| public boolean | canAdapt(Object o)
Overrides org. Implements org. Always returns true as we just return new PyJavaInstance(o) if the adapters added to the superclass can't handle o. |
| ClassicPyObjectAdapter | back to summary |
|---|---|
| public ClassicPyObjectAdapter() | |
| adapt | back to summary |
|---|---|
| public PyObject adapt(Object o) Overrides org. Implements org. Doc from org. 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.
| |
| canAdapt | back to summary |
|---|---|
| public boolean canAdapt(Object o) Overrides org. Implements org. Always returns true as we just return new PyJavaInstance(o) if the adapters added to the superclass can't handle o.
| |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public PyObject | adapt(Object o)
Implements org. Returns the PyObject version of o or null if canAdapt(o) returns false. |
| NumberToPyFloat | back to summary |
|---|---|
| public NumberToPyFloat(Class<T> c) | |
| adapt | back to summary |
|---|---|
| public PyObject adapt(Object o) Implements org. Doc from org. Returns the PyObject version of o or null if canAdapt(o) returns false.
| |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public PyObject | adapt(Object o)
Implements org. Returns the PyObject version of o or null if canAdapt(o) returns false. |
| NumberToPyInteger | back to summary |
|---|---|
| public NumberToPyInteger(Class<T> c) | |
| adapt | back to summary |
|---|---|
| public PyObject adapt(Object o) Implements org. Doc from org. Returns the PyObject version of o or null if canAdapt(o) returns false.
| |