Package 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
Description
`PyJavaPackage`
`topLevelPackage`
Nominal top-level package of all (Java) packages, containing "java", "com", "org", etc..

## Constructor Summary

Constructors
Constructor
Description
`PackageManager()`

## Method Summary

Modifier and Type
Method
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)`
Given the (dotted) name of a package, find the `PyJavaPackage` corresponding, by navigating from the `topLevelPackage`, successively applying `PyObject.__findattr__(String)`.
`PyJavaPackage`
`makeJavaPackage(String name, String classes, 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(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 Details

### topLevelPackage

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

## Constructor Details

### PackageManager

public PackageManager()

## Method Details

### 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 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(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)
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(String name, String classes, 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