Package org.python.core.packagecache

## Class PackageManager

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

- Direct Known Subclasses:
    `CachedJarsPackageManager`

      public abstract class PackageManager
      extends java.lang.Object

  Abstract package manager.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `PyJavaPackage` | `topLevelPackage` | Nominal top-level package of all (Java) packages, containing "java", "com", "org", etc..

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `PackageManager()` |

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `abstract void` | `addDirectory​(java.io.File dir)` | Append a directory to the list of directories searched for java packages and java classes.
    `abstract void` | `addJar​(java.lang.String jarfile, boolean cache)` | Append a jar file to the list of locations searched for java packages and java classes.
    `abstract void` | `addJarDir​(java.lang.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.
    `java.lang.Class` | `findClass​(java.lang.String pkg, java.lang.String name)` |
    `abstract java.lang.Class` | `findClass​(java.lang.String pkg, java.lang.String name, java.lang.String reason)` |
    `PyObject` | `lookupName​(java.lang.String name)` | Given the (dotted) name of a package, find the `PyJavaPackage` corresponding, by navigating from the `topLevelPackage`, successively applying `PyObject.__findattr__(String)`.
    `PyJavaPackage` | `makeJavaPackage​(java.lang.String name, java.lang.String classes, java.lang.String jarfile)` | Create (or ensure we have) a `PyJavaPackage` for the named package and add to it the names of classes mentioned here.
    `void` | `notifyPackageImport​(java.lang.String pkg, java.lang.String name)` |
    `abstract boolean` | `packageExists​(java.lang.String pkg, java.lang.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

      Nominal top-level package of all (Java) packages, containing "java", "com", "org", etc..

  - ### Constructor Detail

    - #### PackageManager

          public PackageManager()

  - ### Method Detail

    - #### findClass

          public abstract java.lang.Class findClass​(java.lang.String pkg,
                                                    java.lang.String name,
                                                    java.lang.String reason)

    - #### findClass

          public java.lang.Class findClass​(java.lang.String pkg,
                                           java.lang.String name)

    - #### notifyPackageImport

          public void notifyPackageImport​(java.lang.String pkg,
                                          java.lang.String name)

    - #### packageExists

          public abstract boolean packageExists​(java.lang.String pkg,
                                                java.lang.String name)

      Dynamically check if pkg.name exists as java pkg in the controlled hierarchy. Should be overridden.
      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 overridden. 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​(java.io.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​(java.lang.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​(java.lang.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​(java.lang.String name)

      Given the (dotted) name of a package, find the `PyJavaPackage` corresponding, by navigating from the `topLevelPackage`, successively applying `PyObject.__findattr__(String)`. This in fact drives the creation of `PyJavaPackage` objects since it indirectly calls `packageExists(String, String)`.
      Parameters:
        `name` - (dotted) package name
      Returns:
        the package named

    - #### makeJavaPackage

          public PyJavaPackage makeJavaPackage​(java.lang.String name,
                                               java.lang.String classes,
                                               java.lang.String jarfile)

      Create (or ensure we have) a `PyJavaPackage` for the named package and add to it the names of classes mentioned here. These classes are added as "place holders" only, so they become members of it, without being instantiated. This method relies on `PyJavaPackage.addPackage(java.lang.String, java.lang.String)` and `PyJavaPackage.addPlaceholders(java.util.Collection<java.lang.String>)`.
      Parameters:
        `name` - package name
        `classes` - comma or @-sign separated string
        `jarfile` - involved; can be null
      Returns:
        created/updated package