Top Description Fields Constructors Methods
org.python.core

public Class PyMethod

extends PyObject
implements InvocationHandler, Traverseproc
Class Inheritance
All Implemented Interfaces
org.python.core.Traverseproc, java.lang.reflect.InvocationHandler
Annotations
@ExposedType
name:instancemethod
isBaseType:false
doc:instancemethod(function, instance, class) Create an instance method object.
Imports
org.python.expose.ExposedGet, .ExposedMethod, .ExposedNew, .ExposedSet, .ExposedType, .MethodType, java.lang.reflect.InvocationHandler, .Method, .Proxy

A Python method.

Field Summary

Modifier and TypeField and Description
public PyObject
__func__

The function (or other callable) implementing a method, also available via im_func

public PyObject
__self__

The instance to which a method is bound; None for unbound methods also available via im_self

public PyObject
im_class

The class associated with a method.

public static final PyType
Inherited from org.python.core.PyObject:
attributesgcMonitorGlobalobjtype

Constructor Summary

AccessConstructor and Description
public
PyMethod(PyObject function, PyObject self, PyObject type)

Method Summary

Modifier and TypeMethod and Description
public PyObject
__call__()

Overrides org.python.core.PyObject.__call__.

A variant of the __call__ method with no arguments.

public PyObject
public PyObject
__call__(PyObject
the single argument to the function.
arg0
)

Overrides org.python.core.PyObject.__call__.

A variant of the __call__ method with one argument.

public PyObject
public PyObject
__call__(PyObject
the first argument to the function.
arg0
,
PyObject
the second argument to the function.
arg1
)

Overrides org.python.core.PyObject.__call__.

A variant of the __call__ method with two arguments.

public PyObject
public PyObject
__call__(PyObject
the first argument to the function.
arg0
,
PyObject
the second argument to the function.
arg1
,
PyObject
the third argument to the function.
arg2
)

Overrides org.python.core.PyObject.__call__.

A variant of the __call__ method with three arguments.

public PyObject
public PyObject
__call__(PyObject
the first argument to the function.
arg0
,
PyObject
the second argument to the function.
arg1
,
PyObject
the third argument to the function.
arg2
,
PyObject
the fourth argument to the function.
arg3
)

Overrides org.python.core.PyObject.__call__.

A variant of the __call__ method with four arguments.

public PyObject
public PyObject
__call__(PyObject
the first argument to the function.
arg1
,
PyObject[]
the last arguments to the function (including keyword arguments).
args
,
String[]
the keywords used for all keyword arguments.
keywords
)

Overrides org.python.core.PyObject.__call__.

A variant of the __call__ method with one extra initial argument.

public PyObject
public PyObject
__call__(PyObject[]
all arguments to the function.
args
)

Overrides org.python.core.PyObject.__call__.

A variant of the __call__ method when no keywords are passed.

public PyObject
public PyObject
__call__(PyObject[]
all arguments to the function (including keyword arguments).
args
,
String[]
the keywords used for all keyword arguments.
keywords
)

Overrides org.python.core.PyObject.__call__.

The basic method to override when implementing a callable object.

public PyObject
public int
__cmp__(PyObject
the object to compare this with.
other
)

Overrides org.python.core.PyObject.__cmp__.

Equivalent to the standard Python __cmp__ method.

public PyObject
__findattr_ex__(String name)

Overrides org.python.core.PyObject.__findattr_ex__.

Attribute lookup hook.

public PyObject
__get__(PyObject
- the instance accessing this descriptor. Can be null if this is being accessed by a type.
obj
,
PyObject
- the type accessing this descriptor. Will be null if obj exists as obj is of the type accessing the descriptor.
type
)

Overrides org.python.core.PyObject.__get__.

Get descriptor for this PyObject.

public Object
__tojava__(Class<?>
the Class to convert this PyObject to.
c
)

Overrides org.python.core.PyObject.__tojava__.

Equivalent to the Jython __tojava__ method.

private PyObject
private String
public PyObject
public PyObject
getFunc()
Deprecated

