Search in sources :

Example 1 with IteratorReader

use of org.opengrok.indexer.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 OGKTextField(QueryBuilder.FULL, new IteratorReader(names)));
}
Also used : OGKTextField(org.opengrok.indexer.analysis.OGKTextField) IteratorReader(org.opengrok.indexer.analysis.IteratorReader) TarInputStream(org.apache.tools.tar.TarInputStream) ArrayList(java.util.ArrayList) TarEntry(org.apache.tools.tar.TarEntry)

Example 2 with IteratorReader

use of org.opengrok.indexer.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 OGKTextField(QueryBuilder.FULL, new IteratorReader(names)));
}
Also used : ZipInputStream(java.util.zip.ZipInputStream) OGKTextField(org.opengrok.indexer.analysis.OGKTextField) IteratorReader(org.opengrok.indexer.analysis.IteratorReader) ZipEntry(java.util.zip.ZipEntry) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)2 IteratorReader (org.opengrok.indexer.analysis.IteratorReader)2 OGKTextField (org.opengrok.indexer.analysis.OGKTextField)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