Class Py
-
Field Summary
Modifier and TypeFieldDescriptionstatic PyObject
static PyObject
static PyObject
static PyObject
static PyObject
static PyObject
static PySystemState
static PyObject
static final PyObject
The singleton Ellipsis Python object - written as ... when indexingstatic final PyFrozenSet
A frozenset with zero elementsstatic final PyObject[]
A zero-length array of PyObject's to pass to functions when we have no argumentsstatic final PyString
A zero-length Python byte stringstatic final PyTuple
A tuple with zero elementsstatic final PyUnicode
A zero-length Python Unicode stringstatic PyObject
static PyObject
static PyObject
static final PyBoolean
The Python boolean Falsestatic PyObject
static PyObject
static PyObject
static PyObject
static PyObject
static PyObject
static PyObject
static PyObject
static PyObject
static PyObject
static PyObject
static PyObject
static PyObject
static PyObject
static final PyString
A Python string containing '\n'static final Object
A unique object to indicate no conversion is possible in __tojava__ methodsstatic final String[]
A zero-length array of Strings to pass to functions that don't have any keyword argumentsstatic final PyObject
The singleton None Python objectstatic final PyObject
The singleton NotImplemented Python object.static PyObject
static final PyInteger
The Python integer 1static PyObject
static PyObject
static PyObject
static PyObject
static PyObject
static PyObject
static final PyString
A Python string containing ' 'static PyObject
static StdoutWrapper
static PyObject
static PyObject
static PyObject
static PyObject
static PyObject
static PyObject
static final long
Set if the type allows subclassingstatic final long
Set if the type object is dynamically allocatedstatic final long
Type is abstract and cannot be instantiatedstatic final PyBoolean
The Python boolean Truestatic PyObject
static PyObject
static PyObject
static PyObject
static PyObject
static final PyUnicode
A Python unicode string containing '\n'static final PyUnicode
A Python unicode string containing ' 'static PyObject
static PyObject
static PyObject
static PyObject
static PyObject
static final PyInteger
The Python integer 0static PyObject
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addTraceback
(Throwable t, PyFrame frame) static void
static void
static PyException
AssertionError
(String message) static PyException
AttributeError
(String message) static PyException
BufferError
(String message) static void
BytesWarning
(String message) static PyCode
compile
(InputStream istream, String filename, CompileMode kind) static PyObject
compile_command_flags
(String string, String filename, CompileMode kind, CompilerFlags cflags, boolean stdprompt) static PyCode
compile_flags
(InputStream istream, String filename, CompileMode kind, CompilerFlags cflags) Compiles python source code coming from a file or another external streamstatic PyCode
compile_flags
(String data, String filename, CompileMode kind, CompilerFlags cflags) Compiles python source code coming from String (raw bytes) data.static PyCode
compile_flags
(org.python.antlr.base.mod node, String name, String filename, boolean linenumbers, boolean printResults, CompilerFlags cflags) Entry point for compiling modules.static PyCode
compile_flags
(org.python.antlr.base.mod node, String filename, CompileMode kind, CompilerFlags cflags) static void
DeprecationWarning
(String message) static void
displayException
(PyObject type, PyObject value, PyObject tb, PyObject file) Print the description of an exception as a big string.static PyException
EnvironmentError
(String message) static PyException
static void
static String
fileSystemDecode
(PyObject filename) static String
fileSystemDecode
(PyString filename) Return a file name or path as Unicode (Java UTF-16String
), decoded if necessary from a Pythonbytes
object, using the file system encoding.static PyString
fileSystemEncode
(String filename) Return a PyString object we can use as a file name or file path in places where Python expects abytes
(that is astr
) object in the file system encoding.static PyString
fileSystemEncode
(PyString filename) Return a PyString object we can use as a file name or file path in places where Python expects abytes
(that is,str
) object in the file system encoding.static Class<?>
Find and load a Java class by name.static Class<?>
findClassEx
(String name, String reason) Find and load a Java class by name.static PyException
FloatingPointError
(String message) static void
static String
formatException
(PyObject type, PyObject value) static String
formatException
(PyObject type, PyObject value, boolean useRepr) static void
FutureWarning
(String message) static PyException
GeneratorExit
(String message) static ExtensiblePyObjectAdapter
static CompilerFlags
static CompilerFlags
getCompilerFlags
(int flags, boolean dont_inherit) static CompilerFlags
getCompilerFlags
(CompilerFlags flags, boolean dont_inherit) static Console
Get the Jython Console (used forinput()
,raw_input()
, etc.) as constructed and set byPySystemState
initialization.static String
The same asgetenv(name, null)
.static String
Get the value of the environment variable named fromos.environ
or return the given default value.static PyString
The same asgetenv(name, null)
.static PyString
Get the value of the environment variable named fromos.environ
or return the given default value.static PyFrame
getFrame()
static String
getName()
static final PySystemState
static final ThreadState
static final ThreadState
getThreadState
(PySystemState newSystemState) static long
static String
static PyException
ImportError
(String message) static boolean
static void
ImportWarning
(String message) static PyException
IndexError
(String message) static void
static boolean
static void
installConsole
(Console console) Install the provided Console, first uninstalling any current one.static PyException
IOError
(IOException ioe) static PyException
static PyException
IOError
(jnr.constants.Constant errno) static PyException
static PyException
static boolean
isInstance
(PyObject inst, PyObject cls) static boolean
isSubClass
(PyObject derived, PyObject cls) static PyObject
static long
static PyObject
Uses the PyObjectAdapter passed toPySystemState.initialize()
to turn o into a PyObject.static PyException
static PyObject
javaPyClass
(PyObject cls, Class<?> interfce) Returns a Python-class that extendscls
andinterfce
.static PyObject[]
Uses the PyObjectAdapter passed toPySystemState.initialize()
to turnobjects
into an array of PyObjects.static PyException
KeyboardInterrupt
(String message) static PyException
static PyException
static final PyString
makeCharacter
(char c) static final PyString
static PyObject
static PyObject
static PyObject
Create a new Python class.static PyObject
static PyException
static PyException
makeException
(PyObject type) static PyException
makeException
(PyObject type, PyObject value) static PyException
makeException
(PyObject type, PyObject value, PyObject traceback) static boolean
matchException
(PyException pye, PyObject exc) Deprecated.static void
static PyException
MemoryError
(String message) static PyException
static PyBoolean
newBoolean
(boolean t) static PyCode
newCode
(int argcount, String[] varnames, String filename, String name, boolean args, boolean keywords, PyFunctionTable funcs, int func_id) static PyCode
newCode
(int argcount, String[] varnames, String filename, String name, boolean args, boolean keywords, PyFunctionTable funcs, int func_id, String[] cellvars, String[] freevars, int npurecell, int moreflags) static PyCode
newCode
(int argcount, String[] varnames, String filename, String name, int firstlineno, boolean args, boolean keywords, PyFunctionTable funcs, int func_id) static PyCode
newCode
(int argcount, String[] varnames, String filename, String name, int firstlineno, boolean args, boolean keywords, PyFunctionTable funcs, int func_id, String[] cellvars, String[] freevars, int npurecell, int moreflags) static PyObject
static PyObject
newDatetime
(Timestamp timestamp) static PyObject
newDecimal
(String decimal) static PyFloat
newFloat
(double v) static PyFloat
newFloat
(float v) static PyComplex
newImaginary
(double v) static final PyInteger
newInteger
(int i) static PyObject
newInteger
(long i) static <T> T
Works likenewJ(PyObject, Class, Object...)
, but looks up the Python-class in the module-dict using the interface-name, i.e.static <T> T
Works likenewJ(PyObject, Class, String[], Object...)
, but looks up the Python-class in the module-dict using the interface-name, i.e.static <T> T
This method is a compact helper to access Python-constructors from Java.static <T> T
This method is a compact helper to access Python-constructors from Java.static <T> T
This method is a compact helper to access Python-constructors from Java.static PyCode
newJavaCode
(Class<?> cls, String name) static PyObject
newJavaFunc
(Class<?> cls, String name) static PyLong
newLong
(int i) static PyLong
newLong
(long l) static PyLong
static PyLong
static PyString
newString
(char c) static PyString
Create aPyString
from a JavaString
.static PyStringMap
static PyString
static PyString
newStringOrUnicode
(PyObject precedent, String s) static PyString
static PyObject
static PyUnicode
newUnicode
(char c) static PyUnicode
newUnicode
(String s) static PyUnicode
newUnicode
(String s, boolean isBasic) static PyException
NotImplementedError
(String message) static PyException
OSError
(IOException ioe) static PyException
static PyException
OSError
(jnr.constants.Constant errno) static PyException
static PyException
OverflowError
(String message) static void
PendingDeprecationWarning
(String message) static void
static void
static void
static void
printComma
(PyObject file, PyObject o) static void
Display an exception and stack trace throughprintException(Throwable, PyFrame, PyObject)
.static void
printException
(Throwable t, PyFrame f) Display an exception and stack trace throughprintException(Throwable, PyFrame, PyObject)
.static void
printException
(Throwable t, PyFrame f, PyObject file) Display an exception and stack trace.static void
println()
static void
static void
static void
static void
printResult
(PyObject ret) static boolean
static byte
static char
static char
static double
static float
static int
static int
static long
static short
static void
static PyException
ReferenceError
(String message) static PyObject
static void
runMain
(CodeBootstrap main, String[] args) Initializes a default PythonInterpreter and runs the code loaded from theCodeBootstrap
as __main__ Called by the code generated inModule.addMain()
static void
runMain
(PyRunnable main, String[] args) Initializes a default PythonInterpreter and runs the code fromPyRunnable.getMain()
as __main__ Called by the code generated inModule.addMain()
static PyException
RuntimeError
(String message) static void
RuntimeWarning
(String message) static void
saveClassFile
(String name, ByteArrayOutputStream bytestream) static PyException
setException
(Throwable t, PyFrame frame) static void
static final PySystemState
setSystemState
(PySystemState newSystemState) static PyException
StopIteration
(String message) static PyException
SyntaxError
(String message) static void
SyntaxWarning
(String message) static PyException
SystemError
(String message) static <T> T
Convert a givenPyObject
to an instance of a Java class.static Object
static PyException
static PyException
UnboundLocalError
(String message) static PyException
UnicodeDecodeError
(String encoding, String object, int start, int end, String reason) static PyException
UnicodeEncodeError
(String encoding, String object, int start, int end, String reason) static PyException
UnicodeError
(String message) static PyException
UnicodeTranslateError
(String object, int start, int end, String reason) static void
UnicodeWarning
(String message) static PyObject[]
unpackSequence
(PyObject obj, int length) static void
UserWarning
(String message) static PyException
ValueError
(String message) static void
static void
static void
warning
(PyObject category, String message, String filename, int lineno, String module, PyObject registry) static void
static void
static void
static void
writeUnraisable
(Throwable unraisable, PyObject obj) static PyException
ZeroDivisionError
(String message) Methods inherited from class org.python.core.PrePy
getCommandResult, getCommandResultWindows, getDefaultBinDir, getDefaultExecutableName, getJarFileName, getJarFileNameFromURL, getLoggingLevel, getSystemProperties, getSystemProperty, haveConsole, increaseLoggingLevel, isInteractive, isInteractive, levelFromVerbosity, maybeWrite, setLoggingLevel, verbosityFromLevel, writeComment, writeDebug, writeError, writeMessage, writeWarning
-
Field Details
-
None
The singleton None Python object -
Ellipsis
The singleton Ellipsis Python object - written as ... when indexing -
NotImplemented
The singleton NotImplemented Python object. Used in rich comparison -
NoKeywords
A zero-length array of Strings to pass to functions that don't have any keyword arguments -
EmptyObjects
A zero-length array of PyObject's to pass to functions when we have no arguments -
EmptyFrozenSet
A frozenset with zero elements -
EmptyTuple
A tuple with zero elements -
Zero
The Python integer 0 -
One
The Python integer 1 -
False
The Python boolean False -
True
The Python boolean True -
EmptyString
A zero-length Python byte string -
EmptyUnicode
A zero-length Python Unicode string -
Newline
A Python string containing '\n' -
UnicodeNewline
A Python unicode string containing '\n' -
Space
A Python string containing ' ' -
UnicodeSpace
A Python unicode string containing ' ' -
TPFLAGS_HEAPTYPE
public static final long TPFLAGS_HEAPTYPESet if the type object is dynamically allocated- See Also:
-
TPFLAGS_BASETYPE
public static final long TPFLAGS_BASETYPESet if the type allows subclassing- See Also:
-
TPFLAGS_IS_ABSTRACT
public static final long TPFLAGS_IS_ABSTRACTType is abstract and cannot be instantiated- See Also:
-
NoConversion
A unique object to indicate no conversion is possible in __tojava__ methods -
OSError
-
NotImplementedError
-
EnvironmentError
-
OverflowError
-
RuntimeError
-
KeyboardInterrupt
-
FloatingPointError
-
SyntaxError
-
IndentationError
-
TabError
-
AttributeError
-
IOError
-
KeyError
-
AssertionError
-
TypeError
-
ReferenceError
-
SystemError
-
IndexError
-
ZeroDivisionError
-
NameError
-
UnboundLocalError
-
SystemExit
-
StopIteration
-
GeneratorExit
-
ImportError
-
ValueError
-
UnicodeError
-
UnicodeTranslateError
-
UnicodeDecodeError
-
UnicodeEncodeError
-
EOFError
-
MemoryError
-
BufferError
-
ArithmeticError
-
LookupError
-
StandardError
-
Exception
-
BaseException
-
Warning
-
UserWarning
-
DeprecationWarning
-
PendingDeprecationWarning
-
SyntaxWarning
-
RuntimeWarning
-
FutureWarning
-
ImportWarning
-
UnicodeWarning
-
BytesWarning
-
JavaError
-
defaultSystemState
-
stderr
-
-
Method Details
-
OSError
-
OSError
-
OSError
-
OSError
-
NotImplementedError
-
EnvironmentError
-
OverflowError
-
RuntimeError
-
KeyboardInterrupt
-
FloatingPointError
-
SyntaxError
-
AttributeError
-
IOError
-
IOError
-
IOError
-
IOError
-
IOError
-
KeyError
-
KeyError
-
AssertionError
-
TypeError
-
ReferenceError
-
SystemError
-
IndexError
-
ZeroDivisionError
-
NameError
-
UnboundLocalError
-
StopIteration
-
GeneratorExit
-
ImportError
-
ValueError
-
UnicodeError
-
UnicodeTranslateError
-
UnicodeDecodeError
public static PyException UnicodeDecodeError(String encoding, String object, int start, int end, String reason) -
UnicodeEncodeError
public static PyException UnicodeEncodeError(String encoding, String object, int start, int end, String reason) -
EOFError
-
memory_error
-
MemoryError
-
BufferError
-
Warning
-
UserWarning
-
DeprecationWarning
-
PendingDeprecationWarning
-
SyntaxWarning
-
RuntimeWarning
-
FutureWarning
-
ImportWarning
-
UnicodeWarning
-
BytesWarning
-
warnPy3k
-
warnPy3k
-
warning
-
warning
-
warning
-
JavaError
-
tojava
Convert a givenPyObject
to an instance of a Java class. Identical too.__tojava__(c)
except that it will raise aTypeError
if the conversion fails.- Parameters:
o
- thePyObject
to convert.c
- the class to convert it to.
-
tojava
-
newInteger
-
newInteger
-
newLong
-
newLong
-
newLong
-
newLong
-
newImaginary
-
newFloat
-
newFloat
-
newString
-
newString
Create aPyString
from a JavaString
. Thethe character codes must all be all < 256. (This is checked.)- Parameters:
s
- character codes are all < 256.- Returns:
- a new
PyString
-
newStringOrUnicode
Return aPyString
for the given JavaString
, if it can be represented as US-ASCII, and aPyUnicode
otherwise.- Parameters:
s
- string content- Returns:
PyString
orPyUnicode
according to content ofs
.
-
newStringOrUnicode
Return aPyString
for the given JavaString
, if it can be represented as US-ASCII and if a preceding object is not aPyUnicode
, and aPyUnicode
otherwise. In some contexts, we want the result to be aPyUnicode
if some preceding result is aPyUnicode
.- Parameters:
precedent
- string of which the type sets a precedents
- string content- Returns:
PyString
orPyUnicode
according to content ofs
.
-
newStringUTF8
-
fileSystemDecode
Return a file name or path as Unicode (Java UTF-16String
), decoded if necessary from a Pythonbytes
object, using the file system encoding. In Jython, this encoding is UTF-8, irrespective of the OS platform. This method is comparable with Python 3os.fsdecode
, but for Java use, in places such as theos
module. If the argument is not aPyUnicode
, it will be decoded using the nominal Jython file system encoding. If the argument is aPyUnicode
, itsString
is returned.- Parameters:
filename
- asbytes
to decode, or already asunicode
- Returns:
- unicode version of path
-
fileSystemDecode
- Parameters:
filename
- asbytes
to decode, or already asunicode
- Returns:
- unicode version of the file name
-
fileSystemEncode
Return a PyString object we can use as a file name or file path in places where Python expects abytes
(that is astr
) object in the file system encoding. In Jython, this encoding is UTF-8, irrespective of the OS platform.This is subtly different from CPython's use of "file system encoding", which tracks the platform's choice so that OS services may be called that have a bytes interface. Jython's interaction with the OS occurs via Java using String arguments representing Unicode values, so we have no need to match the encoding actually chosen by the platform (e.g. 'mbcs' on Windows). Rather we need a nominal Jython file system encoding, for use where the standard library forces byte paths on us (in Python 2). There is no reason for this choice to vary with OS platform. Methods receiving paths as
bytes
willfileSystemDecode(PyString)
them again for Java.- Parameters:
filename
- asunicode
to encode, or already asbytes
- Returns:
- encoded bytes version of path
-
fileSystemEncode
Return a PyString object we can use as a file name or file path in places where Python expects abytes
(that is,str
) object in the file system encoding. In Jython, this encoding is UTF-8, irrespective of the OS platform. This method is comparable with Python 3os.fsencode
. If the argument is a PyString, it is returned unchanged. If the argument is a PyUnicode, it is converted to abytes
using the nominal Jython file system encoding.- Parameters:
filename
- asunicode
to encode, or already asbytes
- Returns:
- encoded bytes version of path
-
getenv
The same asgetenv(name, null)
. Seegetenv(PyString, PyString)
. -
getenv
Get the value of the environment variable named fromos.environ
or return the given default value. Empty string values are treated as undefined for this purpose.- Parameters:
name
- of the environment variable.defaultValue
- to return ifkey
is not defined (may benull
.- Returns:
- the corresponding value or
defaultValue
.
-
getenv
The same asgetenv(name, null)
. Seegetenv(String, String)
. -
getenv
Get the value of the environment variable named fromos.environ
or return the given default value. This is a convenience wrapper ongetenv(PyString, PyString)
which takes care of the fact that environment variables are FS-encoded.- Parameters:
name
- to access in the environment.defaultValue
- to return ifkey
is not defined.- Returns:
- the corresponding value or
defaultValue
.
-
newStringMap
-
newUnicode
-
newUnicode
-
newUnicode
-
newBoolean
-
newDate
-
newTime
-
newDatetime
-
newDecimal
-
newCode
-
newCode
-
newCode
public static PyCode newCode(int argcount, String[] varnames, String filename, String name, boolean args, boolean keywords, PyFunctionTable funcs, int func_id) -
newCode
public static PyCode newCode(int argcount, String[] varnames, String filename, String name, int firstlineno, boolean args, boolean keywords, PyFunctionTable funcs, int func_id) -
newJavaCode
-
newJavaFunc
-
initPython
public static boolean initPython() -
findClass
Find and load a Java class by name.- Parameters:
name
- of the Java class.- Returns:
- the class, or
null
if it wasn't found or something went wrong
-
findClassEx
Find and load a Java class by name.- Parameters:
name
- Name of the Java class.reason
- for finding the class. Used in debugging messages.- Returns:
- the class, or
null
if it simply wasn't found - Throws:
PyException
-JavaError
wrapping errors occurring when the class is found but cannot be loaded.
-
initProxy
-
runMain
Initializes a default PythonInterpreter and runs the code fromPyRunnable.getMain()
as __main__ Called by the code generated inModule.addMain()
- Throws:
Exception
-
runMain
Initializes a default PythonInterpreter and runs the code loaded from theCodeBootstrap
as __main__ Called by the code generated inModule.addMain()
- Throws:
Exception
-
printException
Display an exception and stack trace throughprintException(Throwable, PyFrame, PyObject)
.- Parameters:
t
- to display
-
printException
Display an exception and stack trace throughprintException(Throwable, PyFrame, PyObject)
.- Parameters:
t
- to displayf
- frame at which to start the stack trace
-
printException
Display an exception and stack trace. If the exception wasSystemExit
andOptions.inspect
==false
, this will exit the JVM.- Parameters:
t
- to displayf
- frame at which to start the stack tracefile
- output onto this stream orstderr
ifnull
-
displayException
Print the description of an exception as a big string. The arguments are closely equivalent to the tuple returned by Pythonsys.exc_info
, on standard error or a given byte-oriented file. Compare with Pythontraceback.print_exception
.- Parameters:
type
- of exceptionvalue
- the exception parameter (second argument toraise
)tb
- traceback of the call stack where the exception originally occurredfile
- to print encoded string to, or null meaning standard error
-
formatException
-
formatException
-
writeUnraisable
-
assert_
-
assert_
-
addTraceback
-
setException
-
matchException
Deprecated.As of Jython 2.5, usePyException.match(org.python.core.PyObject)
instead. -
makeException
-
makeException
-
makeException
-
makeException
-
runCode
-
exec
-
getThreadState
-
getThreadState
-
setSystemState
-
getSystemState
-
getFrame
-
setFrame
-
getConsole
Get the Jython Console (used forinput()
,raw_input()
, etc.) as constructed and set byPySystemState
initialization.- Returns:
- the Jython Console
-
installConsole
public static void installConsole(Console console) throws UnsupportedOperationException, IOException Install the provided Console, first uninstalling any current one. The Jython Console is used forraw_input()
etc., and may provide line-editing and history recall at the prompt. A Console may replaceSystem.in
with its line-editing input method.- Parameters:
console
- The new Console object- Throws:
UnsupportedOperationException
- if some prior Console refuses to uninstallIOException
- ifConsole.install()
raises it
-
importSiteIfSelected
public static boolean importSiteIfSelected() -
print
-
printComma
-
println
-
printlnv
-
print
-
printComma
-
println
-
println
public static void println() -
flushLine
public static void flushLine() -
py2boolean
-
py2byte
-
py2short
-
py2int
-
py2int
-
py2long
-
py2float
-
py2double
-
py2char
-
py2char
-
py2void
-
makeCharacter
-
makeCharacter
-
java2py
Uses the PyObjectAdapter passed toPySystemState.initialize()
to turn o into a PyObject.- See Also:
-
javas2pys
Uses the PyObjectAdapter passed toPySystemState.initialize()
to turnobjects
into an array of PyObjects.- See Also:
-
getAdapter
- Returns:
- the ExtensiblePyObjectAdapter used by java2py.
-
makeClass
-
makeClass
-
makeClass
-
makeClass
Create a new Python class.- Parameters:
name
- the String name of the classbases
- an array of PyObject base classesdict
- the class's namespace, containing the class body definition- Returns:
- a new Python Class PyObject
-
getName
-
getCompilerFlags
-
getCompilerFlags
-
getCompilerFlags
-
compile
-
compile_flags
public static PyCode compile_flags(org.python.antlr.base.mod node, String name, String filename, boolean linenumbers, boolean printResults, CompilerFlags cflags) Entry point for compiling modules.- Parameters:
node
- Module node, coming from the parsing processname
- Internal name for the compiled code. Typically generated by callinggetName()
.filename
- Source file namelinenumbers
- True to track source line numbers on the generated codeprintResults
- True to call the sys.displayhook on the result of the codecflags
- Compiler flags- Returns:
- Code object for the compiled module
-
compile_flags
public static PyCode compile_flags(org.python.antlr.base.mod node, String filename, CompileMode kind, CompilerFlags cflags) -
compile_flags
public static PyCode compile_flags(InputStream istream, String filename, CompileMode kind, CompilerFlags cflags) Compiles python source code coming from a file or another external stream -
compile_flags
public static PyCode compile_flags(String data, String filename, CompileMode kind, CompilerFlags cflags) Compiles python source code coming from String (raw bytes) data. If the String is properly decoded (from PyUnicode) the PyCF_SOURCE_IS_UTF8 flag should be specified. -
compile_command_flags
public static PyObject compile_command_flags(String string, String filename, CompileMode kind, CompilerFlags cflags, boolean stdprompt) -
unpackSequence
-
iter
-
id
-
idstr
-
java_obj_id
-
printResult
-
saveClassFile
-
isInstance
-
isSubClass
-
javaPyClass
Returns a Python-class that extendscls
andinterfce
. Ifcls
already extendsinterfce
, simplycls
is returned. Otherwise a new class is created (if not yet cached). It caches such classes and only creates a new one if no appropriate class was cached yet.- Returns:
- a Python-class that extends
cls
andinterfce
-
newJ
This method is a compact helper to access Python-constructors from Java. It creates an instance ofcls
and retruns it in form ofjcls
, which must be an interface. This method even works ifcls
does not extendjcls
in Python-code. In that case, it usesjavaPyClass(PyObject, Class)
to create an appropriate class on the fly.It automatically converts
args
toPyObject
s.
For keyword-support usenewJ(PyObject, Class, String[], Object...)
.- Parameters:
cls
- - the class to be instanciatedjcls
- - the Java-type to be returnedargs
- are automatically converted to Jython-PyObjects- Returns:
- an instance of cls in form of the interface jcls
- See Also:
-
newJ
This method is a compact helper to access Python-constructors from Java. It creates an instance ofcls
and retruns it in form ofjcls
, which must be an interface. This method even works ifcls
does not extendjcls
in Python-code. In that case, it usesjavaPyClass(PyObject, Class)
to create an appropriate class on the fly.keywordss
are applied to the lastargs
in the list.- Parameters:
cls
- - the class to be instanciatedjcls
- - the Java-type to be returnedkeywords
- are applied to the last argsargs
- for the Python-class constructor- Returns:
- an instance of cls in form of the interface jcls
- See Also:
-
newJ
This method is a compact helper to access Python-constructors from Java. It creates an instance ofcls
and retruns it in form ofjcls
, which must be an interface. This method even works ifcls
does not extendjcls
in Python-code. In that case, it usesjavaPyClass(PyObject, Class)
to create an appropriate class on the fly.It automatically converts
args
toPyObject
s.
keywordss
are applied to the lastargs
in the list.- Parameters:
cls
- - the class to be instanciatedjcls
- - the Java-type to be returnedkeywords
- are applied to the last argsargs
- are automatically converted to Jython-PyObjects- Returns:
- an instance of cls in form of the interface jcls
- See Also:
-
newJ
Works likenewJ(PyObject, Class, Object...)
, but looks up the Python-class in the module-dict using the interface-name, i.e.jcls.getSimpleName()
.For keywords-support use
newJ(PyModule, Class, String[], Object...)
.- Parameters:
module
- the module containing the desired classjcls
- Java-type of the desired clas, must have the same nameargs
- constructor-arguments- Returns:
- a new instance of the desired class
- See Also:
-
newJ
Works likenewJ(PyObject, Class, String[], Object...)
, but looks up the Python-class in the module-dict using the interface-name, i.e.jcls.getSimpleName()
.keywordss
are applied to the lastargs
in the list.- Parameters:
module
- the module containing the desired classjcls
- Java-type of the desired class, must have the same namekeywords
- are applied to the lastargs
in the listargs
- constructor-arguments- Returns:
- a new instance of the desired class
- See Also:
-
PyException.match(org.python.core.PyObject)
instead.