public Collection getDocuments()

in apache-rat-core/src/main/java/org/apache/rat/walker/ArchiveWalker.java [84:106]


    public Collection<Document> getDocuments() throws RatException {
        List<Document> result = new ArrayList<>();
        try (ArchiveInputStream<? extends ArchiveEntry> input = new ArchiveStreamFactory().createArchiveInputStream(createInputStream())) {
            ArchiveEntry entry;
            while ((entry = input.getNextEntry()) != null) {
                if (!entry.isDirectory() && input.canReadEntryData(entry)) {
                    DocumentName innerName = DocumentName.builder().setName(entry.getName())
                            .setBaseName(".").build();
                    if (this.getDocument().getNameMatcher().matches(innerName)) {
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        IOUtils.copy(input, baos);
                        ArchiveEntryName entryName = new ArchiveEntryName(getDocument().getName(), entry.getName());
                        result.add(new ArchiveEntryDocument(entryName, baos.toByteArray(), getDocument().getNameMatcher()));
                    }
                }
            }
        } catch (ArchiveException e) {
            DefaultLog.getInstance().warn(format("Unable to process %s: %s", getDocument().getName(), e.getMessage()));
        } catch (IOException e) {
            throw RatException.makeRatException(e);
        }
        return result;
    }