PackageManager (Jython API documentation)
Date: 2015-04-29

org.python.core.packagecache

## Class PackageManager

- java.lang.Object
- - org.python.core.packagecache.PackageManager

- Direct Known Subclasses:
    CachedJarsPackageManager

      public abstract class PackageManager
      extends Object

  Abstract package manager.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `PyJavaPackage` | `topLevelPackage`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PackageManager()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `addDirectory(File dir)` Append a directory to the list of directories searched for java packages and java classes.
    `abstract void` | `addJar(String jarfile, boolean cache)` Append a jar file to the list of locations searched for java packages and java classes.
    `abstract void` | `addJarDir(String dir, boolean cache)` Append a directory to the list of directories searched for java packages and java classes.
    `abstract PyList` | `doDir(PyJavaPackage jpkg, boolean instantiate, boolean exclpkgs)` Reports the specified package content names.
    `Class` | `findClass(String pkg, String name)`
    `abstract Class` | `findClass(String pkg, String name, String reason)`
    `PyObject` | `lookupName(String name)`
    `PyJavaPackage` | `makeJavaPackage(String name, String classes, String jarfile)` Creates package/updates statically known classes info.
    `void` | `notifyPackageImport(String pkg, String name)`
    `abstract boolean` | `packageExists(String pkg, String name)` Dynamically check if pkg.name exists as java pkg in the controlled hierarchy.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### topLevelPackage

          public PyJavaPackage topLevelPackage

  - ### Constructor Detail

    - #### PackageManager

          public PackageManager()

  - ### Method Detail

    - #### findClass

          public abstract Class findClass(String pkg,
                        String name,
                        String reason)

    - #### findClass

          public Class findClass(String pkg,
                        String name)

    - #### notifyPackageImport

          public void notifyPackageImport(String pkg,
                                 String name)

    - #### packageExists

          public abstract boolean packageExists(String pkg,
                              String name)

      Dynamically check if pkg.name exists as java pkg in the controlled hierarchy. Should be overriden.
      Parameters:
        `pkg` - parent pkg name
        `name` - candidate name
      Returns:
        true if pkg exists

    - #### doDir

          public abstract PyList doDir(PyJavaPackage jpkg,
                     boolean instantiate,
                     boolean exclpkgs)

      Reports the specified package content names. Should be overriden. Used by `PyJavaPackage.__dir__()` and `PyJavaPackage.fillDir()`.
      Parameters:
        `jpkg` - queried package
        `instantiate` - if true then instatiate reported names in package dict
        `exclpkgs` - exclude packages (just when instantiate is false)
      Returns:
        resulting list of names (PyList of PyString)

    - #### addDirectory

          public abstract void addDirectory(File dir)

      Append a directory to the list of directories searched for java packages and java classes.
      Parameters:
        `dir` - A directory.

    - #### addJarDir

          public abstract void addJarDir(String dir,
                       boolean cache)

      Append a directory to the list of directories searched for java packages and java classes.
      Parameters:
        `dir` - A directory name.

    - #### addJar

          public abstract void addJar(String jarfile,
                    boolean cache)

      Append a jar file to the list of locations searched for java packages and java classes.
      Parameters:
        `jarfile` - A directory name.

    - #### lookupName

          public PyObject lookupName(String name)

    - #### makeJavaPackage

          public PyJavaPackage makeJavaPackage(String name,
                                      String classes,
                                      String jarfile)

      Creates package/updates statically known classes info. Uses `PyJavaPackage.addPackage(java.lang.String, java.lang.String)`, `PyJavaPackage.addPlaceholders(java.lang.String)`.
      Parameters:
        `name` - package name
        `classes` - comma-separated string
        `jarfile` - involved jarfile; can be null
      Returns:
        created/updated package

Jython homepage