Examples of DefaultDetector


Examples of org.apache.tika.detect.DefaultDetector

     * @throws IOException  if the built-in media type rules can not be read
     */
    public TikaConfig(ClassLoader loader)
            throws MimeTypeException, IOException {
        this.mimeTypes = MimeTypes.getDefaultMimeTypes();
        this.detector = new DefaultDetector(mimeTypes, loader);
        this.parser = new DefaultParser(mimeTypes.getMediaTypeRegistry(), loader);
    }
View Full Code Here

Examples of org.apache.tika.detect.DefaultDetector

            config = System.getenv("TIKA_CONFIG");
        }
        if (config == null) {
            this.mimeTypes = MimeTypes.getDefaultMimeTypes();
            this.parser = new DefaultParser(mimeTypes.getMediaTypeRegistry());
            this.detector = new DefaultDetector(mimeTypes);
        } else {
            ClassLoader loader = ServiceLoader.getContextClassLoader();
            InputStream stream;
            File file = new File(config);
            if (file.isFile()) {
View Full Code Here

Examples of org.apache.tika.detect.DefaultDetector

    private boolean prettyPrint;
   
    public TikaCLI() throws Exception {
        context = new ParseContext();
        detector = new DefaultDetector();
        parser = new AutoDetectParser(detector);
        context.set(Parser.class, parser);
    }
View Full Code Here

Examples of org.apache.tika.detect.DefaultDetector

public class TNEFParserTest extends AbstractPOIContainerExtractionTest {
   private static final String file = "testWINMAIL.dat";
  
   public void testBasics() throws Exception {
      TikaInputStream stream = getTestFile(file);
      Detector detector = new DefaultDetector();
      try {
         assertEquals(
                 MediaType.application("vnd.ms-tnef"),
                 detector.detect(stream, new Metadata()));
     } finally {
         stream.close();
     }
   }
View Full Code Here

Examples of org.apache.tika.detect.DefaultDetector

     * We don't currently support the .xlsb file format
     *  (an OOXML container with binary blobs), but we
     *  shouldn't break on these files either (TIKA-826
     */
    public void testExcelXLSB() throws Exception {
       Detector detector = new DefaultDetector();
       AutoDetectParser parser = new AutoDetectParser();
      
       InputStream input = ExcelParserTest.class.getResourceAsStream(
             "/test-documents/testEXCEL.xlsb");
       Metadata m = new Metadata();
       m.add(Metadata.RESOURCE_NAME_KEY, "excel.xlsb");
      
       // Should be detected correctly
       MediaType type = null;
       try {
          type = detector.detect(input, m);
          assertEquals("application/vnd.ms-excel.sheet.binary.macroenabled.12", type.toString());
       } finally {
          input.close();
       }
      
View Full Code Here

Examples of org.apache.tika.detect.DefaultDetector

    /**
     * We don't currently support the old Excel 95 .xls file format,
     *  but we shouldn't break on these files either (TIKA-976) 
     */
    public void testExcel95() throws Exception {
       Detector detector = new DefaultDetector();
       AutoDetectParser parser = new AutoDetectParser();
      
       InputStream input = ExcelParserTest.class.getResourceAsStream(
             "/test-documents/testEXCEL_95.xls");
       Metadata m = new Metadata();
       m.add(Metadata.RESOURCE_NAME_KEY, "excel_95.xls");
      
       // Should be detected correctly
       MediaType type = null;
       try {
          type = detector.detect(input, m);
          assertEquals("application/vnd.ms-excel", type.toString());
       } finally {
          input.close();
       }
      
View Full Code Here

Examples of org.apache.tika.detect.DefaultDetector

     *
     * @param detector Detector to use
     * @param parsers
     */
    public AutoDetectParser(Parser...parsers) {
        this(new DefaultDetector(), parsers);
    }
View Full Code Here

Examples of org.apache.tika.detect.DefaultDetector

public class TNEFParserTest extends AbstractPOIContainerExtractionTest {
   private static final String file = "testWINMAIL.dat";
  
   public void testBasics() throws Exception {
      TikaInputStream stream = getTestFile(file);
      Detector detector = new DefaultDetector();
      try {
         assertEquals(
                 MediaType.application("vnd.ms-tnef"),
                 detector.detect(stream, new Metadata()));
     } finally {
         stream.close();
     }
   }
View Full Code Here

Examples of org.apache.tika.detect.DefaultDetector

     * We don't currently support the .xlsb file format
     *  (an OOXML container with binary blobs), but we
     *  shouldn't break on these files either (TIKA-826
     */
    public void testExcelXLSB() throws Exception {
       Detector detector = new DefaultDetector();
       AutoDetectParser parser = new AutoDetectParser();
      
       InputStream input = ExcelParserTest.class.getResourceAsStream(
             "/test-documents/testEXCEL.xlsb");
       Metadata m = new Metadata();
       m.add(Metadata.RESOURCE_NAME_KEY, "excel.xlsb");
      
       // Should be detected correctly
       MediaType type = null;
       try {
          type = detector.detect(input, m);
          assertEquals("application/vnd.ms-excel.sheet.binary.macroenabled.12", type.toString());
       } finally {
          input.close();
       }
      
View Full Code Here

Examples of org.apache.tika.detect.DefaultDetector

        return MimeTypes.getDefaultMimeTypes();
    }

    private static Detector getDefaultDetector(
            MimeTypes types, ServiceLoader loader) {
        return new DefaultDetector(types, loader);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.