public class NameDetector extends 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(Map<Pattern,MediaType> patterns)
Creates a new content type detector based on the given name patterns.
|
Modifier and Type | Method and Description |
---|---|
MediaType |
detect(InputStream input,
Metadata metadata)
Detects the content type of an input document based on the document
name given in the input metadata.
|
public NameDetector(Map<Pattern,MediaType> patterns)
patterns
- map from name patterns to corresponding media typespublic MediaType detect(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 © 2007–2016 The Apache Software Foundation. All rights reserved.