Search in sources :

Example 1 with OGKTextField

use of org.opengrok.indexer.analysis.OGKTextField in project OpenGrok by OpenGrok.

the class ELFAnalyzer method analyze.

@Override
public void analyze(Document doc, StreamSource src, Writer xrefOut) throws IOException {
    String fullpath = doc.get("fullpath");
    String content;
    try (RandomAccessFile raf = new RandomAccessFile(fullpath, "r")) {
        content = parseELF(raf.getChannel());
    }
    if (content != null && !content.isEmpty()) {
        doc.add(new OGKTextField(QueryBuilder.FULL, content, Store.NO));
        if (xrefOut != null) {
            xrefOut.append("</pre>");
            Util.htmlize(content, xrefOut);
            xrefOut.append("<pre>");
        }
    }
}
Also used : OGKTextField(org.opengrok.indexer.analysis.OGKTextField) RandomAccessFile(java.io.RandomAccessFile)

Example 2 with OGKTextField

use of org.opengrok.indexer.analysis.OGKTextField in project OpenGrok by OpenGrok.

the class MandocAnalyzer method analyze.

@Override
public void analyze(Document doc, StreamSource src, Writer xrefOut) throws IOException {
    // this is to explicitly use appropriate analyzers tokenstream to
    // workaround #1376 symbols search works like full text search
    JFlexTokenizer symbolTokenizer = symbolTokenizerFactory.get();
    symbolTokenizer.setReader(getReader(src.getStream()));
    OGKTextField full = new OGKTextField(QueryBuilder.FULL, symbolTokenizer);
    doc.add(full);
    if (xrefOut != null) {
        try (Reader in = getReader(src.getStream())) {
            WriteXrefArgs args = new WriteXrefArgs(in, xrefOut);
            args.setProject(project);
            Xrefer xref = writeXref(args);
            String path = doc.get(QueryBuilder.PATH);
            addNumLinesLOC(doc, new NumLinesLOC(path, xref.getLineNumber(), xref.getLOC()));
        }
    }
}
Also used : JFlexTokenizer(org.opengrok.indexer.analysis.JFlexTokenizer) OGKTextField(org.opengrok.indexer.analysis.OGKTextField) NumLinesLOC(org.opengrok.indexer.analysis.NumLinesLOC) Xrefer(org.opengrok.indexer.analysis.Xrefer) Reader(java.io.Reader) WriteXrefArgs(org.opengrok.indexer.analysis.WriteXrefArgs)

Example 3 with OGKTextField

use of org.opengrok.indexer.analysis.OGKTextField in project OpenGrok by OpenGrok.

the class TroffAnalyzer method analyze.

@Override
public void analyze(Document doc, StreamSource src, Writer xrefOut) throws IOException {
    // this is to explicitly use appropriate analyzers tokenstream to workaround #1376 symbols search works like full text search
    JFlexTokenizer symbolTokenizer = symbolTokenizerFactory.get();
    symbolTokenizer.setReader(getReader(src.getStream()));
    OGKTextField full = new OGKTextField(QueryBuilder.FULL, symbolTokenizer);
    doc.add(full);
    if (xrefOut != null) {
        try (Reader in = getReader(src.getStream())) {
            WriteXrefArgs args = new WriteXrefArgs(in, xrefOut);
            args.setProject(project);
            Xrefer xref = writeXref(args);
            String path = doc.get(QueryBuilder.PATH);
            addNumLinesLOC(doc, new NumLinesLOC(path, xref.getLineNumber(), xref.getLOC()));
        }
    }
}
Also used : JFlexTokenizer(org.opengrok.indexer.analysis.JFlexTokenizer) OGKTextField(org.opengrok.indexer.analysis.OGKTextField) NumLinesLOC(org.opengrok.indexer.analysis.NumLinesLOC) Xrefer(org.opengrok.indexer.analysis.Xrefer) Reader(java.io.Reader) WriteXrefArgs(org.opengrok.indexer.analysis.WriteXrefArgs)

Example 4 with OGKTextField

use of org.opengrok.indexer.analysis.OGKTextField 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 5 with OGKTextField

use of org.opengrok.indexer.analysis.OGKTextField 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

OGKTextField (org.opengrok.indexer.analysis.OGKTextField)10 Reader (java.io.Reader)5 WriteXrefArgs (org.opengrok.indexer.analysis.WriteXrefArgs)5 JFlexTokenizer (org.opengrok.indexer.analysis.JFlexTokenizer)4 NumLinesLOC (org.opengrok.indexer.analysis.NumLinesLOC)4 Xrefer (org.opengrok.indexer.analysis.Xrefer)4 ArrayList (java.util.ArrayList)3 IOException (java.io.IOException)2 StringWriter (java.io.StringWriter)2 ZipEntry (java.util.zip.ZipEntry)2 ZipInputStream (java.util.zip.ZipInputStream)2 IteratorReader (org.opengrok.indexer.analysis.IteratorReader)2 BufferedInputStream (java.io.BufferedInputStream)1 RandomAccessFile (java.io.RandomAccessFile)1 ExecutionException (java.util.concurrent.ExecutionException)1 ClassParser (org.apache.bcel.classfile.ClassParser)1 ConstantString (org.apache.bcel.classfile.ConstantString)1 StoredField (org.apache.lucene.document.StoredField)1 TarEntry (org.apache.tools.tar.TarEntry)1 TarInputStream (org.apache.tools.tar.TarInputStream)1