Example #1
0
 @Override
 public void analyze(Document doc, InputStream in) throws IOException {
   if (in.read() != 'B') {
     throw new IOException("Not BZIP2 format");
   }
   if (in.read() != 'Z') {
     throw new IOException("Not BZIP2 format");
   }
   BufferedInputStream gzis = new BufferedInputStream(new CBZip2InputStream(in));
   String path = doc.get("path");
   if (path != null && (path.endsWith(".bz2") || path.endsWith(".BZ2") || path.endsWith(".bz"))) {
     String newname = path.substring(0, path.lastIndexOf('.'));
     // System.err.println("BZIPPED OF = " + newname);
     fa = AnalyzerGuru.getAnalyzer(gzis, newname);
     if (fa instanceof BZip2Analyzer) {
       fa = null;
     } else {
       if (fa.getGenre() == Genre.PLAIN || fa.getGenre() == Genre.XREFABLE) {
         this.g = Genre.XREFABLE;
       } else {
         this.g = Genre.DATA;
       }
       fa.analyze(doc, gzis);
       if (doc.get("t") != null) {
         doc.removeField("t");
         if (g == Genre.XREFABLE) {
           doc.add(new Field("t", g.typeName(), Field.Store.YES, Field.Index.NOT_ANALYZED));
         }
       }
     }
   }
 }
Example #2
0
 /**
  * Write a cross referenced HTML file.
  *
  * @param out Writer to store HTML cross-reference
  */
 @Override
 public void writeXref(Writer out) throws IOException {
   if ((fa != null) && (fa.getGenre() == Genre.PLAIN || fa.getGenre() == Genre.XREFABLE)) {
     fa.writeXref(out);
   }
 }