public class AllowPythonClassEnquirer extends java.lang.Object implements ClassEnquirer
A ClassEnquirer that defines specific packages as Python packages.
This implementation takes a delegate ClassEnquirer to delegate all import
determinations as Java or Python except in the cases of the specific Python
package names provided. Imports of the specified packages in the embedded
Python interpreter will use the Python importer and not the Java importer.
This is useful when you have package name conflicts between Java and Python.
Some examples are projects like py4j and tensorflow which have Python package
names matching Java package names. In those cases, using the default
ClassEnquirer of ClassList will lead to the Java packages on the
classpath taking precedence on imports instead of the Python package. That
can be solved by using this ClassEnquirer with a delegate of ClassList's
instance.
RESTRICTED_PKG_NAMES| Constructor and Description |
|---|
AllowPythonClassEnquirer(ClassEnquirer delegate,
java.lang.String... pythonPackageNames)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String[] |
getClassNames(java.lang.String pkgName)
Given a Java package name, gets the fully-qualified classnames available
for import in the package.
|
java.lang.String[] |
getSubPackages(java.lang.String pkgName)
Given a Java package name, gets the sub-packages available.
|
boolean |
isJavaPackage(java.lang.String name)
Checks if the name is likely available in Java as a package.
|
public AllowPythonClassEnquirer(ClassEnquirer delegate, java.lang.String... pythonPackageNames)
delegate - the ClassEnquirer instance to delegate method calls to except
in the case of the specified Python package namespythonPackageNames - the names of Python packages that should not be treated as a
potential import from Java and instead should immediately
default to being imported by the normal Python importerpublic boolean isJavaPackage(java.lang.String name)
ClassEnquirerisJavaPackage in interface ClassEnquirername - the name to check, such as java, java.util,
java.util.ArrayListpublic java.lang.String[] getClassNames(java.lang.String pkgName)
ClassEnquirergetClassNames in interface ClassEnquirerpkgName - the name of a package the ClassEnquirer supports, such as
java.utilpublic java.lang.String[] getSubPackages(java.lang.String pkgName)
ClassEnquirergetSubPackages in interface ClassEnquirerpkgName - the name of a package the ClassEnquirer supports, such as
java.util