Examples of DefaultDetector


Examples of org.apache.tika.detect.DefaultDetector

            if (mimeType != null) {
                return mimeType;
            }
        }

        DefaultDetector detector = new DefaultDetector();
        Metadata metadata = new Metadata();
        MediaType mediaType = detector.detect(new BufferedInputStream(in), metadata);
        mimeType = mediaType.toString();
        if (mimeType != null) {
            return mimeType;
        }
View Full Code Here

Examples of org.apache.tika.detect.DefaultDetector

        return MimeTypes.getDefaultMimeTypes(loader);
    }

    private static Detector getDefaultDetector(
            MimeTypes types, ServiceLoader loader) {
        return new DefaultDetector(types, loader);
    }
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);
        context.set(PasswordProvider.class, new PasswordProvider() {
            public String getPassword(Metadata metadata) {
                return password;
View Full Code Here

Examples of org.apache.tika.detect.DefaultDetector

   private static final String file = "testWINMAIL.dat";
  
   @Test
   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

     (an OOXML container with binary blobs), but we
     *  shouldn't break on these files either (TIKA-826
     */
    @Test
    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
     */
    @Test
    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

    private boolean prettyPrint;
   
    public TikaCLI() throws Exception {
        context = new ParseContext();
        detector = new DefaultDetector();
        parser = new AutoDetectParser(detector);
        context.set(Parser.class, parser);
        context.set(PasswordProvider.class, new PasswordProvider() {
            public String getPassword(Metadata metadata) {
                return password;
View Full Code Here

Examples of org.apache.tika.detect.DefaultDetector

    private ServiceRegistration parserService;

    public void start(BundleContext context) throws Exception {
        detectorService = context.registerService(
                Detector.class.getName(),
                new DefaultDetector(Activator.class.getClassLoader()),
                new Properties());
        parserService = context.registerService(
                Parser.class.getName(),
                new DefaultParser(Activator.class.getClassLoader()),
                new Properties());
View Full Code Here

Examples of org.apache.tika.detect.DefaultDetector

      is.mark(Integer.MAX_VALUE);
      String encoding = null;
      if(inputType == null) {
        Metadata metadata = new Metadata();
        metadata.set(Metadata.RESOURCE_NAME_KEY, sourceName);
        DefaultDetector detector = new DefaultDetector();
        MediaType type = detector.detect(is, metadata);
   
        ContentHandler contenthandler = new BodyContentHandler();
        AutoDetectParser parser = new AutoDetectParser();
        try {
          parser.parse(is, contenthandler, metadata);
View Full Code Here

Examples of org.apache.tika.detect.DefaultDetector

        assertNotNull(rawDetectors);
        assertTrue("Should have several Detector names, found " + rawDetectors.size(),
                rawDetectors.size() > 3);
       
        // Get the classes found within OSGi
        DefaultDetector detector = new DefaultDetector();
        Set<String> osgiDetectors = new HashSet<String>();
        for (Detector d : detector.getDetectors()) {
            osgiDetectors.add(d.getClass().getName());
        }
       
        // Check that OSGi didn't miss any
        for (String detectorName : rawDetectors) {
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.