private String
private String
public PyObject
getSelf()
Deprecated

public int
hashCode()

Overrides org.python.core.PyObject.hashCode.

Returns a hash code value for this object.

pack-priv final PyObject
pack-priv final int
pack-priv final PyObject
pack-priv final PyObject
pack-priv final PyObject
pack-priv static final PyObject
instancemethod___new__(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords)

public Object
invoke(Object
the proxy instance that the method was invoked on
proxy
,
Method
the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.
method
,
Object[]
an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.
args
)

Implements java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result.

private Object
proxy(Class<?> c)

public boolean
public String
toString()

Overrides org.python.core.PyObject.toString.

Returns a string representation of the object.

public int
traverse(Visitproc visit, Object arg)

Implements org.python.core.Traverseproc.traverse.

Traverses all directly contained PyObjects.

Inherited from org.python.core.PyObject:
__abs____add____and____coerce____coerce_ex____complex____contains____delattr____delattr____delete____delitem____delitem____delslice____delslice____dir____div____divmod____ensure_finalizer____eq____findattr____findattr____finditem____finditem____finditem____float____floordiv____format____ge____getattr____getattr____getitem____getitem____getnewargs____getslice____getslice____gt____hash____hex____iadd____iand____idiv____idivmod____ifloordiv____ilshift____imod____imul____index____int____invert____ior____ipow____irshift____isub____iter____iternext____itruediv____ixor____le____len____long____lshift____lt____mod____mul____ne____neg____nonzero____not____oct____or____pos____pow____pow____radd____rand____rawdir____rdiv____rdivmod____reduce____reduce_ex____reduce_ex____repr____rfloordiv____rlshift____rmod____rmul____ror____rpow____rrshift____rshift____rsub____rtruediv____rxor____set____setattr____setattr____setitem____setitem____setitem____setslice____setslice____str____sub____truediv____trunc____unicode____xor___add_and_basic_add_basic_and_basic_div_basic_divmod_basic_floordiv_basic_iadd_basic_iand_basic_idiv_basic_idivmod_basic_ifloordiv_basic_ilshift_basic_imod_basic_imul_basic_ior_basic_ipow_basic_irshift_basic_isub_basic_itruediv_basic_ixor_basic_lshift_basic_mod_basic_mul_basic_or_basic_pow_basic_rshift_basic_sub_basic_truediv_basic_xor_callextra_cmp_coerce_div_divmod_doget_doget_doset_eq_floordiv_ge_gt_iadd_iand_idiv_idivmod_ifloordiv_ilshift_imod_imul_in_ior_ipow_irshift_is_isnot_isub_itruediv_ixor_jcall_jcallexc_jthrow_le_lshift_lt_mod_mul_ne_notin_or_pow_rshift_sub_truediv_unsupportedop_xoradaptToCoerceTupleasDoubleasIndexasIndexasIntasIntasIterableasLongasLongasNameasNameasStringasStringasStringOrNullasStringOrNullbit_lengthconjugatedelDictdelTypedispatch__init__equalsfastGetClassfastGetDictfinalizegetDictgetJavaProxygetTypeimpAttrimplementsDescrDeleteimplementsDescrGetimplementsDescrSetinvokeinvokeinvokeinvokeinvokeinvokeisCallableisDataDescrisIndexisIntegerisMappingTypeisNumberTypeisSequenceTypejdontdelmergeClassDictmergeDictAttrmergeListAttrnoAttributeErrorobject___contains__object___delattr__object___delattr__object___findattr__object___format__object___getattribute__object___hash__object___init__object___new__object___reduce__object___reduce_ex__object___setattr__object___setattr__object___subclasshook__object_toStringproxyInitreadonlyAttributeErrorrunsupportedopMessagesetDictsetTypeunsupportedopMessage

Field Detail

__func__back to summary
public PyObject __func__

The function (or other callable) implementing a method, also available via im_func

Annotations
@ExposedGet
doc:the function (or other callable) implementing a method

