public abstract class MediaTypeDetector extends Object
Provides the base class for media type detectors.
Modifier | Constructor and Description |
---|---|
protected |
MediaTypeDetector()
Initializes a new instance of the
MediaTypeDetector class. |
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
checkMediaType(String mediaType)
Detects whether the
mediaType is supported by the detector. |
String |
detect(InputStream stream)
Detects the media type by the content of the
stream . |
String |
detect(InputStream stream,
LoadOptions loadOptions)
Detects the media type by the content of the
stream . |
String |
detect(String fileName)
Detects the media type by the
fileName . |
protected String |
detectByContent(InputStream stream)
Detects the media type by the content of the
stream . |
protected String |
detectByContent(InputStream stream,
LoadOptions loadOptions)
Detects the media type by the content of the
stream . |
protected abstract String |
detectByExt(String ext)
Detects the media type by the
ext . |
boolean |
supports(String mediaType)
Detects whether the
mediaType is supported by the detector. |
protected MediaTypeDetector()
Initializes a new instance of the MediaTypeDetector
class.
public String detect(InputStream stream)
Detects the media type by the content of the stream
.
stream
- Stream of the document.ArgumentNullException
- stream
is null.public String detect(InputStream stream, LoadOptions loadOptions)
Detects the media type by the content of the stream
.
stream
- Stream of the document.loadOptions
- The options of loading the file.ArgumentNullException
- stream
is null.public String detect(String fileName)
Detects the media type by the fileName
.
fileName
- The name of the file.public boolean supports(String mediaType)
Detects whether the mediaType
is supported by the detector.
mediaType
- A string with the media type.protected String detectByContent(InputStream stream)
Detects the media type by the content of the stream
.
stream
- Stream of the document.protected String detectByContent(InputStream stream, LoadOptions loadOptions)
Detects the media type by the content of the stream
.
stream
- Stream of the document.loadOptions
- The options of loading the file.protected abstract String detectByExt(String ext)
Detects the media type by the ext
.
ext
- The extension of the file in the UPPER case.protected abstract boolean checkMediaType(String mediaType)
Detects whether the mediaType
is supported by the detector.
mediaType
- A string with media type in the UPPER case.Copyright © 2019. All rights reserved.