public boolean hasNext()

in src/java/org/apache/ivy/osgi/repo/ArtifactReportManifestIterable.java [72:131]


        public boolean hasNext() {
            while (next == null && it.hasNext()) {
                ModuleRevisionId mrid = it.next();
                ArtifactDownloadReport jar = null;
                ArtifactDownloadReport source = null;
                for (ArtifactDownloadReport report : artifactReports.get(mrid)) {
                    if (sourceTypes != null && sourceTypes.contains(report.getArtifact().getType())) {
                        source = report;
                    } else {
                        jar = report;
                    }
                }
                if (jar == null) {
                    // didn't found any suitable jar
                    continue;
                }
                URI sourceURI = null;
                if (source != null) {
                    if (source.getUnpackedLocalFile() != null) {
                        sourceURI = source.getUnpackedLocalFile().toURI();
                    } else {
                        sourceURI = source.getLocalFile().toURI();
                    }
                }
                if (jar.getUnpackedLocalFile() != null && jar.getUnpackedLocalFile().isDirectory()) {
                    try (FileInputStream in = new FileInputStream(new File(jar.getUnpackedLocalFile(),
                            "META-INF/MANIFEST.MF"))) {
                        next = new ManifestAndLocation(new Manifest(in), jar.getUnpackedLocalFile()
                                .toURI(), sourceURI);
                        return true;
                    } catch (FileNotFoundException e) {
                        Message.debug(
                                "Bundle directory file just removed: " + jar.getUnpackedLocalFile(), e);
                    } catch (IOException e) {
                        Message.debug("The Manifest in the bundle directory could not be read: "
                                + jar.getUnpackedLocalFile(), e);
                    }
                } else {
                    File artifact;
                    if (jar.getUnpackedLocalFile() != null) {
                        artifact = jar.getUnpackedLocalFile();
                    } else {
                        artifact = jar.getLocalFile();
                    }
                    try (JarInputStream in = new JarInputStream(new FileInputStream(artifact))) {
                        Manifest manifest = in.getManifest();
                        if (manifest != null) {
                            next = new ManifestAndLocation(manifest, artifact.toURI(), sourceURI);
                            return true;
                        }
                        Message.debug("No manifest in jar: " + artifact);
                    } catch (FileNotFoundException e) {
                        Message.debug("Jar file just removed: " + artifact, e);
                    } catch (IOException e) {
                        Message.warn("Unreadable jar: " + artifact, e);
                    }
                }
            }
            return next != null;
        }