Class SiegfriedDetector

All Implemented Interfaces:
Serializable, Detector

public class SiegfriedDetector extends Object implements Detector
Simple wrapper around Siegfried The default behavior is to run detection, report the results in the metadata and then return null so that other detectors will be used.
See Also:
  • Field Details


      public static final String SIEGFRIED_PREFIX
      See Also:

      public static Property SIEGFRIED_STATUS

      public static Property SIEGFRIED_VERSION

      public static Property SIEGFRIED_SIGNATURE

      public static Property SIEGFRIED_IDENTIFIERS_NAME

      public static Property SIEGFRIED_IDENTIFIERS_DETAILS

      public static Property SIEGFRIED_ERRORS
    • ID

      public static String ID
    • FORMAT

      public static String FORMAT

      public static String VERSION
    • MIME

      public static String MIME

      public static String WARNING
    • BASIS

      public static String BASIS
    • ERRORS

      public static String ERRORS
  • Constructor Details

    • SiegfriedDetector

      public SiegfriedDetector()
  • Method Details

    • checkHasSiegfried

      public static boolean checkHasSiegfried(String siegfriedCommandPath)
    • detect

      public MediaType detect(InputStream input, Metadata metadata) throws IOException
      Description copied from interface: Detector
      Detects the content type of the given input document. Returns application/octet-stream if the type of the document can not be detected.

      If the document input stream is not available, then the first argument may be null. Otherwise the detector may read bytes from the start of the stream to help in type detection. The given stream is guaranteed to support the mark feature and the detector is expected to mark the stream before reading any bytes from it, and to reset the stream before returning. The stream must not be closed by the detector.

      The given input metadata is only read, not modified, by the detector.

      Specified by:
      detect in interface Detector
      input - document input stream, or null
      metadata - input metadata for the document
      mime as identified by the file command or application/octet-stream otherwise
    • setUseMime

      @Field public void setUseMime(boolean useMime)
      As default behavior, Tika runs Siegfried to add its detection to the metadata, but NOT to use detection in determining parsers etc. If this is set to true, this detector will return the first mime detected by Siegfried and that mime will be used by the AutoDetectParser to select the appropriate parser.
      useMime -
    • isUseMime

      public boolean isUseMime()
    • processResult

      protected static MediaType processResult(FileProcessResult result, Metadata metadata, boolean returnMime)
    • setSiegfriedPath

      @Field public void setSiegfriedPath(String fileCommandPath)
    • setMaxBytes

      @Field public void setMaxBytes(int maxBytes)
      If this is not called on a TikaInputStream, this detector will spool up to this many bytes to a file to be detected by the 'file' command.
      maxBytes -
    • setTimeoutMs

      @Field public void setTimeoutMs(long timeoutMs)