if ((path.length() > 1) && (path.charAt(0) == '/')) /* if name has a leading slash */
path = path.substring(1); /* remove leading slash before search */
boolean subPackages = (options & BundleWiring.LISTRESOURCES_RECURSE) != 0;
List<String> packages = new ArrayList<String>();
// search imported package names
KeyedHashSet importSources = getImportedSources(null);
if (importSources != null) {
KeyedElement[] imports = importSources.elements();
for (KeyedElement keyedElement : imports) {
String id = ((PackageSource) keyedElement).getId();
if (id.equals(pkgName) || (subPackages && isSubPackage(pkgName, id)))
packages.add(id);
}
}
// now add package names from required bundles
if (requiredBundles != null) {
KeyedHashSet visited = new KeyedHashSet(false);
visited.add(bundle); // always add ourselves so we do not recurse back to ourselves
for (BundleLoaderProxy requiredProxy : requiredBundles) {
BundleLoader requiredLoader = requiredProxy.getBundleLoader();
requiredLoader.addProvidedPackageNames(requiredProxy.getSymbolicName(), pkgName, packages, subPackages, visited);
}
}