Class OpendesktopMimeDetector
The Opendesktop shared mime database contains glob rules and magic number lookup information to enable applications to detect the mime types of files.
This class uses the mime.cache file which is one of the files created by the update-mime-database application. This file is a memory mapped file that enables the database to be updated and copied without interrupting applications.
This implementation follows the memory mapped spec so it is not required to restart an application using this mime detector should the underlying mime.cache database change.
For a complete description of the information contained in this file please see: http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info- spec-latest.html
This class also follows, where possible, the RECOMENDED order of detection as detailed in this spec. Thanks go to Mathias Clasen at Red Hat for pointing me to the original xdgmime implementation http://svn.gnome.org/viewvc/glib/trunk/ gio/xdgmime/xdgmimecache.c?revision=7784invalid input: '&view'=markup
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddelete()You can override this method if for instance you allocated any resources in the init() method that need to be closed or deallocated specially.dump()Abstract method to be implement by concrete MimeDetector(s).getMimeTypesByteArray(byte[] data) This method is unable to perform glob matching as no name is available.getMimeTypesFile(File file) This method resolves mime types closely in accordance with the RECOMENDED order of detection detailed in the Opendesktop shared mime database specification http://standards.freedesktop.org/shared-mime-info-spec/shared -mime-info-spec-latest.html See the Recommended checking order.getMimeTypesFileName(String fileName) This method resolves mime types closely in accordance with the RECOMENDED order of detection detailed in the Opendesktop shared mime database specification http://standards.freedesktop.org/shared-mime-info-spec/shared -mime-info-spec-latest.html See the Recommended checking order.This method is unable to perform glob matching as no name is available.getMimeTypesURL(URL url) This method resolves mime types closely in accordance with the RECOMENDED order of detection detailed in the Opendesktop shared mime database specification http://standards.freedesktop.org/shared-mime-info-spec/shared -mime-info-spec-latest.html See the Recommended checking order.Methods inherited from class MimeDetector
closeStream, getMimeTypes, getMimeTypes, getMimeTypes, getMimeTypes, getMimeTypes, getName, init
-
Constructor Details
-
OpendesktopMimeDetector
-
OpendesktopMimeDetector
public OpendesktopMimeDetector()
-
-
Method Details
-
delete
public void delete()Description copied from class:MimeDetectorYou can override this method if for instance you allocated any resources in the init() method that need to be closed or deallocated specially.- Overrides:
deletein classMimeDetector
-
getDescription
Description copied from class:MimeDetectorAbstract method to be implement by concrete MimeDetector(s).- Specified by:
getDescriptionin classMimeDetector- Returns:
- description of this MimeDetector
-
getMimeTypesFileName
This method resolves mime types closely in accordance with the RECOMENDED order of detection detailed in the Opendesktop shared mime database specification http://standards.freedesktop.org/shared-mime-info-spec/shared -mime-info-spec-latest.html See the Recommended checking order.- Specified by:
getMimeTypesFileNamein classMimeDetector- Parameters:
fileName-- Returns:
- Collection of matched MimeType(s)
-
getMimeTypesURL
This method resolves mime types closely in accordance with the RECOMENDED order of detection detailed in the Opendesktop shared mime database specification http://standards.freedesktop.org/shared-mime-info-spec/shared -mime-info-spec-latest.html See the Recommended checking order.- Specified by:
getMimeTypesURLin classMimeDetector- Returns:
- Collection of matched MimeType(s)
-
getMimeTypesFile
This method resolves mime types closely in accordance with the RECOMENDED order of detection detailed in the Opendesktop shared mime database specification http://standards.freedesktop.org/shared-mime-info-spec/shared -mime-info-spec-latest.html See the Recommended checking order.- Specified by:
getMimeTypesFilein classMimeDetector- Parameters:
file-- Returns:
- Collection of matched MimeType(s)
- Throws:
UnsupportedOperationException
-
getMimeTypesInputStream
This method is unable to perform glob matching as no name is available. This means that it does not follow the recommended order of detection defined in the shared mime database spec http://standards.freedesktop.org/ shared-mime-info-spec/shared-mime-info-spec-latest.html- Specified by:
getMimeTypesInputStreamin classMimeDetector- Parameters:
in- InputStream.- Returns:
- Collection of matched MimeType(s)
- Throws:
UnsupportedOperationException
-
getMimeTypesByteArray
This method is unable to perform glob matching as no name is available. This means that it does not follow the recommended order of detection defined in the shared mime database spec http://standards.freedesktop.org/ shared-mime-info-spec/shared-mime-info-spec-latest.html- Specified by:
getMimeTypesByteArrayin classMimeDetector- Parameters:
data- byte []. Is a byte array that you want to parse for matching mime types.- Returns:
- Collection of matched MimeType(s)
- Throws:
UnsupportedOperationException
-
dump
-