__self__back to summary
public PyObject __self__

The instance to which a method is bound; None for unbound methods also available via im_self

Annotations
@ExposedGet
doc:the instance to which a method is bound; None for unbound methods

im_classback to summary
public PyObject im_class

The class associated with a method.

Annotations
@ExposedGet
doc:the class associated with a method

TYPEback to summary
public static final PyType TYPE

Hides org.python.core.PyObject.TYPE.

Constructor Detail

PyMethodback to summary
public PyMethod(PyObject function, PyObject self, PyObject type)

Method Detail

__call__back to summary
public PyObject __call__()

Overrides org.python.core.PyObject.__call__.

Doc from org.python.core.PyObject.__call__.

A variant of the __call__ method with no arguments. The default behavior is to invoke __call__(args, keywords) with the appropriate arguments. The only reason to override this function would be for improved performance.

Annotations
@Override
__call__back to summary
public PyObject __call__(ThreadState state)

Overrides org.python.core.PyObject.__call__.

Annotations
@Override
__call__back to summary
public PyObject __call__(PyObject arg0)

Overrides org.python.core.PyObject.__call__.

Doc from org.python.core.PyObject.__call__.

A variant of the __call__ method with one argument. The default behavior is to invoke __call__(args, keywords) with the appropriate arguments. The only reason to override this function would be for improved performance.

Parameters
arg0:PyObject

the single argument to the function.

Annotations
@Override
__call__back to summary
public PyObject __call__(ThreadState state, PyObject arg0)

Overrides org.python.core.PyObject.__call__.

Annotations
@Override
__call__back to summary
public PyObject __call__(PyObject arg0, PyObject arg1)

Overrides org.python.core.PyObject.__call__.

Doc from org.python.core.PyObject.__call__.

A variant of the __call__ method with two arguments. The default behavior is to invoke __call__(args, keywords) with the appropriate arguments. The only reason to override this function would be for improved performance.

Parameters
arg0:PyObject

the first argument to the function.

arg1:PyObject

the second argument to the function.

Annotations
@Override
__call__back to summary
public PyObject __call__(ThreadState state, PyObject arg0, PyObject arg1)

Overrides org.python.core.PyObject.__call__.

Annotations
@Override
__call__back to summary
public PyObject __call__(PyObject arg0, PyObject arg1, PyObject arg2)

Overrides org.python.core.PyObject.__call__.

Doc from org.python.core.PyObject.__call__.

A variant of the __call__ method with three arguments. The default behavior is to invoke __call__(args, keywords) with the appropriate arguments. The only reason to override this function would be for improved performance.

Parameters
arg0:PyObject

the first argument to the function.

arg1:PyObject

the second argument to the function.

arg2:PyObject

the third argument to the function.

Annotations
@Override
__call__back to summary
public PyObject __call__(ThreadState state, PyObject arg0, PyObject arg1, PyObject arg2)

Overrides org.python.core.PyObject.__call__.

Annotations
@Override
__call__back to summary
public PyObject __call__(PyObject arg0, PyObject arg1, PyObject arg2, PyObject arg3)

Overrides org.python.core.PyObject.__call__.

Doc from org.python.core.PyObject.__call__.

A variant of the __call__ method with four arguments. The default behavior is to invoke __call__(args, keywords) with the appropriate arguments. The only reason to override this function would be for improved performance.

Parameters
arg0:PyObject

the first argument to the function.

arg1:PyObject

the second argument to the function.

arg2:PyObject

the third argument to the function.

arg3:PyObject

the fourth argument to the function.

Annotations
@Override
__call__back to summary
public PyObject __call__(ThreadState state, PyObject arg0, PyObject arg1, PyObject arg2, PyObject arg3)

Overrides org.python.core.PyObject.__call__.

Annotations
@Override
__call__back to summary
public PyObject __call__(PyObject arg1, PyObject[] args, String[] keywords)

Overrides org.python.core.PyObject.__call__.

Doc from org.python.core.PyObject.__call__.

