public class PyCallable extends PyObject
Instance Method Example:
jep.exec("class Example(object):\n" +
" def __init__(self):\n" +
" pass\n" +
" def helloWorld(self):\n" +
" return 'Hello World'\n");
jep.exec("instance = Example()");
PyObject pyobj = jep.getValue("instance", PyObject.class);
PyCallable pyHelloWorld = PyObject.getAttr("helloWorld", PyCallable.class);
String result = (String) pyHelloWorld.call();
Function Example:
jep.exec("def hello(arg):\n" +
" return 'Hello ' + str(arg)");
PyCallable pyHello = jep.getValue("hello", PyCallable.class);
String result = (String) pyHello.call("World");
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
call(java.util.Map<java.lang.String,java.lang.Object> kwargs)
Invokes this callable with keyword args.
|
java.lang.Object |
call(java.lang.Object... args)
Invokes this callable with the args in order.
|
java.lang.Object |
call(java.lang.Object[] args,
java.util.Map<java.lang.String,java.lang.Object> kwargs)
Invokes this callable with positional args and keyword args.
|
<T> T |
callAs(java.lang.Class<T> expectedType,
java.util.Map<java.lang.String,java.lang.Object> kwargs)
Invokes this callable with keyword args, converting the return value to
the given class.
|
<T> T |
callAs(java.lang.Class<T> expectedType,
java.lang.Object... args)
Invokes this callable with the args in order, converting the return value
to the given class.
|
<T> T |
callAs(java.lang.Class<T> expectedType,
java.lang.Object[] args,
java.util.Map<java.lang.String,java.lang.Object> kwargs)
Invokes this callable with positional args and keyword args, converting
the return value to the given class.
|
public java.lang.Object call(java.lang.Object... args) throws JepException
args
- args to pass to the function in orderObject
valueJepException
- if an error occurspublic <T> T callAs(java.lang.Class<T> expectedType, java.lang.Object... args) throws JepException
T
- the generic type of the return typeexpectedType
- The expected return type of the invocationargs
- args to pass to the function in orderJepException
- if an error occurspublic java.lang.Object call(java.util.Map<java.lang.String,java.lang.Object> kwargs) throws JepException
kwargs
- a Map of keyword argsObject
valueJepException
- if an error occurspublic <T> T callAs(java.lang.Class<T> expectedType, java.util.Map<java.lang.String,java.lang.Object> kwargs) throws JepException
T
- the generic type of the return typeexpectedType
- The expected return type of the invocationkwargs
- a Map of keyword argsJepException
- if an error occurspublic java.lang.Object call(java.lang.Object[] args, java.util.Map<java.lang.String,java.lang.Object> kwargs) throws JepException
args
- args to pass to the function in orderkwargs
- a Map of keyword argsObject
valueJepException
- if an error occurspublic <T> T callAs(java.lang.Class<T> expectedType, java.lang.Object[] args, java.util.Map<java.lang.String,java.lang.Object> kwargs) throws JepException
T
- the generic type of the return typeexpectedType
- The expected return type of the invocationargs
- args to pass to the function in orderkwargs
- a Map of keyword argsJepException
- if an error occurs