Examples of DefaultDetector


Examples of org.apache.tika.detect.DefaultDetector

        }
       
        if (inputStreams.size() > 0) {
          MimeTypes mimeTypes = MimeTypesFactory.create(inputStreams.toArray(new InputStream[inputStreams.size()]));
          ServiceLoader loader = new ServiceLoader();
          this.detector = new DefaultDetector(mimeTypes, loader);
        } else {
          throw new MorphlineCompilationException("Missing specification for MIME type mappings", config);
        }     
      } finally {
        for (InputStream in : inputStreams) {
View Full Code Here

Examples of org.apache.tika.detect.DefaultDetector

    }
   
    protected MediaType getMediaType(BufferedInputStream inputStream, String fileName) throws IOException {
        final TikaInputStream tikaInputStreamStream = TikaInputStream.get(new CloseShieldInputStream(inputStream));
        try {
            final Detector detector = new DefaultDetector();
            final Metadata metadata = new Metadata();
            metadata.set(Metadata.RESOURCE_NAME_KEY, fileName);
           
            final MediaType type = detector.detect(tikaInputStreamStream, metadata);
            logger.debug("Determined '{}' for '{}'", type, fileName);
            return type;
        }
        catch (IOException e) {
            logger.warn("Failed to determine media type for '" + fileName + "' assuming XML", e);
View Full Code Here

Examples of org.apache.tika.detect.DefaultDetector

    public FileSystemContentReader() {
    }

    @PostConstruct
    public void initialise() {
        detector = new DefaultDetector();
        defaultDir = configurationService.getHome()+File.separator+"resources";

        log.debug("FileSystem Content Reader started (default directory: {})",defaultDir);

    }
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

        } catch (Exception e) {
            throw new SystemFailureException(JcrI18n.unableToInitializeMimeTypeDetector.text(urls, e.getMessage()), e);
        }
        // Create the detectors ...
        // this.allDetectors = new DefaultDetector(classLoader);
        this.allDetectors = new DefaultDetector(mimetypes, classLoader);
        this.nameOnlyDetector = mimetypes;

        LOGGER.debug("Initializing the Tika MIME type detectors");
        for (Detector detector : allDetectors.getDetectors()) {
            LOGGER.debug(" - Found detector: " + detector.getClass().getName());
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

    /**
     * Create new Tika-based content extractor using the provided parser instances. 
     * @param parsers parser instances
     */
    public TikaContentExtractor(final List<Parser> parsers) {
        this(parsers, new DefaultDetector());
    }
View Full Code Here

Examples of org.apache.tika.detect.DefaultDetector

     * supported by the parser.
     * @param parser parser instance
     * @param validateMediaType enabled or disable media type validationparser
     */
    public TikaContentExtractor(final Parser parser, final boolean validateMediaType) {
        this(Collections.singletonList(parser), validateMediaType ? new DefaultDetector() : null);
    }
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

        return MimeTypes.getDefaultMimeTypes(loader);
    }

    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.