public class ProbabilisticMimeDetectionSelector extends java.lang.Object implements Detector
Modifier and Type | Class and Description |
---|---|
static class |
ProbabilisticMimeDetectionSelector.Builder
build class for probability parameters setting
|
Modifier and Type | Field and Description |
---|---|
private float |
changeRate |
private static float |
DEFAULT_EXTENSION_TRUST |
private static float |
DEFAULT_MAGIC_TRUST
probability parameters default value
|
private static float |
DEFAULT_META_TRUST |
private float |
extension_neg |
private float |
extension_trust |
private float |
magic_neg |
private float |
magic_trust |
private float |
meta_neg |
private float |
meta_trust |
private MimeTypes |
mimeTypes |
private float |
priorExtensionFileType |
private float |
priorMagicFileType |
private float |
priorMetaFileType |
private MediaType |
rootMediaType |
private static long |
serialVersionUID |
private float |
threshold |
Constructor and Description |
---|
ProbabilisticMimeDetectionSelector() |
ProbabilisticMimeDetectionSelector(MimeTypes mimeTypes) |
ProbabilisticMimeDetectionSelector(MimeTypes mimeTypes,
ProbabilisticMimeDetectionSelector.Builder builder) |
ProbabilisticMimeDetectionSelector(ProbabilisticMimeDetectionSelector.Builder builder) |
Modifier and Type | Method and Description |
---|---|
private MediaType |
applyProbilities(java.util.List<MimeType> possibleTypes,
MimeType extMimeType,
MimeType metadataMimeType) |
MediaType |
detect(java.io.InputStream input,
Metadata metadata)
Detects the content type of the given input document.
|
MediaTypeRegistry |
getMediaTypeRegistry() |
private void |
initializeDefaultProbabilityParameters()
Initilize probability parameters with default values;
|
private static final long serialVersionUID
private MimeTypes mimeTypes
private final MediaType rootMediaType
private static final float DEFAULT_MAGIC_TRUST
private static final float DEFAULT_META_TRUST
private static final float DEFAULT_EXTENSION_TRUST
private float priorMagicFileType
private float priorExtensionFileType
private float priorMetaFileType
private float magic_trust
private float extension_trust
private float meta_trust
private float magic_neg
private float extension_neg
private float meta_neg
private float threshold
private float changeRate
public ProbabilisticMimeDetectionSelector()
public ProbabilisticMimeDetectionSelector(ProbabilisticMimeDetectionSelector.Builder builder)
public ProbabilisticMimeDetectionSelector(MimeTypes mimeTypes)
public ProbabilisticMimeDetectionSelector(MimeTypes mimeTypes, ProbabilisticMimeDetectionSelector.Builder builder)
private void initializeDefaultProbabilityParameters()
public MediaType detect(java.io.InputStream input, Metadata metadata) throws java.io.IOException
Detector
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.
private MediaType applyProbilities(java.util.List<MimeType> possibleTypes, MimeType extMimeType, MimeType metadataMimeType)
public MediaTypeRegistry getMediaTypeRegistry()