KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > python > core > JavaImporter


1 package org.python.core;
2
3 /**
4  * Load Java classes.
5  */

6 public class JavaImporter extends PyObject {
7
8     public JavaImporter() {
9         super();
10     }
11
12     /**
13      * Find the module for the fully qualified name.
14      * @param name the fully qualified name of the module
15      * @return a loader instance if this importer can load the module, None otherwise
16      */

17     public PyObject find_module(String JavaDoc name) {
18         return find_module(name, Py.None);
19     }
20
21     /**
22      * Find the module for the fully qualified name.
23      * @param name the fully qualified name of the module
24      * @param path if installed on the meta-path None or a module path
25      * @return a loader instance if this importer can load the module, None otherwise
26      */

27     public PyObject find_module(String JavaDoc name, PyObject path) {
28         Py.writeDebug("import", "trying " + name + " in packagemanager for path " + path);
29         PyObject ret = PySystemState.packageManager.lookupName(name.intern());
30         if (ret != null) {
31             Py.writeComment("import", "'" + name + "' as java package");
32             return this;
33         }
34         return Py.None;
35     }
36
37     public PyObject load_module(String JavaDoc name) {
38         return PySystemState.packageManager.lookupName(name.intern());
39     }
40
41     /**
42      * Returns a string representation of the object.
43      *
44      * @return a string representation of the object.
45      */

46     public String JavaDoc toString() {
47         return this.getType().toString();
48     }
49 }
50
Popular Tags