Examples of detect()


Examples of org.apache.tika.detect.DefaultDetector.detect()

            }
        }

        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.Detector.detect()

          String ct = metadata.get(org.apache.tika.metadata.HttpHeaders.CONTENT_TYPE);

          if (ct!=null) {
            return MediaType.parse(ct);
          } else {
            return detector.detect(inputStream, metadata);
          }
        }
      });
    }
  }
View Full Code Here

Examples of org.apache.tika.detect.TextDetector.detect()

        // Finally, assume plain text if no control bytes are found
        try {
            TextDetector detector = new TextDetector(getMinLength());
            ByteArrayInputStream stream = new ByteArrayInputStream(data);
            return forName(detector.detect(stream, new Metadata()).toString());
        } catch (Exception e) {
            return rootMimeType;
        }
    }
View Full Code Here

Examples of org.apache.tika.detect.ZipContainerDetector.detect()

          // It's OOXML
          TikaInputStream ooxmlStream = TikaInputStream.get(
                new DocumentInputStream((DocumentEntry)ooxml)
          );
          ZipContainerDetector detector = new ZipContainerDetector();
          MediaType type = detector.detect(ooxmlStream, new Metadata());
          handleEmbeddedResource(ooxmlStream, null, type.toString(), xhtml, true);
          return;
       } catch(FileNotFoundException e) {
          // It's regular OLE2
       }
View Full Code Here

Examples of org.apache.tika.mime.MimeTypes.detect()

        for (Map.Entry<File, String> entry : files.entrySet()) {
            String name = entry.getValue();
            File file = entry.getKey();

            byte[] buf = IOUtils.toByteArray(new FileInputStream(file));
            MediaType mediaType = mimeTypes.
                    detect(new ByteArrayInputStream(buf), new Metadata());
            MimeType mimeType = mimeTypes.forName(mediaType.toString());
            FileBody fb = new FileBody(file, name + mimeType.getExtension(),
                    mimeType.getName(), Consts.UTF_8.name());
View Full Code Here

Examples of org.apache.tika.parser.pkg.ZipContainerDetector.detect()

            TikaInputStream stream = TikaInputStream.get(
                    new DocumentInputStream((DocumentEntry) ooxml));
            try {
                ZipContainerDetector detector = new ZipContainerDetector();
                MediaType type = detector.detect(stream, new Metadata());
                handleEmbeddedResource(stream, null, dir.getName(), type.toString(), xhtml, true);
                return;
            } finally {
                stream.close();
            }
View Full Code Here

Examples of org.apache.tika.parser.txt.CharsetDetector.detect()

    public String guessEncoding(InputStream is) throws IOException {
        CharsetDetector charsetDetector = new CharsetDetector();
        charsetDetector.setText( is instanceof BufferedInputStream ? is : new BufferedInputStream(is) );
        charsetDetector.enableInputFilter(true);
        CharsetMatch cm = charsetDetector.detect();
        return cm.getName();
    }

}
View Full Code Here

Examples of org.atmosphere.util.annotation.AnnotationDetector.detect()

        AnnotationDetector detector = new AnnotationDetector(atmosphereReporter);
        try {
            if (packages.size() > 0) {
                for (String p : packages) {
                    logger.trace("Package {} scanned for @AtmosphereAnnotation", p);
                    detector.detect(p);
                }
            }

            // Now look for application defined annotation
            String path = IOUtils.realPath(f.getServletContext(), f.getHandlersPath());
View Full Code Here

Examples of org.elasticsearch.monitor.jvm.HotThreads.detect()

                .busiestThreads(request.request.threads)
                .type(request.request.type)
                .interval(request.request.interval)
                .threadElementsSnapshotCount(request.request.snapshots);
        try {
            return new NodeHotThreads(clusterService.localNode(), hotThreads.detect());
        } catch (Exception e) {
            throw new ElasticsearchException("failed to detect hot threads", e);
        }
    }
View Full Code Here

Examples of org.tmatesoft.hg.repo.HgLookup.detect()

    File srcRepoLoc = RepoUtils.cloneRepoToTempLocation("test-annotate", "test-pull2empty-src", false);
    File dstRepoLoc = RepoUtils.initEmptyTempRepo("test-pull2empty-dst");
    HgServer server = new HgServer().start(srcRepoLoc);
    try {
      final HgLookup hgLookup = new HgLookup();
      final HgRemoteRepository srcRemote = hgLookup.detect(server.getURL());
      final HgRepository dstRepo = hgLookup.detect(dstRepoLoc);
      HgPullCommand cmd = new HgPullCommand(dstRepo).source(srcRemote);
      cmd.execute();
      final HgRepository srcRepo = hgLookup.detect(srcRepoLoc);
      checkRepositoriesAreSame(srcRepo, dstRepo);
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.