Search in sources :

Example 1 with IteratorReader

use of org.opensolaris.opengrok.analysis.IteratorReader in project OpenGrok by OpenGrok.

the class TarAnalyzer method analyze.

@Override
public void analyze(Document doc, StreamSource src, Writer xrefOut) throws IOException {
    ArrayList<String> names = new ArrayList<>();
    try (TarInputStream zis = new TarInputStream(src.getStream())) {
        TarEntry entry;
        while ((entry = zis.getNextEntry()) != null) {
            String name = entry.getName();
            names.add(name);
            if (xrefOut != null) {
                Util.htmlize(name, xrefOut);
                xrefOut.append("<br/>");
            }
        }
    }
    doc.add(new TextField("full", new IteratorReader(names)));
}
Also used : IteratorReader(org.opensolaris.opengrok.analysis.IteratorReader) TarInputStream(org.apache.tools.tar.TarInputStream) ArrayList(java.util.ArrayList) TextField(org.apache.lucene.document.TextField) TarEntry(org.apache.tools.tar.TarEntry)

Example 2 with IteratorReader

use of org.opensolaris.opengrok.analysis.IteratorReader in project OpenGrok by OpenGrok.

the class ZipAnalyzer method analyze.

@Override
public void analyze(Document doc, StreamSource src, Writer xrefOut) throws IOException {
    ArrayList<String> names = new ArrayList<>();
    try (ZipInputStream zis = new ZipInputStream(src.getStream())) {
        ZipEntry entry;
        while ((entry = zis.getNextEntry()) != null) {
            String name = entry.getName();
            names.add(name);
            if (xrefOut != null) {
                Util.htmlize(name, xrefOut);
                xrefOut.append("<br/>");
            }
        }
    }
    doc.add(new TextField("full", new IteratorReader(names)));
}
Also used : ZipInputStream(java.util.zip.ZipInputStream) IteratorReader(org.opensolaris.opengrok.analysis.IteratorReader) ZipEntry(java.util.zip.ZipEntry) ArrayList(java.util.ArrayList) TextField(org.apache.lucene.document.TextField)

Aggregations

ArrayList (java.util.ArrayList)2 TextField (org.apache.lucene.document.TextField)2 IteratorReader (org.opensolaris.opengrok.analysis.IteratorReader)2 ZipEntry (java.util.zip.ZipEntry)1 ZipInputStream (java.util.zip.ZipInputStream)1 TarEntry (org.apache.tools.tar.TarEntry)1 TarInputStream (org.apache.tools.tar.TarInputStream)1