public class NameDetector extends java.lang.Object implements Detector
If a pattern matches the given name, then the media type associated with
that pattern is returned as the likely content type of the input document.
Otherwise the returned type is application/octet-stream
.
See the detect(InputStream, Metadata)
method for more details
of the matching algorithm.
Constructor and Description |
---|
NameDetector(java.util.Map<java.util.regex.Pattern,MediaType> patterns)
Creates a new content type detector based on the given name patterns.
|
Modifier and Type | Method and Description |
---|---|
MediaType |
detect(java.io.InputStream input,
Metadata metadata)
Detects the content type of an input document based on the document
name given in the input metadata.
|
public NameDetector(java.util.Map<java.util.regex.Pattern,MediaType> patterns)
patterns
- map from name patterns to corresponding media typespublic MediaType detect(java.io.InputStream input, Metadata metadata)
If a resource name is given, then it is first processed as follows.
The resulting name string (if any) is then matched in sequence against all the configured name patterns. If a match is found, then the (first) matching media type is returned.
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"