A variant of the __call__ method with one extra initial argument. This variant is used to allow method invocations to be performed efficiently. The default behavior is to invoke __call__(args, keywords) with the appropriate arguments. The only reason to override this function would be for improved performance.

Parameters
arg1:PyObject

the first argument to the function.

args:PyObject[]

the last arguments to the function (including keyword arguments).

keywords:String[]

the keywords used for all keyword arguments.

Annotations
@Override
__call__back to summary
public PyObject __call__(ThreadState state, PyObject arg1, PyObject[] args, String[] keywords)

Overrides org.python.core.PyObject.__call__.

Annotations
@Override
__call__back to summary
public PyObject __call__(PyObject[] args)

Overrides org.python.core.PyObject.__call__.

Doc from org.python.core.PyObject.__call__.

A variant of the __call__ method when no keywords are passed. The default behavior is to invoke __call__(args, keywords) with the appropriate arguments. The only reason to override this function would be for improved performance.

Parameters
args:PyObject[]

all arguments to the function.

Annotations
@Override
__call__back to summary
public PyObject __call__(ThreadState state, PyObject[] args)

Overrides org.python.core.PyObject.__call__.

Annotations
@Override
__call__back to summary
public PyObject __call__(PyObject[] args, String[] keywords)

Overrides org.python.core.PyObject.__call__.

Doc from org.python.core.PyObject.__call__.

The basic method to override when implementing a callable object. The first len(args)-len(keywords) members of args[] are plain arguments. The last len(keywords) arguments are the values of the keyword arguments.

Parameters
args:PyObject[]

all arguments to the function (including keyword arguments).

keywords:String[]

the keywords used for all keyword arguments.

Annotations
@Override
__call__back to summary
public PyObject __call__(ThreadState state, PyObject[] args, String[] keywords)

Overrides org.python.core.PyObject.__call__.

Annotations
@Override
__cmp__back to summary
public int __cmp__(PyObject other)

Overrides org.python.core.PyObject.__cmp__.

Doc from org.python.core.PyObject.__cmp__.

Equivalent to the standard Python __cmp__ method.

Parameters
other:PyObject

the object to compare this with.

Returns:int

-1 if this<o; 0 if this==o; +1 if this>o; -2 if no comparison is implemented

Annotations
@Override

__findattr_ex__back to summary
public PyObject __findattr_ex__(String name)

Overrides org.python.core.PyObject.__findattr_ex__.

Doc from org.python.core.PyObject.__findattr_ex__.

Attribute lookup hook. If the attribute is not found, null may be returned or a Py.AttributeError can be thrown, whatever is more correct, efficient and/or convenient for the implementing class. Client code should use __getattr__(String) or __findattr__(String). Both methods have a clear policy for failed lookups.

Returns:PyObject

The looked up value. May return null if the attribute is not found

Annotations
@Override

__get__back to summary
public PyObject __get__(PyObject obj, PyObject type)

Overrides org.python.core.PyObject.__get__.

Doc from org.python.core.PyObject.__get__.

Get descriptor for this PyObject.

Parameters
obj:PyObject

- the instance accessing this descriptor. Can be null if this is being accessed by a type.

type:PyObject

- the type accessing this descriptor. Will be null if obj exists as obj is of the type accessing the descriptor.

Returns:PyObject

- the object defined for this descriptor for the given obj and type.

Annotations
@Override

__tojava__back to summary
public Object __tojava__(Class<?> c)

Overrides org.python.core.PyObject.__tojava__.

Doc from org.python.core.PyObject.__tojava__.

Equivalent to the Jython __tojava__ method. Tries to coerce this object to an instance of the requested Java class. Returns the special object Py.NoConversion if this PyObject can not be converted to the desired Java class.

Parameters
c:Class<?>

the Class to convert this PyObject to.

Annotations
@Override
checkSelfback to summary
private PyObject checkSelf(PyObject arg, PyObject[] args)
getClassNameback to summary
private String getClassName(PyObject cls)
getDocback to summary
public PyObject getDoc()
Annotations
@ExposedGet
name:__doc__
getFuncback to summary
public PyObject getFunc()

