|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tika.detect.NameDetector
public class NameDetector
Content type detection based on the resource name. An instance of this class contains a set of regular expression patterns that are matched against the resource name potentially given as a part of the input metadata.
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 Summary | |
---|---|
NameDetector(java.util.Map<java.util.regex.Pattern,MediaType> patterns)
Creates a new content type detector based on the given name patterns. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NameDetector(java.util.Map<java.util.regex.Pattern,MediaType> patterns)
patterns
- map from name patterns to corresponding media typesMethod Detail |
---|
public 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.
detect
in interface Detector
input
- ignoredmetadata
- input metadata, possibly with a RESOURCE_NAME_KEY value
application/octet-stream
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |