Interface MimetypeService
- All Known Implementing Classes:
MimetypeMap
This service interface provides support for Mimetypes.
- Author:
- Derek Hulley
-
Method Summary
Modifier and TypeMethodDescriptionProvides the system default charset finder.Get all human readable mimetype descriptions indexed by mimetype extensionGet all human readable mimetype descriptions indexed by mimetypegetExtension
(String mimetype) Get the extension for the specified mimetypeGet all mimetype extensions indexed by mimetypegetMimetype
(String extension) Get the mimetype for the specified extensiongetMimetypeIfNotMatches
(ContentReader reader) Use detection heuristics to check if the mime type of the document really matches what it claims to be.Get all mimetypesgetMimetypes
(String extension) Returns a collection of mimetypes ordered by extension.Get all mimetypes indexed by extensionguessMimetype
(String filename) Provides a non-null best guess of the appropriate mimetype given a filename, based entirely on the file extension.guessMimetype
(String filename, InputStream input) Provides a non-null best guess of the appropriate mimetype for a given file.guessMimetype
(String filename, ContentReader reader) Provides a non-null best guess of the appropriate mimetype for a given file.boolean
Check if a given mimetype represents a text format.
-
Method Details
-
getExtension
Get the extension for the specified mimetype- Parameters:
mimetype
- a valid mimetype- Returns:
- Returns the default extension for the mimetype
-
getMimetype
Get the mimetype for the specified extension- Parameters:
extension
- a valid file extension- Returns:
- Returns a valid mimetype if found, or null if does not exist
-
getDisplaysByExtension
Get all human readable mimetype descriptions indexed by mimetype extension- Returns:
- the map of displays indexed by extension
-
getDisplaysByMimetype
Get all human readable mimetype descriptions indexed by mimetype- Returns:
- the map of displays indexed by mimetype
-
getExtensionsByMimetype
Get all mimetype extensions indexed by mimetype- Returns:
- the map of extension indexed by mimetype
-
getMimetypesByExtension
Get all mimetypes indexed by extension- Returns:
- the map of mimetypes indexed by extension
-
isText
Check if a given mimetype represents a text format.- Parameters:
mimetype
- the mimetype to check- Returns:
- Returns true if it is text
-
getMimetypes
Get all mimetypes- Returns:
- all mimetypes
-
guessMimetype
Provides a non-null best guess of the appropriate mimetype given a filename, based entirely on the file extension. Because file extensions can be wrong, you are strongly advised to useguessMimetype(String, ContentReader)
instead.- Parameters:
filename
- the name of the file with an optional file extension- Returns:
- Returns the best guess mimetype or the mimetype for straight binary files if no extension could be found.
-
guessMimetype
Provides a non-null best guess of the appropriate mimetype for a given file. Uses a mixture of file name and file content logic to identify the mimetype for the file, and will usually manage to identify files with incorrect extensions.- Parameters:
filename
- the name of the file with an optional file extensionreader
- a reader for the content of the file- Returns:
- Returns the best guess mimetype or the mimetype for straight binary files if no extension could be found.
-
guessMimetype
Provides a non-null best guess of the appropriate mimetype for a given file. Uses a mixture of file name and file content logic to identify the mimetype for the file, and will usually manage to identify files with incorrect extensions.- Parameters:
filename
- the name of the file with an optional file extensioninput
- an input stream for the content- Returns:
- Returns the best guess mimetype or the mimetype for straight binary files if no extension could be found.
-
getMimetypeIfNotMatches
Use detection heuristics to check if the mime type of the document really matches what it claims to be. This is typically used when a transformation or metadata extractions fails, and you want to know if someone has renamed a file and consequently it has the wrong mime type.- Returns:
- Null if the mime type seems ok, otherwise the mime type it probably is
-
getContentCharsetFinder
Provides the system default charset finder.- Returns:
- Returns a character set finder that can be used to decode streams in order to get the encoding.
- Since:
- 2.1
-
getMimetypes
Returns a collection of mimetypes ordered by extension.- Parameters:
extension
- to restrict the collection to one entry
-