Package org.apache.tika.detect.siegfried
Class SiegfriedDetector
java.lang.Object
org.apache.tika.detect.siegfried.SiegfriedDetector
- All Implemented Interfaces:
Serializable
,Detector
Simple wrapper around Siegfried https://github.com/richardlehane/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 Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
checkHasSiegfried
(String siegfriedCommandPath) detect
(InputStream input, Metadata metadata) Detects the content type of the given input document.boolean
protected static MediaType
processResult
(FileProcessResult result, Metadata metadata, boolean returnMime) 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.void
setSiegfriedPath
(String fileCommandPath) void
setTimeoutMs
(long timeoutMs) 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.
-
Field Details
-
SIEGFRIED_PREFIX
- See Also:
-
SIEGFRIED_STATUS
-
SIEGFRIED_VERSION
-
SIEGFRIED_SIGNATURE
-
SIEGFRIED_IDENTIFIERS_NAME
-
SIEGFRIED_IDENTIFIERS_DETAILS
-
SIEGFRIED_ERRORS
-
ID
-
FORMAT
-
VERSION
-
MIME
-
WARNING
-
BASIS
-
ERRORS
-
-
Constructor Details
-
SiegfriedDetector
public SiegfriedDetector()
-
-
Method Details
-
checkHasSiegfried
-
detect
Description copied from interface:Detector
Detects the content type of the given input document. Returnsapplication/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 themark feature
and the detector is expected tomark
the stream before reading any bytes from it, and toreset
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 interfaceDetector
- Parameters:
input
- document input stream, ornull
metadata
- input metadata for the document- Returns:
- mime as identified by the file command or application/octet-stream otherwise
- Throws:
IOException
-
setUseMime
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 totrue
, this detector will return the first mime detected by Siegfried and that mime will be used by the AutoDetectParser to select the appropriate parser.- Parameters:
useMime
-
-
isUseMime
public boolean isUseMime() -
processResult
protected static MediaType processResult(FileProcessResult result, Metadata metadata, boolean returnMime) -
setSiegfriedPath
-
setMaxBytes
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.- Parameters:
maxBytes
-
-
setTimeoutMs
-