public class PyObject extends JepAccess implements java.lang.AutoCloseable
Modifier and Type | Method and Description |
---|---|
<T> T |
as(java.lang.Class<T> expectedType)
Attempt to convert this object to a Java equivalant using the builtin Jep
conversions.
|
void |
close() |
void |
delAttr(java.lang.String attr_name)
Deletes an attribute on the wrapped Python object, similar to the Python
built-in function delattr.
|
boolean |
equals(java.lang.Object obj)
Checks that the Java type matches and if so then uses Python's rich
compare with the == operator to check if this wrapped Python object
matches the other PyObject.
|
java.lang.Object |
getAttr(java.lang.String attr_name)
Access an attribute of the wrapped Python Object, similar to the Python
built-in function getattr.
|
<T> T |
getAttr(java.lang.String attr_name,
java.lang.Class<T> clazz)
Access an attribute of the wrapped Python Object, similar to the Python
built-in function getattr.
|
int |
hashCode()
Produces the hash code of the wrapped Python object by using the Python
built-in method hash.
|
<T> T |
proxy(java.lang.Class<T> primaryInterface,
java.lang.Class<?>... extraInterfaces)
Create a dynamic proxy that implements the provided interfaces by calling
the corresponding Python methods on this PyObject.
|
void |
setAttr(java.lang.String attr_name,
java.lang.Object o)
Sets an attribute on the wrapped Python object, similar to the Python
built-in function setattr.
|
java.lang.String |
toString()
Produces the string representation of the wrapped Python object by using
the Python built-in method str.
|
public void close() throws JepException
close
in interface java.lang.AutoCloseable
JepException
public java.lang.Object getAttr(java.lang.String attr_name) throws JepException
this.attr_name
.attr_name
- the attribute nameJepException
- if an error occurspublic <T> T getAttr(java.lang.String attr_name, java.lang.Class<T> clazz) throws JepException
Jep.getValue(String, Class)
.T
- the generic type of the return typeattr_name
- the attribute nameclazz
- the Java class of the return type.JepException
- if an error occurspublic void setAttr(java.lang.String attr_name, java.lang.Object o) throws JepException
this.attr_name = o
.attr_name
- the attribute nameo
- the object to set as an attributeJepException
- if an error occurspublic void delAttr(java.lang.String attr_name) throws JepException
del this.attr_name
.attr_name
- the name of the attribute to be deletedJepException
- if an error occurspublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public <T> T proxy(java.lang.Class<T> primaryInterface, java.lang.Class<?>... extraInterfaces) throws JepException
T
- the generic type of the return typeprimaryInterface
- A interface the returned object will implementextraInterfaces
- Optional additional interfaces the returned object will also
implement.JepException
- if an error occurs or the conversion is not possiblepublic <T> T as(java.lang.Class<T> expectedType) throws JepException
Interpreter.getValue(String, Class)
.T
- the generic type of the return typeexpectedType
- the Java class of the return type.JepException
- if an error occurs or the conversion is not possible