Deprecated

Annotations
@Deprecated
@ExposedGet
name:im_func
getFuncNameback to summary
private String getFuncName()
getInstClassNameback to summary
private String getInstClassName(PyObject inst)
getSelfback to summary
public PyObject getSelf()

Deprecated

Annotations
@Deprecated
@ExposedGet
name:im_self
hashCodeback to summary
public int hashCode()

Overrides org.python.core.PyObject.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override

instancemethod___call__back to summary
pack-priv final PyObject instancemethod___call__(ThreadState state, PyObject[] args, String[] keywords)
Annotations
@ExposedMethod
doc:x.__call__(...) <==> x(...)
instancemethod___cmp__back to summary
pack-priv final int instancemethod___cmp__(PyObject other)
Annotations
@ExposedMethod
type:CMP
doc:x.__cmp__(y) <==> cmp(x,y)
instancemethod___findattr_ex__back to summary
pack-priv final PyObject instancemethod___findattr_ex__(String name)
instancemethod___get__back to summary
pack-priv final PyObject instancemethod___get__(PyObject obj, PyObject type)
Annotations
@ExposedMethod
defaults:null
doc:descr.__get__(obj[, type]) -> value
instancemethod___getattribute__back to summary
pack-priv final PyObject instancemethod___getattribute__(PyObject arg0)
Annotations
@ExposedMethod
doc:x.__getattribute__(\'name\') <==> x.name
instancemethod___new__back to summary
pack-priv static final PyObject instancemethod___new__(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords)
Annotations
@ExposedNew
invokeback to summary
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable

Implements java.lang.reflect.InvocationHandler.invoke.

Doc from java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result. This method will be invoked on an invocation handler when a method is invoked on a proxy instance that it is associated with.

Parameters
proxy:Object

the proxy instance that the method was invoked on

method:Method

the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.

args:Object[]

an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.

Returns:Object

the value to return from the method invocation on the proxy instance. If the declared return type of the interface method is a primitive type, then the value returned by this method must be an instance of the corresponding primitive wrapper class; otherwise, it must be a type assignable to the declared return type. If the value returned by this method is null and the interface method's return type is primitive, then a NullPointerException will be thrown by the method invocation on the proxy instance. If the value returned by this method is otherwise not compatible with the interface method's declared return type as described above, a ClassCastException will be thrown by the method invocation on the proxy instance.

Exceptions
Throwable:
the exception to throw from the method invocation on the proxy instance. The exception's type must be assignable either to any of the exception types declared in the throws clause of the interface method or to the unchecked exception types java.lang.RuntimeException or java.lang.Error. If a checked exception is thrown by this method that is not assignable to any of the exception types declared in the throws clause of the interface method, then an UndeclaredThrowableException containing the exception that was thrown by this method will be thrown by the method invocation on the proxy instance.

proxyback to summary
private Object proxy(Class<?> c)
refersDirectlyToback to summary
public boolean refersDirectlyTo(PyObject ob)

Implements org.python.core.Traverseproc.refersDirectlyTo.

Doc from org.python.core.Traverseproc.refersDirectlyTo.

Optional operation. Should only be implemented if it is more efficient than calling traverse(Visitproc, Object) with a visitproc that just watches out for ob. Must return false if ob is null.

Annotations
@Override
toStringback to summary
public String toString()

Overrides org.python.core.PyObject.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override

traverseback to summary
public int traverse(Visitproc visit, Object arg)

Implements org.python.core.Traverseproc.traverse.

Doc from org.python.core.Traverseproc.traverse.

Traverses all directly contained PyObjects. Like in CPython, arg must be passed unmodified to visit as its second parameter. If Visitproc#visit(PyObject, Object) returns nonzero, this return value must be returned immediately by traverse. Visitproc#visit(PyObject, Object) must not be called with a null PyObject-argument.

Annotations
@Override